Files
opm-simulators/tests/make_failure_report.sh
T
Bård SkaflestadandCopilot Autofix powered by AI 9d321db0d8 Use Exact Test Name Matching When Extracting Test Properties
This commit switches away from matching specific test names in
CTestTestfile.cmake using regular expressions to using exact name
match instead.  The regular expressions are a little too brittle in
the face of partially overlapping test names like

    compareECLFiles_flow+UDT-1D-01
    compareECLFiles_flow+UDT-1D-01B

for which the greedy matching ".*$" could yield false positives.
Instead we use the "index" function to pinpoint the exact line, and
position within the line, that matches exactly that test and
specific property.  While here, switch the injected variable name
away from "search" and over to "test" to better reflect the nature
of the variable and update call sites accordingly.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-29 09:09:38 +02:00

48 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Generates a summary plot comparison for each failed test case
OPM_TESTS_ROOT=$1
BUILD_DIR=$2
RESULT_DIR=$3
SOURCE_DIR=`dirname "$0"`
JOBS=${BUILDTHREADS:-16}
FAILED_TESTS=`cat $BUILD_DIR/Testing/Temporary/LastTestsFailed*.log`
mkdir -p $BUILD_DIR/failure_report
cd $BUILD_DIR/failure_report
rm -f *
JOBLIST=""
for failed_test in $FAILED_TESTS
do
if grep -q -E "compareECLFiles" <<< $failed_test
then
failed_test=$(echo "${failed_test}" | sed -e 's/.*://')
# Extract test properties
binary=$(awk -v test="${failed_test}" -v prop="SIMULATOR" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
dir_name=$(awk -v test="${failed_test}" -v prop="DIRNAME" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
file_name=$(awk -v test="${failed_test}" -v prop="FILENAME" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
test_name=$(awk -v test="${failed_test}" -v prop="TESTNAME" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
JOBLIST+="-r $OPM_TESTS_ROOT/${dir_name}/opm-simulation-reference/${binary}/${file_name} -s $RESULT_DIR/tests/results/$binary+$test_name/$file_name -c $test_name -o plot\\n"
elif grep -q -E "compareSeparateECLFiles" <<< $failed_test
then
failed_test=$(echo "${failed_test}" | sed -e 's/.*://')
# Extract test properties
binary=$(awk -v test="${failed_test}" -v prop="SIMULATOR" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
dir_name=$(awk -v test="${failed_test}" -v prop="DIRNAME" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
file_name1=$(awk -v test="${failed_test}" -v prop="FILENAME1" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
file_name2=$(awk -v test="${failed_test}" -v prop="FILENAME2" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
test_name=$(awk -v test="${failed_test}" -v prop="TESTNAME" -f ${SOURCE_DIR}/getprop.awk $RESULT_DIR/CTestTestfile.cmake)
JOBLIST+="-r $RESULT_DIR/tests/results/$binary+$test_name/$file_name1 -s $RESULT_DIR/tests/results/$binary+$test_name/$file_name2 -c $test_name -o plot -t $file_name1 -u $file_name2\\n"
fi
done
echo -e $JOBLIST | xargs -L1 -P${JOBS} $SOURCE_DIR/plot_well_comparison.py
if test -n "$FAILED_TESTS"
then
$SOURCE_DIR/plot_well_comparison.py -o rename
fi