2
2
3
3
# ###############
4
4
usage () {
5
- echo " Usage: $0 -c <compiler> [-t <tests to run>]"
5
+ echo " Usage: $0 -c <compiler> [-l <run label>] [- t <tests to run>]"
6
6
echo " -c <compiler> The compiler to use for the test"
7
+ echo " -l <run label> The label to use in output patch file name"
7
8
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
8
9
echo " If the argument is not used all tests are run"
9
10
exit 1
10
11
}
11
12
13
+ # ###############
14
+ # Check diff of the provided file using the given diff options
15
+ # If the diff is not empty print it with the provided message
16
+ report_diff () {
17
+ file=" $1 "
18
+ diff_opt=" $2 "
19
+ error_msg=" $3 "
20
+ patch_file=" $4 "
21
+
22
+ # Compare the content with the reference value checked in git
23
+ diff_output=$( git diff " $diff_opt " -- " $file " )
24
+ if [[ -n " $diff_output " ]]; then
25
+ echo " $error_msg :"
26
+ echo " $file "
27
+ printf " \n$diff_output \n\n" | tee -a " $patch_file "
28
+ failure=1
29
+ fi
30
+ }
31
+
12
32
# ###############
13
33
# Check file existence and compare its state against the version in git
14
34
check_file () {
@@ -26,34 +46,36 @@ check_file () {
26
46
git ls-files --error-unmatch " $file " > /dev/null 2>&1
27
47
untracked=$?
28
48
49
+ patch_file=" $label$cxx_compiler .patch"
50
+
29
51
if [[ $untracked -eq 1 ]]; then
30
- echo " The $description is not tracked by git:"
31
- echo " $file "
32
52
# Add the file to the index to be able to diff it...
33
53
git add " $file "
34
- # ... print the diff ...
35
- git --no-pager diff HEAD -- " $file " | tee -a " $cxx_compiler -patch.diff"
36
- # ... and remove the file from the diff
54
+ # ... report the diff ...
55
+ report_diff " $file " \
56
+ " HEAD" \
57
+ " The $description is not tracked by git" \
58
+ " $patch_file "
59
+ # ... and remove the file from the index
37
60
git rm --cached -- " $file " > /dev/null 2>&1
38
-
39
- failure=1
40
61
else
41
62
# Compare the content with the reference value checked in git
42
- diff_output=$( git diff --ignore-cr-at-eol -- " $file " )
43
- if [[ -n " $diff_output " ]]; then
44
- echo " Non-matching $description :"
45
- printf " \n$diff_output \n\n" | tee -a " $cxx_compiler -patch.diff"
46
- failure=1
47
- fi
63
+ report_diff " $file " \
64
+ " --ignore-cr-at-eol" \
65
+ " Non-matching $description " \
66
+ " $patch_file "
48
67
fi
49
68
}
50
69
51
- optstring=" c:t:"
70
+ optstring=" c:l: t:"
52
71
while getopts ${optstring} arg; do
53
72
case " ${arg} " in
54
73
c)
55
74
cxx_compiler=" ${OPTARG} "
56
75
;;
76
+ l)
77
+ label=" ${OPTARG} -"
78
+ ;;
57
79
t)
58
80
# Replace commas with spaces
59
81
chosen_tests=${OPTARG/ ,/ }
@@ -103,11 +125,11 @@ expected_results_dir="test-results"
103
125
# ###############
104
126
# Get the directory with the exec outputs and compilation command
105
127
if [[ " $cxx_compiler " == * " cl.exe" * ]]; then
106
- compiler_cmd=' cl.exe -nologo -std:c++latest -MD -EHsc -I ..\include -I ..\ ..\..\include -Fe:'
128
+ compiler_cmd=' cl.exe -nologo -std:c++latest -MD -EHsc -I ..\..\..\include -Fe:'
107
129
exec_out_dir=" $expected_results_dir /msvc-2022"
108
130
compiler_version=$( cl.exe)
109
131
else
110
- compiler_cmd=" $cxx_compiler -I../include -I../ ../../include -std=c++20 -pthread -o "
132
+ compiler_cmd=" $cxx_compiler -I../../../include -std=c++20 -pthread -o "
111
133
112
134
compiler_ver=$( " $cxx_compiler " --version)
113
135
if [[ " $compiler_ver " == * " Apple clang version 14.0" * ]]; then
0 commit comments