Skip to content

Commit fa0134a

Browse files
authored
CI: Update and fix (#957)
* CI: Unify diffing in run-tests.shi and update workflow * CI: Update MacOs tests
1 parent 29a1f43 commit fa0134a

File tree

5 files changed

+44
-25
lines changed

5 files changed

+44
-25
lines changed

.github/workflows/regression-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ jobs:
2727
compiler: cl.exe
2828
steps:
2929
- name: Checkout repo
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3131

3232
- name: Run regression tests - Linux and macOS version
3333
if: startsWith(matrix.os, 'ubuntu') || matrix.os == 'macos-13'
3434
run: |
3535
cd regression-tests
36-
bash run-tests.sh -c ${{ matrix.compiler }}
36+
bash run-tests.sh -c ${{ matrix.compiler }} -l ${{ matrix.os }}
3737
3838
- name: Run regression tests - Windows version
3939
if: matrix.os == 'windows-latest'
4040
run: |
4141
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
4242
git config --local core.autocrlf false && ^
4343
cd regression-tests && ^
44-
bash run-tests.sh -c ${{ matrix.compiler }}
44+
bash run-tests.sh -c ${{ matrix.compiler }} -l ${{ matrix.os }}
4545
shell: cmd
4646

4747
- name: Upload patch
4848
if: ${{ !cancelled() }}
4949
uses: actions/upload-artifact@v4
5050
with:
51-
name: ${{ matrix.compiler }}-patch.diff
52-
path: regression-tests/${{ matrix.compiler }}-patch.diff
51+
name: ${{ matrix.os }}-${{ matrix.compiler }}.patch
52+
path: regression-tests/${{ matrix.os }}-${{ matrix.compiler }}.patch
5353
if-no-files-found: ignore

regression-tests/run-tests.sh

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,33 @@
22

33
################
44
usage() {
5-
echo "Usage: $0 -c <compiler> [-t <tests to run>]"
5+
echo "Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>]"
66
echo " -c <compiler> The compiler to use for the test"
7+
echo " -l <run label> The label to use in output patch file name"
78
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
89
echo " If the argument is not used all tests are run"
910
exit 1
1011
}
1112

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+
1232
################
1333
# Check file existence and compare its state against the version in git
1434
check_file () {
@@ -26,34 +46,36 @@ check_file () {
2646
git ls-files --error-unmatch "$file" > /dev/null 2>&1
2747
untracked=$?
2848

49+
patch_file="$label$cxx_compiler.patch"
50+
2951
if [[ $untracked -eq 1 ]]; then
30-
echo " The $description is not tracked by git:"
31-
echo " $file"
3252
# Add the file to the index to be able to diff it...
3353
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
3760
git rm --cached -- "$file" > /dev/null 2>&1
38-
39-
failure=1
4061
else
4162
# 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"
4867
fi
4968
}
5069

51-
optstring="c:t:"
70+
optstring="c:l:t:"
5271
while getopts ${optstring} arg; do
5372
case "${arg}" in
5473
c)
5574
cxx_compiler="${OPTARG}"
5675
;;
76+
l)
77+
label="${OPTARG}-"
78+
;;
5779
t)
5880
# Replace commas with spaces
5981
chosen_tests=${OPTARG/,/ }
@@ -103,11 +125,11 @@ expected_results_dir="test-results"
103125
################
104126
# Get the directory with the exec outputs and compilation command
105127
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:'
107129
exec_out_dir="$expected_results_dir/msvc-2022"
108130
compiler_version=$(cl.exe)
109131
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 "
111133

112134
compiler_ver=$("$cxx_compiler" --version)
113135
if [[ "$compiler_ver" == *"Apple clang version 14.0"* ]]; then
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
Null safety violation: std::optional does not contain a value
2-
libc++abi: terminating
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
Null safety violation: std::shared_ptr is empty
2-
libc++abi: terminating
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
Null safety violation: std::unique_ptr is empty
2-
libc++abi: terminating

0 commit comments

Comments
 (0)