Skip to content

Commit 5f10cb4

Browse files
committed
Fix tests on OSX
1 parent 239849e commit 5f10cb4

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/json.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ JSON._dump() {
122122
fi
123123
done
124124
prev=("${line[@]}")
125-
done < <(sort -k1,1V -u; )
125+
done < <(sort -k '1,1' -u )
126126
local indent=$(( ${#stack} - 1 ))
127127
for (( i=0; i<${#stack}; i++ )); do
128128
if [ "${stack:$i:1}" = "a" ]; then

test/dump.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_dump() {
2828
dbg json2
2929
is "$json2" "$json1" "dump | load | dump produces same result as dump"
3030

31-
is "$(grep -o : <<<"$json1" | wc -l)" \
31+
is $(grep -o : <<<"$json1" | wc -l) \
3232
"$(grep -oE '/[^/ ]*' test/dump.data | sort -u | grep -cvE '/[0-9]*$')" \
3333
"dumped result contains correct number of keys"
3434

test/keys.t

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ is "$(JSON.get '/files/file 2.txt/type' tree1)" \
1515

1616
file_object=$(JSON.object '/files' tree1)
1717

18+
# XXX Can't get osx and linux to sort these the same. Workaround:
19+
{
20+
if [[ "$(uname)" == Darwin ]]; then
21+
expect="file 2.txt"$'\n'"file1.txt"
22+
else
23+
expect="file1.txt"$'\n'"file 2.txt"
24+
fi
25+
}
26+
1827
keys="$(JSON.keys '/' file_object)"
1928
is "$keys" \
20-
"file1.txt"$'\n'"file 2.txt" \
29+
"$expect" \
2130
"JSON.keys '/'" #'
2231

2332
keys="$(JSON.keys '/files' tree1)"
2433
is "$keys" \
25-
"file1.txt"$'\n'"file 2.txt" \
34+
"$expect" \
2635
"JSON.keys '/files'" #'
2736

2837
keys="$(JSON.keys '/' tree1)"

0 commit comments

Comments
 (0)