Skip to content

Commit

Permalink
Add cxx_std to regression test jobs to allow them to specify C++ st…
Browse files Browse the repository at this point in the history
…andard to compile with
  • Loading branch information
bluetarpmedia committed May 23, 2024
1 parent fcfdcec commit 11bdee2
Show file tree
Hide file tree
Showing 2,618 changed files with 838 additions and 18 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
regression-tests:
name: Run ${{ matrix.os }} | ${{ matrix.compiler }} | ${{ matrix.stdlib }}
name: ${{ matrix.os }} | ${{ matrix.compiler }} | ${{ matrix.cxx_std }} | ${{ matrix.stdlib }}
runs-on: ${{ matrix.os }}
env:
CXX: ${{ matrix.compiler }}
Expand All @@ -21,31 +21,44 @@ jobs:
matrix:
os: [ubuntu-24.04]
compiler: [g++-13, g++-14, clang++-18]
cxx_std: [c++2b]
stdlib: [libstdc++]
include:
- os: ubuntu-22.04
compiler: clang++-15
cxx_std: c++20
stdlib: libstdc++
- os: ubuntu-22.04
compiler: clang++-15
cxx_std: c++20
stdlib: libc++-15-dev
- os: ubuntu-20.04
compiler: clang++-12
cxx_std: c++20
stdlib: libstdc++
- os: ubuntu-20.04
compiler: g++-10
cxx_std: c++20
stdlib: libstdc++
- os: macos-14
compiler: clang++
cxx_std: c++2b
stdlib: default
- os: macos-13
compiler: clang++
cxx_std: c++2b
stdlib: default
- os: macos-13
compiler: clang++-15
cxx_std: c++2b
stdlib: default
- os: windows-latest
compiler: cl.exe
cxx_std: c++latest
stdlib: default
- os: windows-latest
compiler: cl.exe
cxx_std: c++20
stdlib: default
steps:
- name: Checkout repo
Expand All @@ -61,15 +74,15 @@ jobs:
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: |
cd regression-tests
bash run-tests.sh -c ${{ matrix.compiler }} -s ${{ matrix.stdlib }} -l ${{ matrix.os }}
bash run-tests.sh -c ${{ matrix.compiler }} -s ${{ matrix.cxx_std }} -d ${{ matrix.stdlib }} -l ${{ matrix.os }}
- name: Run regression tests - Windows version
if: matrix.os == 'windows-latest'
run: |
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
git config --local core.autocrlf false && ^
cd regression-tests && ^
bash run-tests.sh -c ${{ matrix.compiler }} -l ${{ matrix.os }}
bash run-tests.sh -c ${{ matrix.compiler }} -s ${{ matrix.cxx_std }} -l ${{ matrix.os }}
shell: cmd

- name: Upload patch
Expand Down
37 changes: 22 additions & 15 deletions regression-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
usage() {
echo "Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>]"
echo " -c <compiler> The compiler to use for the test"
echo " -s <stdlib> Clang-only: the C++ Standard Library to link with ('libstdc++', 'libc++', or 'default' for platform default)"
echo " -s <cxx_std> The C++ standard to compile with (e.g. 'c++20', 'c++2b', 'c++latest' depending on the compiler)"
echo " -d <stdlib> Clang-only: the C++ Standard Library to link with ('libstdc++', 'libc++', or 'default' for platform default)"
echo " -l <run label> The label to use in output patch file name"
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
echo " If the argument is not used all tests are run"
Expand Down Expand Up @@ -47,7 +48,7 @@ check_file () {
git ls-files --error-unmatch "$file" > /dev/null 2>&1
untracked=$?

patch_file="${label}-${cxx_compiler}-${cxx_stdlib}.patch"
patch_file="${label}-${cxx_compiler}-${cxx_std}-${cxx_stdlib}.patch"

if [[ $untracked -eq 1 ]]; then
# Add the file to the index to be able to diff it...
Expand All @@ -68,13 +69,16 @@ check_file () {
fi
}

optstring="c:s:l:t:"
optstring="c:s:d:l:t:"
while getopts ${optstring} arg; do
case "${arg}" in
c)
cxx_compiler="${OPTARG}"
;;
s)
cxx_std="${OPTARG}"
;;
d)
cxx_stdlib="${OPTARG}"
;;
l)
Expand Down Expand Up @@ -129,8 +133,8 @@ expected_results_dir="test-results"
################
# Get the directory with the exec outputs and compilation command
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
compiler_cmd='cl.exe -nologo -std:c++latest -MD -EHsc -I ..\..\..\include -Fe:'
exec_out_dir="$expected_results_dir/msvc-2022"
compiler_cmd="cl.exe -nologo -std:${cxx_std} -MD -EHsc -I ..\..\..\include -Fe:"
exec_out_dir="$expected_results_dir/msvc-2022-${cxx_std}"
compiler_version=$(cl.exe)
else
# Verify the compiler command
Expand All @@ -140,7 +144,6 @@ else
exit 2
fi

cpp_std=c++2b
compiler_version=$("$cxx_compiler" --version)

if [[ "$compiler_version" == *"Apple clang version 14.0"* ||
Expand All @@ -152,16 +155,16 @@ else
exec_out_dir="$expected_results_dir/clang-12"
elif [[ "$compiler_version" == *"clang version 15.0"* ]]; then
exec_out_dir="$expected_results_dir/clang-15"
# c++2b causes starge issues on GitHub ubuntu runners
cpp_std="c++20"
# c++2b causes strange issues on GitHub ubuntu runners
cxx_std="c++20"
elif [[ "$compiler_version" == *"clang version 18.1"* ]]; then
exec_out_dir="$expected_results_dir/clang-18"
# c++2b causes starge issues on GitHub ubuntu runners
cpp_std="c++20"
# c++2b causes strange issues on GitHub ubuntu runners
cxx_std="c++20"
elif [[ "$compiler_version" == *"g++-10"* ]]; then
exec_out_dir="$expected_results_dir/gcc-10"
# GCC 10 does not support c++2b
cpp_std=c++20
cxx_std=c++20
elif [[ "$compiler_version" == *"g++-12"* ||
"$compiler_version" == *"g++-13"*
]]; then
Expand All @@ -173,10 +176,14 @@ else
exit 2
fi

# Clang can choose which C++ Standard Library (libstdc++ | libc++) to link with
# Append the C++ standard (e.g. 'c++20') to the expected output dir name
exec_out_dir="${exec_out_dir}-${cxx_std}"

# Clang can link with either libstdc++ or libc++
# By default clang on ubuntu links with libstdc++ and on macOS links with libc++.
if [[ "$compiler_version" == *"clang"* ]]; then
if [[ "$cxx_stdlib" == "default" || "$cxx_stdlib" == "" ]]; then
cxx_stdlib_link_arg=""
cxx_stdlib_link_arg="" # Use compiler/platform default
elif [[ "$cxx_stdlib" == "libstdc++" ]]; then
cxx_stdlib_link_arg="-stdlib=libstdc++"
elif [[ "$cxx_stdlib" == *"libc++"* ]]; then
Expand All @@ -194,10 +201,10 @@ else
exit 2
fi
else
cxx_stdlib_link_arg=""
cxx_stdlib_link_arg="" # Use compiler/platform default
fi

compiler_cmd="$cxx_compiler -I../../../include -std=$cpp_std $cxx_stdlib_link_arg -pthread -o "
compiler_cmd="$cxx_compiler -I../../../include -std=$cxx_std $cxx_stdlib_link_arg -pthread -o "
printf "\ncompiler_cmd: $compiler_cmd\n\n"
fi

Expand Down
File renamed without changes.
Loading

0 comments on commit 11bdee2

Please sign in to comment.