diff --git a/tests/integrate/Autotest.sh b/tests/integrate/Autotest.sh index 546626ec9e..2be862754f 100755 --- a/tests/integrate/Autotest.sh +++ b/tests/integrate/Autotest.sh @@ -548,10 +548,11 @@ if [ -z $g ]; then exit 1 fi else - if [ "$fatal" -gt 0 ] || [ "$failed" -gt 0 ]; then - echo -e "\e[0;31m[ERROR ]\e[0m Reference generation failed for $fatal cases." - printf "%b" "$fatal_case_list" + if [ "$fatal" -eq 0 ] && [ "$failed" -eq 0 ]; then + echo "Generate test cases complete." + else + echo -e "\e[0;31m[ERROR ]\e[0m Reference generation failed for $(($fatal + $failed)) case(s)." + printf "%b" "$fatal_case_list$failed_case_list" exit 1 fi - echo "Generate test cases complete." fi diff --git a/tests/integrate/CMakeLists.txt b/tests/integrate/CMakeLists.txt index b3670710fd..48910ac3c4 100644 --- a/tests/integrate/CMakeLists.txt +++ b/tests/integrate/CMakeLists.txt @@ -1,4 +1,22 @@ find_program(BASH bash) +# Validation-script regressions do not impose a Python configure dependency +# on builds that only use a dedicated output validator. +find_package(Python3 QUIET COMPONENTS Interpreter) +if(Python3_Interpreter_FOUND) + add_test( + NAME compare_file_test + COMMAND ${Python3_EXECUTABLE} -m unittest validation_tools/test_compare_file.py + WORKING_DIRECTORY ${ABACUS_TEST_DIR}/integrate + ) + + add_test( + NAME catch_properties_test + COMMAND ${BASH} validation_tools/test_catch_properties.sh + WORKING_DIRECTORY ${ABACUS_TEST_DIR}/integrate + ) +else() + message(STATUS "Python3 interpreter not found; skipping validation-script regression tests") +endif() if(ENABLE_ASAN) add_test( diff --git a/tests/integrate/validation_tools/CompareFile.py b/tests/integrate/validation_tools/CompareFile.py index 71148f80f7..08e8c473b3 100755 --- a/tests/integrate/validation_tools/CompareFile.py +++ b/tests/integrate/validation_tools/CompareFile.py @@ -61,6 +61,8 @@ def ReadParam(): return file1,file2,epsilon,useAbsoluteVal,compareAbsoluteDiff def is_two_data_diff(data1,data2,epsilon,compareAbsoluteDiff): + if not math.isfinite(data1) or not math.isfinite(data2): + return True if compareAbsoluteDiff: if abs(data1-data2) > epsilon: return True else: @@ -122,6 +124,11 @@ def ReadFile(file1,lines): try: with open(file1) as f1: for line in f1.readlines(): lines.append(line) + # A final blank line carries no numerical information and varies among + # otherwise equivalent output writers. Keep interior blank lines so a + # missing or shifted data row is still detected below. + while lines and not lines[-1].strip(): + lines.pop() except OSError: print("Error: can not find file %s" % file1) sys.exit(1) @@ -148,6 +155,16 @@ def IsComplex(x): return False return [realp,imagp] +def HasNonFiniteNumber(line): + for token in line.split(): + complex_value = IsComplex(token) + if complex_value: + if not math.isfinite(complex_value[0]) or not math.isfinite(complex_value[1]): + return True + elif IsFloat(token) and not math.isfinite(float(token)): + return True + return False + def ExitError(iline,line1,line2,jnumber=-1): if jnumber < 0: print('Compare Error: line %d\n %s:%s %s:%s'%(iline+1,file1,line1,file2,line2)) @@ -166,7 +183,9 @@ def ExitError(iline,line1,line2,jnumber=-1): lines2 = normalize_lines(lines2) for i in range(min(len(lines1),len(lines2))): - if lines1[i].strip() == lines2[i].strip():continue + if lines1[i].strip() == lines2[i].strip(): + if HasNonFiniteNumber(lines1[i]): ExitError(i,lines1[i],lines2[i]) + continue elif '' in [lines1[i].strip(),lines2[i].strip()]: ExitError(i,lines1[i],lines2[i]) elif len(lines1[i].split()) != len(lines2[i].split()): ExitError(i,lines1[i],lines2[i]) else: @@ -192,3 +211,9 @@ def ExitError(iline,line1,line2,jnumber=-1): if is_two_data_diff(float(sline1[j]), float(sline2[j]), epsilon, compareAbsoluteDiff): ExitError(i,sline1[j],sline2[j],j) elif sline1[j] != sline2[j]: ExitError(i,sline1[j],sline2[j],j) + + if len(lines1) != len(lines2): + i = min(len(lines1),len(lines2)) + line1 = lines1[i] if i < len(lines1) else '' + line2 = lines2[i] if i < len(lines2) else '' + ExitError(i,line1,line2) diff --git a/tests/integrate/validation_tools/catch_properties.sh b/tests/integrate/validation_tools/catch_properties.sh index 6add6375a6..1124442b7e 100755 --- a/tests/integrate/validation_tools/catch_properties.sh +++ b/tests/integrate/validation_tools/catch_properties.sh @@ -7,7 +7,24 @@ # one-time INPUT switch parsing) and then runs each property block below. PROPS_SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) source "$PROPS_SCRIPT_DIR/props_common.sh" -props_init "$1" +props_result_file=$1 +props_reference_mode=0 +case "$props_result_file" in + result.ref | */result.ref | result.ref.new | */result.ref.new) + props_reference_mode=1 + cleanup_failed_reference() { + reference_status=$? + trap - EXIT + if [ "$reference_status" -ne 0 ]; then + rm -f "$props_result_file" + fi + exit "$reference_status" + } + trap cleanup_failed_reference EXIT + set -e + ;; +esac +props_init "$props_result_file" source "$PROPS_SCRIPT_DIR/props_lr.sh" if run_lr_tracking_props; then @@ -87,11 +104,17 @@ run_ml_rpa_props # Before the split this block ran as a separate `bash` process without -e, # so a failing helper (get_sum_*.py, a missing deepks_desc.dat) left an # empty value for the threshold check instead of aborting the collection. -# Keep that behavior with a subshell that disables errexit. -( - set +e +# Keep that behavior for result.out. Reference generation instead inherits the +# entry point's errexit mode, so an early failure cannot be hidden by a later +# successful command in the collector. +if [ "$props_reference_mode" -eq 1 ]; then run_deepks_props -) +else + ( + set +e + run_deepks_props + ) || true +fi #-------------------------------------------- # basic collectors that run after deepks: symmetry diff --git a/tests/integrate/validation_tools/props_basic.sh b/tests/integrate/validation_tools/props_basic.sh index f28f1819fb..9e25aa9d6f 100644 --- a/tests/integrate/validation_tools/props_basic.sh +++ b/tests/integrate/validation_tools/props_basic.sh @@ -125,7 +125,7 @@ run_basic_props() { elif [ "$has_dos" = 2 ]; then local dos_dir=OUT.autotest if [ "$out_app_flag" = 2 ]; then dos_dir+=/DOS; fi - python3 "$PROPS_TOOLS_DIR/check_dos_npy.py" "$dos_dir" "${nspin:-1}" dos.ref >> "$props_result_file" || return 1 + python3 "$PROPS_TOOLS_DIR/check_dos_npy.py" "$dos_dir" "${nspin:-1}" dos.ref >>"$props_result_file" || return 1 fi #------------------------------- @@ -134,8 +134,7 @@ run_basic_props() { if ! test -z "$has_cond" && [ $has_cond == 1 ]; then onref=refOnsager.txt oncal=OUT.autotest/Onsager.txt - python3 $COMPARE_SCRIPT $onref $oncal 3 -com_type 0 - echo "CompareH_Failed $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH_Failed" "$onref" "$oncal" 3 0 0 rm -f je-je.txt Chebycoef fi diff --git a/tests/integrate/validation_tools/props_common.sh b/tests/integrate/validation_tools/props_common.sh index db735e1122..e7c28f9f67 100644 --- a/tests/integrate/validation_tools/props_common.sh +++ b/tests/integrate/validation_tools/props_common.sh @@ -57,6 +57,38 @@ sanitize_result_key() { echo "$1" | sed 's/[^A-Za-z0-9_]/_/g' } +record_compare_status() { + result_file=$1 + result_key=$2 + compare_status=$3 + + if [ "$compare_status" -ne 0 ]; then + case "$result_file" in + result.ref | */result.ref | result.ref.new | */result.ref.new) + echo "Error: refusing to record failed comparison $result_key in $result_file" >&2 + rm -f "$result_file" + exit "$compare_status" + ;; + esac + fi + echo "$result_key $compare_status" >>"$result_file" +} + +run_and_record_status() { + result_file=$1 + result_key=$2 + shift 2 + + # A failed check remains useful data in result.out, but it must never be + # accepted as the expected value while generating result.ref. + if "$@"; then + command_status=0 + else + command_status=$? + fi + record_compare_status "$result_file" "$result_key" "$command_status" +} + record_compare_result() { result_file=$1 result_key=$2 @@ -64,14 +96,28 @@ record_compare_result() { cal_file=$4 accuracy=${5:-8} use_abs=${6:-0} + compare_type=${7:-} if [ ! -f "$ref_file" ] || [ ! -f "$cal_file" ]; then - echo "$result_key 1" >>"$result_file" - return + record_compare_status "$result_file" "$result_key" 1 + return $? fi - python3 $COMPARE_SCRIPT "$ref_file" "$cal_file" "$accuracy" -abs "$use_abs" - echo "$result_key $?" >>"$result_file" + if [ -n "$compare_type" ]; then + if python3 "$COMPARE_SCRIPT" "$ref_file" "$cal_file" "$accuracy" \ + -abs "$use_abs" -com_type "$compare_type"; then + compare_status=0 + else + compare_status=$? + fi + else + if python3 "$COMPARE_SCRIPT" "$ref_file" "$cal_file" "$accuracy" -abs "$use_abs"; then + compare_status=0 + else + compare_status=$? + fi + fi + record_compare_status "$result_file" "$result_key" "$compare_status" } # props_init RESULT_FILE diff --git a/tests/integrate/validation_tools/props_cube.sh b/tests/integrate/validation_tools/props_cube.sh index 4ff82b16ec..dade03b0e8 100644 --- a/tests/integrate/validation_tools/props_cube.sh +++ b/tests/integrate/validation_tools/props_cube.sh @@ -22,8 +22,7 @@ run_cube_pot_props() { if ! test -z "$out_pot" && [ $out_pot == 1 ]; then pot1ref=pot.cube.ref pot1cal=OUT.autotest/pot.cube - python3 $COMPARE_SCRIPT $pot1ref $pot1cal 3 - echo "ComparePot1_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ComparePot1_pass" "$pot1ref" "$pot1cal" 3 fi #------------------------------- @@ -32,8 +31,7 @@ run_cube_pot_props() { if ! test -z "$out_pot" && [ $out_pot == 2 ]; then pot1ref=potes.cube.ref pot1cal=OUT.autotest/potes.cube - python3 $COMPARE_SCRIPT $pot1ref $pot1cal 8 - echo "ComparePot_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ComparePot_pass" "$pot1ref" "$pot1cal" 8 fi #------------------------------- @@ -43,8 +41,7 @@ run_cube_pot_props() { if ! test -z "$out_elf" && [ $out_elf == 1 ]; then elf1ref=elftot.cube.ref elf1cal=OUT.autotest/elftot.cube - python3 $COMPARE_SCRIPT $elf1ref $elf1cal 3 - echo "ComparePot1_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ComparePot1_pass" "$elf1ref" "$elf1cal" 3 fi } @@ -65,8 +62,8 @@ run_cube_props() { #--------------------------------------- if ! test -z "$has_scan" && [ $has_scan == "scan" ] && ! test -z "$out_chg" && [ $out_chg == 1 ]; then - python3 $COMPARE_SCRIPT tau.cube.ref OUT.autotest/tau.cube 8 - echo "tau.cube_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "tau.cube_pass" \ + "tau.cube.ref" "OUT.autotest/tau.cube" 8 fi #--------------------------------------- @@ -75,8 +72,8 @@ run_cube_props() { #--------------------------------------- if ! test -z "$has_ldos" && [ $has_ldos == 1 ]; then stm_bias=$(get_input_key_value "stm_bias" "OUT.autotest/INPUT.info") - python3 $COMPARE_SCRIPT ldos.cube.ref OUT.autotest/ldos_"$stm_bias"ev.cube 8 - echo "ldos.cube_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ldos.cube_pass" \ + "ldos.cube.ref" "OUT.autotest/ldos_${stm_bias}ev.cube" 8 fi #--------------------------------------- @@ -138,7 +135,7 @@ run_cube_props() { if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then wfc_cal=OUT.autotest/wf_nao.txt wfc_ref=wf_nao.txt.ref - else # multi-k point case + else # multi-k point case if ! test -z "$out_app_flag" && [ $out_app_flag == 0 ]; then # mode 0 overwrites one fixed file at every write, so the file holds # the last written step; the reference below records that step (3). @@ -165,7 +162,7 @@ run_cube_props() { printf "\n" } else {print $0} - }' OUT.autotest/"$input_file".txt > OUT.autotest/"$wfc_name"_mod.txt + }' OUT.autotest/"$input_file".txt >OUT.autotest/"$wfc_name"_mod.txt if [ $? -ne 0 ]; then echo "Error: failed to preprocess OUT.autotest/$input_file.txt" wfc_prep_ok=0 @@ -189,16 +186,19 @@ run_cube_props() { # downstream comparison. if [ "$wfc_prep_ok" -ne 1 ]; then wfc_pass=1 - elif ! sed '/^[[:space:]]*#/d' "$wfc_cal" >"$wfc_cal_nohdr" \ - || ! sed '/^[[:space:]]*#/d' "$wfc_ref" >"$wfc_ref_nohdr"; then + elif ! sed '/^[[:space:]]*#/d' "$wfc_cal" >"$wfc_cal_nohdr" || + ! sed '/^[[:space:]]*#/d' "$wfc_ref" >"$wfc_ref_nohdr"; then echo "Error: failed to strip comment lines from $wfc_cal or $wfc_ref" wfc_pass=1 else - python3 $COMPARE_SCRIPT "$wfc_cal_nohdr" "$wfc_ref_nohdr" 8 -abs 1 - wfc_pass=$? + if python3 "$COMPARE_SCRIPT" "$wfc_cal_nohdr" "$wfc_ref_nohdr" 8 -abs 1; then + wfc_pass=0 + else + wfc_pass=$? + fi fi rm -f "$wfc_cal_nohdr" "$wfc_ref_nohdr" - echo "Compare_wfc_lcao_pass $wfc_pass" >>$props_result_file + record_compare_status "$props_result_file" "Compare_wfc_lcao_pass" "$wfc_pass" fi } @@ -209,8 +209,8 @@ run_cube_tail_props() { # mulliken charge #-------------------------------------------- if ! test -z "$out_mul" && [ $out_mul == 1 ]; then - python3 $COMPARE_SCRIPT mulliken.txt.ref OUT.autotest/mulliken.txt 3 - echo "Compare_mulliken_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "Compare_mulliken_pass" \ + "mulliken.txt.ref" "OUT.autotest/mulliken.txt" 3 fi #-------------------------------------------- @@ -314,11 +314,8 @@ run_cube_tail_props() { if_separate_k=$(get_input_key_value "if_separate_k" "INPUT") if [ "$nspin" = "4" ] && { [ "$if_separate_k" = "1" ] || [ "$if_separate_k" = "true" ]; } && [ -n "$out_wfc_norm" ] && [ -n "$out_wfc_re_im" ] && [ -n "$out_pchg" ]; then - if python3 "$CUBE_TOOL" check-spinor OUT.autotest; then - echo "pw_spinor_cube_identity 0" >>"$props_result_file" - else - echo "pw_spinor_cube_identity 1" >>"$props_result_file" - fi + run_and_record_status "$props_result_file" "pw_spinor_cube_identity" \ + python3 "$CUBE_TOOL" check-spinor OUT.autotest fi } diff --git a/tests/integrate/validation_tools/props_deepks.sh b/tests/integrate/validation_tools/props_deepks.sh index ae3d8a69b1..257807d403 100644 --- a/tests/integrate/validation_tools/props_deepks.sh +++ b/tests/integrate/validation_tools/props_deepks.sh @@ -177,15 +177,11 @@ run_deepks_props() { fi # For deepks_v_delta < 0 - # CompareFile.py exits 1 when the files differ; capture the status in a - # named variable so it is recorded even when sourced under `bash -e`. if ! test -z "$deepks_v_delta" && [ $deepks_v_delta -lt 0 ]; then - hr_pass=0 - python3 $COMPARE_SCRIPT "deepks_hrtot.csr.ref" "OUT.autotest/deepks_hrtot.csr" 8 || hr_pass=$? - echo "deepks_hr_label_pass $hr_pass" >>$props_result_file - hrdelta_pass=0 - python3 $COMPARE_SCRIPT "deepks_hrdelta.csr.ref" "OUT.autotest/deepks_hrdelta.csr" 8 || hrdelta_pass=$? - echo "deepks_vdelta_r_pass $hrdelta_pass" >>$props_result_file + record_compare_result "$props_result_file" "deepks_hr_label_pass" \ + "deepks_hrtot.csr.ref" "OUT.autotest/deepks_hrtot.csr" 8 + record_compare_result "$props_result_file" "deepks_vdelta_r_pass" \ + "deepks_hrdelta.csr.ref" "OUT.autotest/deepks_hrdelta.csr" 8 # For deepks_v_delta = -1 if [ $deepks_v_delta -eq -1 ]; then process_npy "single" "abs" "vdrpre" "" "deepks_vdrp" "$props_result_file" diff --git a/tests/integrate/validation_tools/props_lr.sh b/tests/integrate/validation_tools/props_lr.sh index bd754fc71e..bea2c4005e 100644 --- a/tests/integrate/validation_tools/props_lr.sh +++ b/tests/integrate/validation_tools/props_lr.sh @@ -7,11 +7,8 @@ run_lr_tracking_props() { if [ "$is_lr" != 1 ] || [ ! -f state_tracking.ref ]; then return 1 fi - if python3 "$PROPS_SCRIPT_DIR/excited_state_check.py" "$running_path" state_tracking.ref; then - echo "CompareStateTracking_pass 0" >>"$props_result_file" - else - echo "CompareStateTracking_pass 1" >>"$props_result_file" - fi + run_and_record_status "$props_result_file" "CompareStateTracking_pass" \ + python3 "$PROPS_SCRIPT_DIR/excited_state_check.py" "$running_path" state_tracking.ref return 0 } @@ -34,11 +31,8 @@ run_lr_force_props() { force_tolerance=$configured_force_tolerance fi fi - if python3 "$PROPS_SCRIPT_DIR/lr_force_check.py" "$running_path" lr_force.ref "$force_tolerance"; then - echo "CompareLRForce_pass 0" >>"$props_result_file" - else - echo "CompareLRForce_pass 1" >>"$props_result_file" - fi + run_and_record_status "$props_result_file" "CompareLRForce_pass" \ + python3 "$PROPS_SCRIPT_DIR/lr_force_check.py" "$running_path" lr_force.ref "$force_tolerance" fi } diff --git a/tests/integrate/validation_tools/props_mat.sh b/tests/integrate/validation_tools/props_mat.sh index 7f04acd9b1..e3b8e8bf91 100644 --- a/tests/integrate/validation_tools/props_mat.sh +++ b/tests/integrate/validation_tools/props_mat.sh @@ -29,12 +29,12 @@ compare_hr_csr() { echo "Error: can not find file $ref or $cal" return 1 fi - python3 $COMPARE_SCRIPT <(sed "$strip" "$ref") <(sed "$strip" "$cal") 8 || return 1 + python3 "$COMPARE_SCRIPT" <(sed "$strip" "$ref") <(sed "$strip" "$cal") 8 || return 1 if [ "$(sed -n "$pick" "$ref" | wc -l)" -ne "$(sed -n "$pick" "$cal" | wc -l)" ]; then echo "Error: E_Fermi annotation count differs between $ref and $cal" return 1 fi - python3 $COMPARE_SCRIPT <(sed -n "$pick" "$ref") <(sed -n "$pick" "$cal") 3 + python3 "$COMPARE_SCRIPT" <(sed -n "$pick" "$ref") <(sed -n "$pick" "$cal") 3 } # Band-energy-term files start with comment lines (version, timestamp, ionic @@ -59,8 +59,7 @@ run_mat_dm1_props() { if ! test -z "$out_dm1" && [ $out_dm1 == 1 ]; then dm1ref=dmr_nao.csr.ref dm1cal=OUT.autotest/dmr_nao.csr - python3 $COMPARE_SCRIPT $dm1ref $dm1cal 8 - echo "CompareDM1_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareDM1_pass" "$dm1ref" "$dm1cal" 8 fi } @@ -74,8 +73,7 @@ run_mat_props() { if [ "$calculation" == "get_s" ]; then sref=sr_nao.csr.ref scal=OUT.autotest/sr_nao.csr - python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareS_pass" "$sref" "$scal" 8 fi #------------------------------- @@ -85,8 +83,8 @@ run_mat_props() { if ! test -z "$out_pband" && [ $out_pband == 1 ]; then orbref=refNaoTxt orbcal=OUT.autotest/nao.txt - python3 $COMPARE_SCRIPT $orbref $orbcal 8 - echo "CompareOrb_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareOrb_pass" \ + python3 $COMPARE_SCRIPT $orbref $orbcal 8 fi #------------------------------- @@ -102,14 +100,13 @@ run_mat_props() { eigcal=OUT.autotest/diamond.eig # AMN is covariant under the band gauge (A -> U^dagger A), so compare # the gauge-invariant Gram matrix A^dagger A instead of the raw elements. - python3 $COMPARE_AMN_SCRIPT $amnref $amncal - echo "CompareAMN_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareAMN_pass" \ + python3 "$COMPARE_AMN_SCRIPT" "$amnref" "$amncal" # MMN is covariant as M(k,b) -> U_k^dagger M(k,b) U_{k+b}; CPU and GPU # differ by per-band phases, under which |M_mn| is invariant. - python3 $COMPARE_MMN_SCRIPT $mmnref $mmncal - echo "CompareMMN_pass $?" >>$props_result_file - python3 $COMPARE_SCRIPT $eigref $eigcal 8 - echo "CompareEIG_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareMMN_pass" \ + python3 "$COMPARE_MMN_SCRIPT" "$mmnref" "$mmncal" + record_compare_result "$props_result_file" "CompareEIG_pass" "$eigref" "$eigcal" 8 fi #------------------------------- @@ -117,7 +114,7 @@ run_mat_props() { # echo total_dos # echo $has_band #------------------------------- - if ! test -z "$has_band" && [ $has_band == 1 ]; then + if ! test -z "$has_band" && [ $has_band == 1 ]; then bandref=band.txt.ref bandcal=OUT.autotest/band.txt # Every ionic step in band.txt is preceded by a provenance comment block @@ -127,10 +124,10 @@ run_mat_props() { # substitution would hand CompareFile.py an empty stream and pass silently. if ! test -f "$bandref" || ! test -f "$bandcal"; then echo "Error: can not find file $bandref or $bandcal" - echo "CompareBand_pass 1" >>$props_result_file + record_compare_status "$props_result_file" "CompareBand_pass" 1 else - python3 $COMPARE_SCRIPT <(sed '/^[[:space:]]*#/d' "$bandref") <(sed '/^[[:space:]]*#/d' "$bandcal") 8 - echo "CompareBand_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareBand_pass" \ + python3 $COMPARE_SCRIPT <(sed '/^[[:space:]]*#/d' "$bandref") <(sed '/^[[:space:]]*#/d' "$bandcal") 8 fi fi @@ -151,14 +148,11 @@ run_mat_props() { sref=s_nao.txt.ref scal=OUT.autotest/s_nao.txt # Compare Hamiltonian matrix for spin 1 - python3 $COMPARE_SCRIPT $h1ref $h1cal 6 - echo "CompareH1_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH1_pass" "$h1ref" "$h1cal" 6 # Compare Hamiltonian matrix for spin 2 - python3 $COMPARE_SCRIPT $h2ref $h2cal 6 - echo "CompareH2_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH2_pass" "$h2ref" "$h2cal" 6 # Compare overlap matrix - python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareS_pass" "$sref" "$scal" 8 elif ! test -z "$nspin" && [ $nspin == 4 ]; then # nspin=4 : do nothing, only matching condition without any operation true @@ -169,11 +163,9 @@ run_mat_props() { sref=s_nao.txt.ref scal=OUT.autotest/s_nao.txt # Compare Hamiltonian matrix - python3 $COMPARE_SCRIPT $href $hcal 6 - echo "CompareH_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH_pass" "$href" "$hcal" 6 # Compare overlap matrix - python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareS_pass" "$sref" "$scal" 8 fi else # ========== Multiple k-points calculation ========== @@ -186,14 +178,11 @@ run_mat_props() { sref=sk2_nao.txt.ref scal=OUT.autotest/sk2_nao.txt # Compare Hamiltonian matrix for spin 1 - python3 $COMPARE_SCRIPT $h1ref $h1cal 6 - echo "CompareH1_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH1_pass" "$h1ref" "$h1cal" 6 # Compare Hamiltonian matrix for spin 2 - python3 $COMPARE_SCRIPT $h2ref $h2cal 6 - echo "CompareH2_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH2_pass" "$h2ref" "$h2cal" 6 # Compare overlap matrix - python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareS_pass" "$sref" "$scal" 8 elif ! test -z "$nspin" && [ $nspin == 4 ]; then # nspin=4 : do nothing, only matching condition without any operation true @@ -204,27 +193,25 @@ run_mat_props() { sref=sk2_nao.txt.ref scal=OUT.autotest/sk2_nao.txt # Compare Hamiltonian matrix - python3 $COMPARE_SCRIPT $href $hcal 6 - echo "CompareH_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareH_pass" "$href" "$hcal" 6 # Compare overlap matrix - python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareS_pass" "$sref" "$scal" 8 fi fi elif ! test -z "$has_hs" && [ $has_hs == 2 ]; then HSK_BINARY_COMPARE="$PROPS_TOOLS_DIR/compare_hsk_binary.py" if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then HSK_TEXT_REFERENCE_DIR="../scf_out_hk" - python3 $HSK_BINARY_COMPARE OUT.autotest/hk_nao.dat "$HSK_TEXT_REFERENCE_DIR/h_nao.txt.ref" real 3 - echo "CompareH_pass $?" >>$props_result_file - python3 $HSK_BINARY_COMPARE OUT.autotest/sk_nao.dat "$HSK_TEXT_REFERENCE_DIR/s_nao.txt.ref" real 3 - echo "CompareS_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareH_pass" python3 "$HSK_BINARY_COMPARE" \ + OUT.autotest/hk_nao.dat "$HSK_TEXT_REFERENCE_DIR/h_nao.txt.ref" real 3 + run_and_record_status "$props_result_file" "CompareS_pass" python3 "$HSK_BINARY_COMPARE" \ + OUT.autotest/sk_nao.dat "$HSK_TEXT_REFERENCE_DIR/s_nao.txt.ref" real 3 else HSK_TEXT_REFERENCE_DIR="../scf_out_hsk" - python3 $HSK_BINARY_COMPARE OUT.autotest/hk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/hk2_nao.txt.ref" complex 3 - echo "CompareH_pass $?" >>$props_result_file - python3 $HSK_BINARY_COMPARE OUT.autotest/sk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/sk2_nao.txt.ref" complex 3 - echo "CompareS_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareH_pass" python3 "$HSK_BINARY_COMPARE" \ + OUT.autotest/hk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/hk2_nao.txt.ref" complex 3 + run_and_record_status "$props_result_file" "CompareS_pass" python3 "$HSK_BINARY_COMPARE" \ + OUT.autotest/sk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/sk2_nao.txt.ref" complex 3 fi fi @@ -241,10 +228,10 @@ run_mat_props() { fi oeref=eband_vxc.ref oecal=OUT.autotest/eband_vxc.txt - python3 $COMPARE_SCRIPT $xcref $xccal 4 - echo "CompareVXC_pass $?" >>$props_result_file - compare_eband_energy $oeref $oecal 5 - echo "CompareOrbXC_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareVXC_pass" \ + python3 $COMPARE_SCRIPT $xcref $xccal 4 + run_and_record_status "$props_result_file" "CompareOrbXC_pass" \ + compare_eband_energy $oeref $oecal 5 fi #-------------------------------- @@ -253,22 +240,22 @@ run_mat_props() { if ! test -z "$has_xc2" && [ $has_xc2 == 1 ]; then xc2ref=vxcrs1_nao.csr.ref xc2cal=OUT.autotest/vxcrs1_nao.csr - python3 $COMPARE_SCRIPT $xc2ref $xc2cal 8 - echo "CompareVXC_R_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareVXC_R_pass" \ + python3 $COMPARE_SCRIPT $xc2ref $xc2cal 8 fi #-------------------------------- # separate terms in band enegy #-------------------------------- if ! test -z "$has_eband_separate" && [ $has_eband_separate == 1 ]; then - compare_eband_energy eband_kin.ref OUT.autotest/eband_kin.txt - echo "CompareOrbKinetic_pass $?" >>$props_result_file - compare_eband_energy eband_vl.ref OUT.autotest/eband_vl.txt - echo "CompareOrbVL_pass $?" >>$props_result_file - compare_eband_energy eband_vnl.ref OUT.autotest/eband_vnl.txt - echo "CompareOrbVNL_pass $?" >>$props_result_file - compare_eband_energy eband_hart.ref OUT.autotest/eband_hart.txt - echo "CompareOrbVHartree_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareOrbKinetic_pass" \ + compare_eband_energy eband_kin.ref OUT.autotest/eband_kin.txt + run_and_record_status "$props_result_file" "CompareOrbVL_pass" \ + compare_eband_energy eband_vl.ref OUT.autotest/eband_vl.txt + run_and_record_status "$props_result_file" "CompareOrbVNL_pass" \ + compare_eband_energy eband_vnl.ref OUT.autotest/eband_vnl.txt + run_and_record_status "$props_result_file" "CompareOrbVHartree_pass" \ + compare_eband_energy eband_hart.ref OUT.autotest/eband_hart.txt fi #----------------------------------- @@ -276,44 +263,41 @@ run_mat_props() { #----------------------------------- #echo $has_hs2 if ! test -z "$has_hs2" && [ $has_hs2 == 1 ]; then - compare_hr_csr hrs1_nao.csr.ref OUT.autotest/hrs1_nao.csr - echo "CompareHR_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareHR_pass" \ + compare_hr_csr hrs1_nao.csr.ref OUT.autotest/hrs1_nao.csr if ! test -z "$nspin" && [ "$nspin" -eq 2 ]; then - compare_hr_csr hrs2_nao.csr.ref OUT.autotest/hrs2_nao.csr - echo "CompareHR2_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareHR2_pass" \ + compare_hr_csr hrs2_nao.csr.ref OUT.autotest/hrs2_nao.csr fi - python3 $COMPARE_SCRIPT sr_nao.csr.ref OUT.autotest/sr_nao.csr 8 - echo "CompareSR_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareSR_pass" \ + "sr_nao.csr.ref" "OUT.autotest/sr_nao.csr" 8 elif ! test -z "$has_hs2" && [ "$has_hs2" == 2 ]; then HSR_BINARY_COMPARE="$PROPS_TOOLS_DIR/compare_hsr_binary.py" - python3 $HSR_BINARY_COMPARE OUT.autotest/hrs1_nao.dat hrs1_nao.csr.ref real 4 - echo "CompareHR_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareHR_pass" python3 "$HSR_BINARY_COMPARE" \ + OUT.autotest/hrs1_nao.dat hrs1_nao.csr.ref real 4 if ! test -z "$nspin" && [ "$nspin" -eq 2 ]; then - python3 $HSR_BINARY_COMPARE OUT.autotest/hrs2_nao.dat hrs2_nao.csr.ref real 4 - echo "CompareHR2_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareHR2_pass" python3 "$HSR_BINARY_COMPARE" \ + OUT.autotest/hrs2_nao.dat hrs2_nao.csr.ref real 4 fi - python3 $HSR_BINARY_COMPARE OUT.autotest/sr_nao.dat sr_nao.csr.ref real 4 - echo "CompareSR_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "CompareSR_pass" python3 "$HSR_BINARY_COMPARE" \ + OUT.autotest/sr_nao.dat sr_nao.csr.ref real 4 fi #----------------------------------- # H(R), S(R), and DM(R) matrices in NPZ format #----------------------------------- if { ! test -z "$out_hsr" && [ "$out_hsr" == 3 ]; } || { ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; }; then - test -f OUT.autotest/sr_nao.npz - echo "OutputSRNPZ_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "OutputSRNPZ_pass" test -f OUT.autotest/sr_nao.npz fi if { ! test -z "$out_hr_npz" && [ "$out_hr_npz" == 1 ]; } || { ! test -z "$out_hsr" && [ "$out_hsr" == 3 ]; } || { ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; }; then - test -f OUT.autotest/hrs1_nao.npz - echo "OutputHRNPZ_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "OutputHRNPZ_pass" test -f OUT.autotest/hrs1_nao.npz fi if ! test -z "$out_dm_npz" && [ "$out_dm_npz" == 1 ]; then - test -f OUT.autotest/output_DM0.npz - echo "OutputDMNPZ_pass $?" >>$props_result_file + run_and_record_status "$props_result_file" "OutputDMNPZ_pass" test -f OUT.autotest/output_DM0.npz fi #----------------------------------- @@ -321,10 +305,13 @@ run_mat_props() { #----------------------------------- #echo $has_mat_r if ! test -z "$has_mat_r" && [ $has_mat_r == 1 ]; then + local position_status=0 for axis in x y z; do - python3 $COMPARE_SCRIPT "rr${axis}_nao.csr.ref" "OUT.autotest/rr${axis}_nao.csr" 8 || return 1 + if ! python3 "$COMPARE_SCRIPT" "rr${axis}_nao.csr.ref" "OUT.autotest/rr${axis}_nao.csr" 8; then + position_status=1 + fi done - echo "ComparerR_pass $?" >>$props_result_file + record_compare_status "$props_result_file" "ComparerR_pass" "$position_status" fi #----------------------------------- @@ -332,8 +319,8 @@ run_mat_props() { #----------------------------------- #echo $has_mat_t if ! test -z "$has_mat_t" && [ $has_mat_t == 1 ]; then - python3 $COMPARE_SCRIPT tr_nao.csr.ref OUT.autotest/tr_nao.csr 8 - echo "ComparerTR_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ComparerTR_pass" \ + "tr_nao.csr.ref" "OUT.autotest/tr_nao.csr" 8 fi #----------------------------------- @@ -341,8 +328,8 @@ run_mat_props() { #----------------------------------- #echo $has_mat_syns if ! test -z "$has_mat_syns" && [ $has_mat_syns == 1 ]; then - python3 $COMPARE_SCRIPT syns_nao.csr.ref OUT.autotest/syns_nao.csr 8 - echo "CompareSYNS_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "CompareSYNS_pass" \ + "syns_nao.csr.ref" "OUT.autotest/syns_nao.csr" 8 fi #----------------------------------- @@ -350,12 +337,12 @@ run_mat_props() { #----------------------------------- #echo $has_mat_dh if ! test -z "$has_mat_dh" && [ $has_mat_dh == 1 ] && [ $gamma_only != 1 ]; then - python3 $COMPARE_SCRIPT dhrxs1_nao.csr.ref OUT.autotest/dhrxs1_nao.csr 8 - echo "ComparerdHRx_pass $?" >>$props_result_file - python3 $COMPARE_SCRIPT dhrys1_nao.csr.ref OUT.autotest/dhrys1_nao.csr 8 - echo "ComparerdHRy_pass $?" >>$props_result_file - python3 $COMPARE_SCRIPT dhrzs1_nao.csr.ref OUT.autotest/dhrzs1_nao.csr 8 - echo "ComparerdHRz_pass $?" >>$props_result_file + record_compare_result "$props_result_file" "ComparerdHRx_pass" \ + "dhrxs1_nao.csr.ref" "OUT.autotest/dhrxs1_nao.csr" 8 + record_compare_result "$props_result_file" "ComparerdHRy_pass" \ + "dhrys1_nao.csr.ref" "OUT.autotest/dhrys1_nao.csr" 8 + record_compare_result "$props_result_file" "ComparerdHRz_pass" \ + "dhrzs1_nao.csr.ref" "OUT.autotest/dhrzs1_nao.csr" 8 fi #----------------------------------- @@ -382,8 +369,7 @@ run_mat_dm_props() { if ! test -z "$out_dm" && [ $out_dm == 1 ]; then dmfile=OUT.autotest/dm_nao.txt dmref=dm_nao.txt.ref - python3 $COMPARE_SCRIPT $dmref $dmfile 5 - echo "DM_different $?" >>$props_result_file + record_compare_result "$props_result_file" "DM_different" "$dmref" "$dmfile" 5 fi } diff --git a/tests/integrate/validation_tools/props_tddft.sh b/tests/integrate/validation_tools/props_tddft.sh index 9fff21f490..b4b15bf0d0 100644 --- a/tests/integrate/validation_tools/props_tddft.sh +++ b/tests/integrate/validation_tools/props_tddft.sh @@ -42,11 +42,14 @@ run_tddft_props() { reference_rows=$(awk 'NF { count++ } END { print count+0 }' "$current1ref") current_rows=$(awk 'NF { count++ } END { print count+0 }' "$current1cal") if [ "$reference_rows" -gt 0 ] && [ "$current_rows" -ge "$reference_rows" ]; then - python3 "$COMPARE_SCRIPT" "$current1ref" "$current1cal" -tol "$current_tol" - current_status=$? + if python3 "$COMPARE_SCRIPT" "$current1ref" "$current1cal" -tol "$current_tol"; then + current_status=0 + else + current_status=$? + fi fi fi - echo "CompareCurrent_pass $current_status" >>$props_result_file + record_compare_status "$props_result_file" "CompareCurrent_pass" "$current_status" fi #-------------------------------------------- @@ -55,7 +58,7 @@ run_tddft_props() { if ! test -z "$out_efield" && [ "$out_efield" == 1 ]; then efield_refs=(efield_*.txt.ref) if [ ! -e "${efield_refs[0]}" ]; then - echo "CompareEfieldReference_pass 1" >>$props_result_file + record_compare_status "$props_result_file" "CompareEfieldReference_pass" 1 else for efield_ref in "${efield_refs[@]}"; do efield_name=${efield_ref%.ref} diff --git a/tests/integrate/validation_tools/run_check.sh b/tests/integrate/validation_tools/run_check.sh index 5ad42e9064..604e92ce2a 100755 --- a/tests/integrate/validation_tools/run_check.sh +++ b/tests/integrate/validation_tools/run_check.sh @@ -72,15 +72,21 @@ test -d OUT.autotest || exit 0 #if any input parameters for this script, just generate reference file. #---------------------------------------------------------------------- if test -z $1; then - "$CATCH_SCRIPT" result.out || exit 1 + if ! bash -e "$CATCH_SCRIPT" result.out; then + echo "Failed to collect validation results." >&2 + exit 1 + fi check_out result.out elif [ $1 == "debug" ]; then # Single_job.sh debug copies validation_tools/ into the case directory; # use that copy so local edits to the collectors take effect. - ./validation_tools/catch_properties.sh result.out || exit 1 + if ! bash -e ./validation_tools/catch_properties.sh result.out; then + echo "Failed to collect validation results." >&2 + exit 1 + fi check_out result.out else - if ! "$CATCH_SCRIPT" result.ref.new; then + if ! bash -e "$CATCH_SCRIPT" result.ref.new; then rm -f result.ref.new exit 1 fi diff --git a/tests/integrate/validation_tools/test_catch_properties.sh b/tests/integrate/validation_tools/test_catch_properties.sh new file mode 100644 index 0000000000..92126aceb0 --- /dev/null +++ b/tests/integrate/validation_tools/test_catch_properties.sh @@ -0,0 +1,596 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +integrate_dir=$(realpath "${script_dir}/..") +test_root=$(mktemp -d "${TMPDIR:-/tmp}/catch-properties-test.XXXXXX") +trap 'rm -rf "${test_root}"' EXIT + +case_dir="${test_root}/tests/01_PW/test_case" +mkdir -p "${case_dir}/OUT.autotest" +ln -s "${integrate_dir}" "${test_root}/tests/integrate" + +cat >"${case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +out_band 1 +EOF + +cat >"${case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${case_dir}/sr_nao.csr.ref" +touch "${case_dir}/OUT.autotest/sr_nao.csr" + +( + cd "${case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out +) + +grep -qx 'CompareBand_pass 1' "${case_dir}/result.out" + +if ( + cd "${case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a failed comparison while generating result.ref" >&2 + exit 1 +fi + +if [ -e "${case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial result.ref after comparison failure" >&2 + exit 1 +fi + +npz_case_dir="${test_root}/tests/01_PW/npz_case" +mkdir -p "${npz_case_dir}/OUT.autotest" + +cat >"${npz_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +out_hsr_npz 1 +EOF + +cat >"${npz_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${npz_case_dir}/sr_nao.csr.ref" +touch "${npz_case_dir}/OUT.autotest/sr_nao.csr" + +( + cd "${npz_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out +) + +grep -qx 'OutputSRNPZ_pass 1' "${npz_case_dir}/result.out" +grep -qx 'OutputHRNPZ_pass 1' "${npz_case_dir}/result.out" + +if ( + cd "${npz_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a missing NPZ file while generating result.ref" >&2 + exit 1 +fi + +if [ -e "${npz_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial NPZ result.ref after generation failure" >&2 + exit 1 +fi + +hsk_case_dir="${test_root}/tests/01_PW/hsk_case" +mkdir -p "${hsk_case_dir}/OUT.autotest" + +cat >"${hsk_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +out_hsk 2 +gamma_only 1 +EOF + +cat >"${hsk_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${hsk_case_dir}/sr_nao.csr.ref" +touch "${hsk_case_dir}/OUT.autotest/sr_nao.csr" + +( + cd "${hsk_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out +) + +grep -qx 'CompareH_pass 1' "${hsk_case_dir}/result.out" +grep -qx 'CompareS_pass 1' "${hsk_case_dir}/result.out" + +if ( + cd "${hsk_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a failed HSK comparison while generating result.ref" >&2 + exit 1 +fi + +if [ -e "${hsk_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial HSK result.ref after generation failure" >&2 + exit 1 +fi + +# Keep upstream's renamed VXC files while retaining failure propagation in +# both Gamma-only and multi-k collectors. No legacy vxc_out.* files exist. +for gamma in 0 1; do + vxc_case_dir="${test_root}/tests/01_PW/vxc_case_${gamma}" + mkdir -p "${vxc_case_dir}/OUT.autotest" + printf 'INPUT_PARAMETERS\ncalculation get_s\nout_mat_xc 1\ngamma_only %s\n' \ + "${gamma}" >"${vxc_case_dir}/INPUT" + printf 'Driver atomic_world 0.01\n' >"${vxc_case_dir}/OUT.autotest/running_get_s.log" + touch "${vxc_case_dir}/sr_nao.csr.ref" "${vxc_case_dir}/OUT.autotest/sr_nao.csr" + if [ "${gamma}" -eq 1 ]; then + vxc_name=vxcmo_nao.txt + else + vxc_name=vxcmok2_nao.txt + fi + printf 'value 1\n' >"${vxc_case_dir}/${vxc_name}.ref" + printf 'value 1\n' >"${vxc_case_dir}/OUT.autotest/${vxc_name}" + printf 'value 1\n' >"${vxc_case_dir}/eband_vxc.ref" + printf 'value 1\n' >"${vxc_case_dir}/OUT.autotest/eband_vxc.txt" + ( + cd "${vxc_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref + ) + grep -qx 'CompareVXC_pass 0' "${vxc_case_dir}/result.ref" + grep -qx 'CompareOrbXC_pass 0' "${vxc_case_dir}/result.ref" + + for failure in different missing; do + if [ "${failure}" = different ]; then + printf 'value 2\n' >"${vxc_case_dir}/OUT.autotest/eband_vxc.txt" + else + rm "${vxc_case_dir}/OUT.autotest/eband_vxc.txt" + fi + ( + cd "${vxc_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out + ) + grep -qx 'CompareVXC_pass 0' "${vxc_case_dir}/result.out" + grep -qx 'CompareOrbXC_pass 1' "${vxc_case_dir}/result.out" + if ( + cd "${vxc_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref + ); then + echo "catch_properties.sh accepted ${failure} VXC output in result.ref" >&2 + exit 1 + fi + if [ -e "${vxc_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial VXC result.ref" >&2 + exit 1 + fi + done +done + +# Upstream's Wannier validators accept the band gauge without rewriting the +# output files; all three statuses must still reject invalid references. +wannier_case_dir="${test_root}/tests/01_PW/wannier_case" +mkdir -p "${wannier_case_dir}/OUT.autotest" +printf 'INPUT_PARAMETERS\ncalculation get_s\ntowannier90 1\n' >"${wannier_case_dir}/INPUT" +printf 'Driver atomic_world 0.01\n' >"${wannier_case_dir}/OUT.autotest/running_get_s.log" +touch "${wannier_case_dir}/sr_nao.csr.ref" "${wannier_case_dir}/OUT.autotest/sr_nao.csr" +printf '2 1 1\n1 1 1 1 0\n2 1 1 0 0\n' >"${wannier_case_dir}/diamond.amn" +printf 'Created on test date\n2 1 1\n1 1 1 0 0\n2 1 1 0 1\n' >"${wannier_case_dir}/OUT.autotest/diamond.amn" +printf '1 1 1\n1 1 0 0 0\n1 0\n' >"${wannier_case_dir}/diamond.mmn" +printf 'Created on test date\n1 1 1\n1 1 0 0 0\n0 1\n' >"${wannier_case_dir}/OUT.autotest/diamond.mmn" +printf '1 1 0.5\n' >"${wannier_case_dir}/diamond.eig" +cp "${wannier_case_dir}/diamond.eig" "${wannier_case_dir}/OUT.autotest/diamond.eig" +( + cd "${wannier_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref +) +for property in AMN MMN EIG; do + grep -qx "Compare${property}_pass 0" "${wannier_case_dir}/result.ref" +done +grep -qx 'Created on test date' "${wannier_case_dir}/OUT.autotest/diamond.amn" +grep -qx 'Created on test date' "${wannier_case_dir}/OUT.autotest/diamond.mmn" +for extension in amn mmn eig; do + property=${extension^^} + output_file="${wannier_case_dir}/OUT.autotest/diamond.${extension}" + cp "${output_file}" "${test_root}/valid.${extension}" + for failure in malformed missing; do + if [ "${failure}" = malformed ]; then + printf 'invalid Wannier output\n' >"${output_file}" + else + rm "${output_file}" + fi + ( + cd "${wannier_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out + ) + grep -qx "Compare${property}_pass 1" "${wannier_case_dir}/result.out" + if ( + cd "${wannier_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref + ); then + echo "catch_properties.sh accepted ${failure} ${property} output in result.ref" >&2 + exit 1 + fi + test ! -e "${wannier_case_dir}/result.ref" + done + cp "${test_root}/valid.${extension}" "${output_file}" +done + +# Both upstream LR routes keep failed checks in result.out, but reference +# generation must fail and remove even the early-return tracking result. +for lr_mode in force tracking; do + lr_case_dir="${test_root}/tests/01_PW/lr_${lr_mode}" + mkdir -p "${lr_case_dir}/OUT.autotest" + printf 'INPUT_PARAMETERS\ncalculation get_s\nesolver_type lr\ncal_force 1\n' >"${lr_case_dir}/INPUT" + printf 'Driver atomic_world 0.01\n' >"${lr_case_dir}/OUT.autotest/running_get_s.log" + touch "${lr_case_dir}/sr_nao.csr.ref" "${lr_case_dir}/OUT.autotest/sr_nao.csr" + if [ "${lr_mode}" = force ]; then + lr_property=CompareLRForce_pass + printf 'singlet 0 0 1 -2 3\n' >"${lr_case_dir}/lr_force.ref" + cat >>"${lr_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Start to calculate excited-state force of singlet +Forces (-gradients) of each excited state: (eV/Angstrom) + state atom x y z + 0 0 force 1 -2 3 +DONE +EOF + else + lr_property=CompareStateTracking_pass + printf 'out_band 1\n' >>"${lr_case_dir}/INPUT" + printf '{"steps": 1}\n' >"${lr_case_dir}/state_tracking.ref" + cat >>"${lr_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +EXCITED-STATE RELAX step 0: E_gs = -10 eV, Omega = 1 eV, E_exc = -9 eV | |F_gs|max = 0.1, |F_Omega|max = 0.2 eV/Angstrom +EOF + fi + ( + cd "${lr_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref + ) + grep -qx "${lr_property} 0" "${lr_case_dir}/result.ref" + if [ "${lr_mode}" = tracking ]; then + test "$(wc -l <"${lr_case_dir}/result.ref")" -eq 1 + fi + printf 'Driver atomic_world 0.01\n' >"${lr_case_dir}/OUT.autotest/running_get_s.log" + ( + cd "${lr_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out + ) + grep -qx "${lr_property} 1" "${lr_case_dir}/result.out" + if ( + cd "${lr_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref + ); then + echo "catch_properties.sh accepted a failed LR ${lr_mode} check in result.ref" >&2 + exit 1 + fi + test ! -e "${lr_case_dir}/result.ref" +done + +deepks_case_dir="${test_root}/tests/01_PW/deepks_case" +mkdir -p "${deepks_case_dir}/OUT.autotest" + +cat >"${deepks_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +deepks_out_labels 1 +deepks_v_delta -1 +EOF + +cat >"${deepks_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${deepks_case_dir}/sr_nao.csr.ref" +touch "${deepks_case_dir}/OUT.autotest/sr_nao.csr" +printf 'value 1\n' >"${deepks_case_dir}/deepks_hrtot.csr.ref" +printf 'value 2\n' >"${deepks_case_dir}/OUT.autotest/deepks_hrtot.csr" +printf 'value 1\n' >"${deepks_case_dir}/deepks_hrdelta.csr.ref" +printf 'value 1\n' >"${deepks_case_dir}/OUT.autotest/deepks_hrdelta.csr" + +( + cd "${deepks_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out +) + +grep -qx 'deepks_hr_label_pass 1' "${deepks_case_dir}/result.out" +grep -qx 'deepks_vdelta_r_pass 0' "${deepks_case_dir}/result.out" + +if ( + cd "${deepks_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a failed DeePKS comparison while generating result.ref" >&2 + exit 1 +fi + +if [ -e "${deepks_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial DeePKS result.ref after generation failure" >&2 + exit 1 +fi + +deepks_missing_case_dir="${test_root}/tests/01_PW/deepks_missing_case" +mkdir -p "${deepks_missing_case_dir}/OUT.autotest" + +cat >"${deepks_missing_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +deepks_scf 1 +EOF + +cat >"${deepks_missing_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${deepks_missing_case_dir}/sr_nao.csr.ref" +touch "${deepks_missing_case_dir}/OUT.autotest/sr_nao.csr" + +( + cd "${deepks_missing_case_dir}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out +) + +grep -qx 'deepks_desc 0.0' "${deepks_missing_case_dir}/result.out" + +if ( + cd "${deepks_missing_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a missing DeePKS descriptor while generating result.ref" >&2 + exit 1 +fi + +if [ -e "${deepks_missing_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial result.ref after a missing DeePKS descriptor" >&2 + exit 1 +fi + +ml_case_dir="${test_root}/tests/01_PW/ml_case" +mkdir -p "${ml_case_dir}/OUT.autotest/MLKEDF_Descriptors" + +cat >"${ml_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +EOF + +cat >"${ml_case_dir}/OUT.autotest/running_get_s.log" <<'EOF' +Driver atomic_world 0.01 +EOF + +touch "${ml_case_dir}/sr_nao.csr.ref" +touch "${ml_case_dir}/OUT.autotest/sr_nao.csr" +printf 'not a NumPy file\n' >"${ml_case_dir}/OUT.autotest/MLKEDF_Descriptors/broken.npy" + +if ( + cd "${ml_case_dir}" + bash ../../integrate/validation_tools/catch_properties.sh result.ref +); then + echo "catch_properties.sh accepted a failed ML descriptor collector" >&2 + exit 1 +fi + +if [ -e "${ml_case_dir}/result.ref" ]; then + echo "catch_properties.sh left a partial result.ref after an ML collector failure" >&2 + exit 1 +fi + +cat >"${test_root}/fake_abacus" <<'EOF' +#!/usr/bin/env bash +mkdir -p OUT.autotest +cat > OUT.autotest/running_get_s.log <<'INNER_EOF' +Driver atomic_world 0.01 +INNER_EOF +cat > OUT.autotest/running_scf.log <<'INNER_EOF' +Driver atomic_world 0.01 +INNER_EOF +cat > OUT.autotest/running_get_wf.log <<'INNER_EOF' +Driver atomic_world 0.01 +INNER_EOF +touch OUT.autotest/sr_nao.csr +EOF +chmod +x "${test_root}/fake_abacus" + +mkdir -p "${test_root}/fake_bin" +cat >"${test_root}/fake_bin/mpirun" <<'EOF' +#!/usr/bin/env bash +if [ "$1" = "-np" ]; then + shift 2 +fi +exec "$@" +EOF +chmod +x "${test_root}/fake_bin/mpirun" + +# A collector can fail after writing a valid prefix of result.out. run_check.sh +# must propagate that failure before check_out can accept the prefix. Exercise +# both the ordinary path and Single_job.sh's debug path, which uses the copied +# validation_tools directory. +for run_check_mode in normal debug; do + run_check_case_dir="${test_root}/tests/01_PW/run_check_${run_check_mode}" + mkdir -p "${run_check_case_dir}/OUT.autotest/MLKEDF_Descriptors" + printf 'not a NumPy file\n' >"${run_check_case_dir}/OUT.autotest/MLKEDF_Descriptors/broken.npy" + cat >"${run_check_case_dir}/INPUT" <<'EOF' +INPUT_PARAMETERS +calculation get_s +EOF + printf 'Driver atomic_world 0.01\n' >"${run_check_case_dir}/OUT.autotest/running_get_s.log" + touch "${run_check_case_dir}/sr_nao.csr.ref" "${run_check_case_dir}/OUT.autotest/sr_nao.csr" + printf 'CompareS_pass 0\n' >"${run_check_case_dir}/result.ref" + + if [ "${run_check_mode}" = debug ]; then + cp "${integrate_dir}/validation_tools/run_check.sh" "${run_check_case_dir}/run_check.sh" + cp -r "${integrate_dir}/validation_tools" "${run_check_case_dir}/validation_tools" + run_check_command=(bash ./run_check.sh debug) + else + run_check_command=(bash ../../integrate/validation_tools/run_check.sh) + fi + + run_check_log="${test_root}/run-check-${run_check_mode}.log" + if ( + cd "${run_check_case_dir}" + PATH="${test_root}/fake_bin:${PATH}" \ + ABACUS_EXE="${test_root}/fake_abacus" \ + "${run_check_command[@]}" + ) >"${run_check_log}" 2>&1; then + cat "${run_check_log}" >&2 + echo "run_check.sh ${run_check_mode} path reported success after collector failure" >&2 + exit 1 + fi + grep -q 'Failed to collect validation results.' "${run_check_log}" +done + +run_check_log="${test_root}/run-check.log" +if ( + cd "${deepks_missing_case_dir}" + PATH="${test_root}/fake_bin:${PATH}" \ + ABACUS_EXE="${test_root}/fake_abacus" \ + bash ../../integrate/validation_tools/run_check.sh generate +) >"${run_check_log}" 2>&1; then + cat "${run_check_log}" >&2 + echo "run_check.sh reported success after reference generation failed" >&2 + exit 1 +fi + +if [ -e "${deepks_missing_case_dir}/result.ref" ]; then + echo "run_check.sh left a partial result.ref after generation failure" >&2 + exit 1 +fi + +echo test_case >"${test_root}/tests/01_PW/CASES.txt" +autotest_log="${test_root}/autotest.log" +if ( + cd "${test_root}/tests/01_PW" + OMP_NUM_THREADS=1 bash ../integrate/Autotest.sh \ + -a "${test_root}/fake_abacus" -n 0 -o 1 -j 1 -f CASES.txt -g +) >"${autotest_log}" 2>&1; then + cat "${autotest_log}" >&2 + echo "Autotest.sh reported success after reference generation failed" >&2 + exit 1 +fi + +if [ -e "${case_dir}/result.ref" ]; then + echo "Autotest.sh left a partial result.ref after generation failure" >&2 + exit 1 +fi + +# Temporary reference failures must preserve the previous accepted result. +printf 'previous reference\n' >"${case_dir}/result.ref" +if ( + cd "${test_root}/tests/01_PW" + OMP_NUM_THREADS=1 bash ../integrate/Autotest.sh \ + -a "${test_root}/fake_abacus" -n 0 -o 1 -j 1 -f CASES.txt -g +) >"${autotest_log}" 2>&1; then + echo "Autotest.sh accepted a failed comparison in result.ref.new" >&2 + exit 1 +fi +grep -qx 'previous reference' "${case_dir}/result.ref" +test ! -e "${case_dir}/result.ref.new" +if ( + cd "${case_dir}" + PATH="${test_root}/fake_bin:${PATH}" ABACUS_EXE="${test_root}/fake_abacus" \ + bash ../../integrate/validation_tools/run_check.sh generate +) >"${run_check_log}" 2>&1; then + echo "run_check.sh accepted a failed comparison in result.ref.new" >&2 + exit 1 +fi +grep -qx 'previous reference' "${case_dir}/result.ref" +test ! -e "${case_dir}/result.ref.new" + +# Successful generation must replace the old reference through the same path. +printf 'value 1\n' >"${case_dir}/band.txt.ref" +printf '# ABACUS version: test\nvalue 1\n' >"${case_dir}/OUT.autotest/band.txt" +( + cd "${test_root}/tests/01_PW" + OMP_NUM_THREADS=1 bash ../integrate/Autotest.sh \ + -a "${test_root}/fake_abacus" -n 0 -o 1 -j 1 -f CASES.txt -g +) >"${autotest_log}" 2>&1 +grep -qx 'CompareBand_pass 0' "${case_dir}/result.ref" +test ! -e "${case_dir}/result.ref.new" + +# Upstream's dedicated-validator path must still honor a custom MPI launcher, +# its flags, the OFML single-rank exception, and commented case-list entries. +launcher_case_dir="${test_root}/tests/01_PW/launcher_case" +mkdir -p "${launcher_case_dir}" +printf 'INPUT_PARAMETERS\ncalculation get_s\nout_band 1\n' >"${launcher_case_dir}/INPUT" +printf '\n # absent_case\nlauncher_case\n' >"${test_root}/tests/01_PW/LAUNCHER_CASES.txt" +cat >"${test_root}/fake_bin/custom_mpi" <<'EOF' +#!/usr/bin/env bash +set -eu +[ "$#" -eq 6 ] +[ "$1" = "--ranks" ] +[ "$2" = "$EXPECTED_RANKS" ] +[ "$3" = "--test-pre-one" ] +[ "$4" = "--test-pre-two" ] +[ "$6" = "--test-post" ] +touch "$LAUNCHER_MARKER" +exec "$5" +EOF +chmod +x "${test_root}/fake_bin/custom_mpi" +for expected_ranks in 4 1; do + if [ "${expected_ranks}" -eq 1 ]; then + printf 'of_ml_gene_data 1\n' >>"${launcher_case_dir}/INPUT" + fi + launcher_log="${test_root}/launcher-${expected_ranks}.log" + ( + cd "${test_root}/tests/01_PW" + EXPECTED_RANKS="${expected_ranks}" \ + LAUNCHER_MARKER="${test_root}/launcher-${expected_ranks}.used" \ + ABACUS_MPIEXEC="${test_root}/fake_bin/custom_mpi" \ + ABACUS_MPIEXEC_NUMPROC_FLAG=--ranks \ + ABACUS_MPIEXEC_PREFLAGS='--test-pre-one --test-pre-two' \ + ABACUS_MPIEXEC_POSTFLAGS=--test-post \ + OMP_NUM_THREADS=1 bash ../integrate/Autotest.sh \ + -a "${test_root}/fake_abacus" -n 4 -o 1 -j 1 -f LAUNCHER_CASES.txt -p + ) >"${launcher_log}" 2>&1 + test -f "${test_root}/launcher-${expected_ranks}.used" + grep -q 'Property collectors skipped' "${launcher_log}" + if [ -e "${launcher_case_dir}/result.out" ] || [ -e "${launcher_case_dir}/result.ref" ]; then + echo "Autotest.sh ran property collectors despite -p" >&2 + exit 1 + fi +done + +# Preserve upstream current filenames/tolerances and all three r(R) components, +# including failure recording in ordinary output and temporary references. +for collector in current position; do + merged_case="${test_root}/tests/01_PW/merged_${collector}" + mkdir -p "${merged_case}/OUT.autotest" + printf 'INPUT_PARAMETERS\ncalculation get_s\n' >"${merged_case}/INPUT" + printf 'Driver atomic_world 0.01\n' >"${merged_case}/OUT.autotest/running_get_s.log" + touch "${merged_case}/sr_nao.csr.ref" "${merged_case}/OUT.autotest/sr_nao.csr" + if [ "${collector}" = current ]; then + printf 'out_current 2\n' >>"${merged_case}/INPUT" + printf 'current_threshold 1e-4\n' >"${merged_case}/threshold" + printf '0 1\n' >"${merged_case}/current_tot.txt.ref" + printf '0 1.00001\n' >"${merged_case}/OUT.autotest/current_tot_comm.txt" + merged_key=CompareCurrent_pass + broken_file=current_tot_comm.txt + else + printf 'out_mat_r 1\n' >>"${merged_case}/INPUT" + for axis in x y z; do + printf '0 1\n' >"${merged_case}/rr${axis}_nao.csr.ref" + printf '0 1\n' >"${merged_case}/OUT.autotest/rr${axis}_nao.csr" + done + merged_key=ComparerR_pass + broken_file=rrx_nao.csr + fi + ( + cd "${merged_case}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref.new + ) + grep -qx "${merged_key} 0" "${merged_case}/result.ref.new" + printf '1 2\n' >>"${merged_case}/OUT.autotest/${broken_file}" + ( + cd "${merged_case}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.out + ) + grep -qx "${merged_key} 1" "${merged_case}/result.out" + if ( + cd "${merged_case}" + bash -e ../../integrate/validation_tools/catch_properties.sh result.ref.new + ); then + echo "catch_properties.sh accepted invalid ${collector} output in result.ref.new" >&2 + exit 1 + fi + test ! -e "${merged_case}/result.ref.new" +done diff --git a/tests/integrate/validation_tools/test_compare_file.py b/tests/integrate/validation_tools/test_compare_file.py new file mode 100644 index 0000000000..68e01e1a67 --- /dev/null +++ b/tests/integrate/validation_tools/test_compare_file.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +import pathlib +import subprocess +import sys +import tempfile +import unittest + + +COMPARE_FILE = pathlib.Path(__file__).with_name("CompareFile.py") + + +class CompareFileTest(unittest.TestCase): + def run_compare(self, first_content, second_content, extra_arguments=None): + with tempfile.TemporaryDirectory() as temporary_directory: + temporary_path = pathlib.Path(temporary_directory) + first_path = temporary_path / "first.txt" + second_path = temporary_path / "second.txt" + first_path.write_text(first_content, encoding="utf-8") + second_path.write_text(second_content, encoding="utf-8") + command = [sys.executable, str(COMPARE_FILE), str(first_path), str(second_path)] + if extra_arguments: + command.extend(extra_arguments) + return subprocess.run( + command, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + check=False, + ) + + def test_equal_files_with_comments_and_blank_lines_pass(self): + result = self.run_compare("# heading\n\nvalue 1.0\n", " # heading \n \nvalue 1.0\n") + + self.assertEqual(result.returncode, 0, result.stdout) + + def test_missing_data_line_fails_in_either_file(self): + for first_content, second_content in ( + ("value 1.0\nextra 2.0\n", "value 1.0\n"), + ("value 1.0\n", "value 1.0\nextra 2.0\n"), + ): + with self.subTest(first_content=first_content, second_content=second_content): + result = self.run_compare(first_content, second_content) + + self.assertEqual(result.returncode, 1) + self.assertIn("", result.stdout) + + def test_extra_comment_line_fails(self): + result = self.run_compare("value 1.0\n# extra\n", "value 1.0\n") + + self.assertEqual(result.returncode, 1) + + def test_trailing_blank_lines_are_ignored(self): + result = self.run_compare("value 1.0\n\n", "value 1.0\n") + + self.assertEqual(result.returncode, 0, result.stdout) + + def test_extra_interior_blank_line_fails(self): + result = self.run_compare("first 1.0\n\nsecond 2.0\n", "first 1.0\nsecond 2.0\n") + + self.assertEqual(result.returncode, 1) + + def test_final_newline_is_not_significant(self): + result = self.run_compare("value 1.0\n", "value 1.0") + + self.assertEqual(result.returncode, 0, result.stdout) + + def test_provenance_and_step_normalization_preserve_strict_comparison(self): + reference = "STEP: 1\nvalue 1.0\n" + output = "# ABACUS version: test\n# Written at test time\n# Ionic_Step 1\nvalue 1.0\n" + self.assertEqual(self.run_compare(reference, output).returncode, 0) + self.assertEqual(self.run_compare(reference, output + "extra 2.0\n").returncode, 1) + self.assertEqual(self.run_compare(output + "extra 2.0\n", reference).returncode, 1) + + def test_custom_tolerance_keeps_non_finite_and_row_count_checks(self): + arguments = ["-tol", "1e-4"] + self.assertEqual(self.run_compare("1.0\n", "1.00001\n", arguments).returncode, 0) + self.assertEqual(self.run_compare("1.0\n", "1.001\n", arguments).returncode, 1) + self.assertEqual(self.run_compare("1.0\n", "1.00001\n2.0\n", arguments).returncode, 1) + self.assertEqual(self.run_compare("nan\n", "nan\n", arguments).returncode, 1) + + def test_non_finite_numbers_fail(self): + comparisons = ( + ("value nan\n", "value nan\n", []), + ("value nan\n", "value 1.0\n", []), + ("value inf\n", "value inf\n", ["-com_type", "0"]), + ("value inf\n", "value -inf\n", ["-com_type", "0"]), + ("value (1.0,nan)\n", "value (1.0,nan)\n", []), + ) + for first_content, second_content, extra_arguments in comparisons: + with self.subTest(first_content=first_content, second_content=second_content): + result = self.run_compare(first_content, second_content, extra_arguments) + + self.assertEqual(result.returncode, 1, result.stdout) + + +if __name__ == "__main__": + unittest.main()