@@ -153,13 +153,29 @@ get_kani_path() {
153153
154154get_harnesses () {
155155 local kani_path=" $1 "
156- # Run kani list with JSON format and process with jq to extract all harness names
157- # Note: This code is based on `kani list` JSON version 0.1 -- if the version changes, this logic may need to change as well.
158- " $kani_path " list -Z list -Z function-contracts -Z mem-predicates -Z float-lib -Z c-ffi ./library --std --format json \
156+ " $kani_path " list -Z list -Z function-contracts -Z mem-predicates -Z float-lib -Z c-ffi ./library --std --format json | \
157+ # Note: this command is based on kani list JSON version 0.1.
158+ # If the JSON format changes, this command may need to be updated.
159+ # We group each file's standard and contract harnesses together, so that standard and contract harnesses for a single file are
160+ # more likely to run on the same partition.
159161 jq -r '
160- ([.["standard-harnesses"] | to_entries | .[] | .value[]] +
161- [.["contract-harnesses"] | to_entries | .[] | .value[]]) |
162- .[]
162+ # Merge standard and contract harnesses by file
163+ (reduce (.["standard-harnesses"] | to_entries[]) as $entry ({};
164+ . + { ($entry.key): $entry.value }
165+ )) as $std |
166+ (reduce (.["contract-harnesses"] | to_entries[]) as $entry ({};
167+ . + { ($entry.key): $entry.value }
168+ )) as $contract |
169+ # Get all unique files, sorted alphabetically
170+ ($std | keys + $contract | keys | unique | sort) as $all_files |
171+ # For each file, output its harnesses in order
172+ reduce $all_files[] as $file ({};
173+ . + {
174+ ($file): (($std[$file] // []) + ($contract[$file] // []))
175+ }
176+ ) |
177+ to_entries |
178+ .[].value[]
163179 '
164180}
165181
0 commit comments