File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 22
33DIR=$( mktemp -d)
44
5+ normalize_file () {
6+ JQ_SCRIPT=$( cat << 'EOF '
7+ def sort_deps:
8+ if type == "object" then
9+ # Process each key-value pair
10+ with_entries(
11+ if .key == "contractDependencies" and (.value | type == "array") then
12+ .value = (.value | sort)
13+ else
14+ .value = (.value | sort_deps)
15+ end
16+ )
17+ elif type == "array" then
18+ # Process each array element recursively
19+ map(sort_deps)
20+ else
21+ .
22+ end;
23+
24+ sort_deps
25+ EOF
26+ )
27+
28+ jq " $JQ_SCRIPT " " $1 " > " $1 .mod"
29+ mv " $1 .mod" " $1 "
30+ }
31+
532cp -r tests/solc-multi-file " $DIR "
633cd " $DIR /solc-multi-file" || exit 255
734crytic-compile --compile-remove-metadata --export-formats solc,truffle A.sol
835
936cd - || exit 255
1037node tests/process_combined_solc.js " $DIR /solc-multi-file/crytic-export/combined_solc.json" " $DIR "
38+
39+ case " $( uname -sr) " in
40+ # for some reason, contractDependencies appear in random order in Windows
41+ # so we sort them for consistency in the tests
42+ CYGWIN* |MINGW* |MSYS* )
43+ echo " Testing on Windows, doing extra JSON normalization"
44+ for f in " $DIR /solc-multi-file/crytic-export/" * .json tests/expected/solc-multi-file/* .json; do
45+ normalize_file " $f "
46+ done
47+ ;;
48+ esac
49+
1150DIFF=$( diff -r " $DIR /solc-multi-file/crytic-export" tests/expected/solc-multi-file)
1251if [ " $? " != " 0" ] || [ " $DIFF " != " " ]
1352then
You can’t perform that action at this time.
0 commit comments