File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
DIR=$( mktemp -d)
4
4
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
+
5
32
cp -r tests/solc-multi-file " $DIR "
6
33
cd " $DIR /solc-multi-file" || exit 255
7
34
crytic-compile --compile-remove-metadata --export-formats solc,truffle A.sol
8
35
9
36
cd - || exit 255
10
37
node 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
+
11
50
DIFF=$( diff -r " $DIR /solc-multi-file/crytic-export" tests/expected/solc-multi-file)
12
51
if [ " $? " != " 0" ] || [ " $DIFF " != " " ]
13
52
then
You can’t perform that action at this time.
0 commit comments