Skip to content

Commit

Permalink
Merge pull request #119 from vacantron/hotfix
Browse files Browse the repository at this point in the history
Fix snapshot test
  • Loading branch information
jserv authored Mar 19, 2024
2 parents 0ba28d1 + cd17c30 commit 6999393
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tests/check-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ function check_snapshot() {

$SHECC --dump-ir -o $temp_exe $source &>/dev/null
dot -Tdot_json -o $temp_json CFG.dot
diff -q <(cat $ref) <(sed -E "/0x[0-9a-f]+/d" $temp_json | jq -S -c .)
diff -q <(cat $ref) \
<(sed -E "/0x[0-9a-f]+/d" $temp_json | \
jq -S -c '.edges |= sort_by(._gvid) | .objects |= sort_by(._gvid) |
.objects |= map_values(.edges |= (. // [] | sort)) |
.objects |= map_values(.nodes |= (. // [] | sort)) |
.objects |= map_values(.subgraphs |= (. // [] | sort))')
}

for file in tests/*.c; do
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/fib.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/snapshots/hello.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion tests/update-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ function update_snapshot() {
$SHECC --dump-ir -o $temp_exe $source &>/dev/null
dot -Tdot_json -o $temp_json CFG.dot
sed -i -E "/0x[0-9a-f]+/d" $temp_json
jq -S -c . $temp_json > $dest
jq -S -c '.edges |= sort_by(._gvid) | .objects |= sort_by(._gvid) |
.objects |= map_values(.edges |= (. // [] | sort)) |
.objects |= map_values(.nodes |= (. // [] | sort)) |
.objects |= map_values(.subgraphs |= (. // [] | sort))' $temp_json > $dest
}

for file in tests/*.c; do
Expand Down

0 comments on commit 6999393

Please sign in to comment.