Skip to content

Commit

Permalink
#2291: Update scripts for the output to be less noisy
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Jul 12, 2024
1 parent a0ec659 commit df3886c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/lb_data/lb_data_file_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ int main(int argc, char** argv) {

vt::finalize();
return 0;
}
}
2 changes: 1 addition & 1 deletion scripts/LBDatafile_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@
},
]
}
)
)
18 changes: 4 additions & 14 deletions scripts/check_lb_data_files.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env bash

set -exo pipefail
set -eo pipefail

path_to_vt_build_dir=${1}
path_to_vt_src_dir=${2}
cd "$path_to_vt_build_dir" || exit 1

function run_schema_validator() {
file=$1
echo ""
echo "Running schema validator on: $file"
if python3 "${path_to_vt_src_dir}/scripts/JSON_data_files_validator.py" --file_path="$file"
then
Expand All @@ -19,23 +18,14 @@ function run_schema_validator() {
fi
}

find . -iname "*.json" | grep -v "compile_commands" | while read f
do
run_schema_validator "$f"
done

find "${path_to_vt_src_dir}/examples" -iname "*.json" | while read f
do
run_schema_validator "$f"
done

find . -iname "*.json.br" | while read f
find . "${path_to_vt_src_dir}/examples" -iname "*.json" -o -iname "*.json.br" \
| grep -v "compile_commands" | while read f
do
run_schema_validator "$f"
done

# Compare output of the lb_data_file_generator example with reference file
if ! python3 "${path_to_vt_src_dir}/scripts/generate_and_validate_lb_data_file.py" \
if ! python3 "${path_to_vt_src_dir}/scripts/compare_lb_data_file.py" \
-f "${path_to_vt_build_dir}/examples/lb_data/lb_data_file_generator_1_LBDatafile.0.json" \
-r "${path_to_vt_src_dir}/examples/lb_data/lb_data_file_example.json"
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ def compare(file_to_validate, reference_file):
"""
Compares file to validate wih reference
"""
print("Comparing '" + file_to_validate + "' with reference file '" + reference_file + "'.")

with open(file_to_validate) as val_file, open(reference_file) as ref_file:
to_validate = json.load(val_file)
reference = json.load(ref_file)
diff = DeepDiff(to_validate, reference, report_repetition=True, math_epsilon=0.1)
is_valid = not len(diff.affected_paths)

if not is_valid:
sys.stderr.write("Comparing '" + file_to_validate + "' with reference file '" + reference_file + "'... Failed!\n")
sys.stderr.write("Detected differences:\n")
json.dump(str(diff), sys.stderr, indent=4)
sys.stderr.write("\n")
sys.stderr.flush()
sys.exit(1)
else:
print("Comparison OK.")
print("Comparing '" + file_to_validate + "' with reference file '" + reference_file + "'... Status OK.")

def main():
parser = argparse.ArgumentParser()
parser.add_argument("--file-to-check", "-f", dest='file', required=True)
parser.add_argument("--reference-file", "-r", dest='reference_file', required=False)
parser.add_argument("--reference-file", "-r", dest='reference_file', required=True)
args = parser.parse_args()

compare(args.file, args.reference_file)
Expand Down

0 comments on commit df3886c

Please sign in to comment.