Skip to content

Commit 0e74bd7

Browse files
MSVC regression-test job in CI now builds and links with C++ standard library modules to enable import std.compat; (#953)
* Fix typo * MSVC CI regression tests now build and link with the `std.compat` module for the C++ standard library * Fix syntax to access environment variable * Need to build `std` module as well as `std.compat` * Fix syntax typo * Remove temp `exit` that was used for testing
1 parent e7dfcbc commit 0e74bd7

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

regression-tests/run-tests.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ check_file () {
3939
failure=1
4040
else
4141
# Compare the content with the reference value checked in git
42-
diff_output=$(git diff --ignore-cr-at-eol -I"\#define CPP2\_.*\_STD" -- "$file")
42+
diff_output=$(git diff --ignore-cr-at-eol -- "$file")
4343
if [[ -n "$diff_output" ]]; then
4444
echo " Non-matching $description:"
4545
printf "\n$diff_output\n\n" | tee -a "$cxx_compiler-patch.diff"
@@ -103,7 +103,7 @@ expected_results_dir="test-results"
103103
################
104104
# Get the directory with the exec outputs and compilation command
105105
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
106-
compiler_cmd='cl.exe -nologo -std:c++latest -MD -EHsc -I ..\include -I ..\..\..\include -experimental:module -Fe:'
106+
compiler_cmd='cl.exe -nologo -std:c++latest -MD -EHsc -I ..\include -I ..\..\..\include -Fe:'
107107
exec_out_dir="$expected_results_dir/msvc-2022"
108108
compiler_version=$(cl.exe)
109109
else
@@ -144,14 +144,26 @@ if [[ $? -ne 0 ]]; then
144144
exit 2
145145
fi
146146

147+
################
148+
# Build the `std` and `std.compat` modules so that the regression tests can use them (currently only supported by MSVC)
149+
# in order to support `import std.compat;`.
150+
regression_test_link_obj=""
151+
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
152+
echo "Building std and std.compat modules"
153+
(cd $exec_out_dir; \
154+
cl.exe -nologo -std:c++latest -MD -EHsc -c "${VCToolsInstallDir}/modules/std.ixx";
155+
cl.exe -nologo -std:c++latest -MD -EHsc -c "${VCToolsInstallDir}/modules/std.compat.ixx")
156+
regression_test_link_obj="std.obj std.compat.obj"
157+
fi
158+
147159
################
148160
failed_tests=()
149161
failed_compilations=()
150162
skipped_tests=()
151163
echo "Running regression tests"
152164
for test_file in $tests; do
153165
test_name=${test_file%.*}
154-
expeced_output="$expected_results_dir/$test_file.output"
166+
expected_output="$expected_results_dir/$test_file.output"
155167
generated_cpp_name=$test_name.cpp
156168
expected_src="$expected_results_dir/$generated_cpp_name"
157169
test_bin="test.exe"
@@ -163,24 +175,19 @@ for test_file in $tests; do
163175
if [[ $test_name == "pure2"* ]]; then
164176
descr="pure Cpp2 code"
165177
opt="-p"
166-
# Disable C++ modules with MSVC due to GitHub-hosted runner not supporting it
167-
# See https://github.com/hsutter/cppfront/issues/943
168-
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
169-
opt="$opt -include-std"
170-
fi
171178
fi
172179
echo " Testing $descr: $test_name.cpp2"
173180

174181
########
175182
# Run the translation test
176183
echo " Generating Cpp1 code"
177-
./"$cppfront_cmd" "$test_file" -o "$expected_src" $opt > "$expeced_output" 2>&1
184+
./"$cppfront_cmd" "$test_file" -o "$expected_src" $opt > "$expected_output" 2>&1
178185

179186
failure=0
180187
compiler_issue=0
181188
########
182189
# The C++1 generation output has to exist and to be tracked by git
183-
check_file "$expeced_output" "Cpp1 generation output file"
190+
check_file "$expected_output" "Cpp1 generation output file"
184191

185192
########
186193
# Check the generated code
@@ -200,7 +207,7 @@ for test_file in $tests; do
200207
# The source is temporarily copied to avoid issues with bash paths in cl.exe
201208
(cd $exec_out_dir; \
202209
cp ../../$expected_src $generated_cpp_name;
203-
$compiler_cmd"$test_bin" \
210+
$compiler_cmd"$test_bin" $regression_test_link_obj \
204211
$generated_cpp_name \
205212
> $generated_cpp_name.output 2>&1)
206213
compilation_result=$?
@@ -239,7 +246,7 @@ for test_file in $tests; do
239246
fi
240247
fi
241248
fi
242-
elif [[ $(cat "$expeced_output") != *"error"* ]]; then
249+
elif [[ $(cat "$expected_output") != *"error"* ]]; then
243250
echo " Missing generated src file treated as failure"
244251
echo " Failing compilation message needs to contain 'error'"
245252
failure=1

0 commit comments

Comments
 (0)