@@ -39,7 +39,7 @@ check_file () {
39
39
failure=1
40
40
else
41
41
# 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 " )
43
43
if [[ -n " $diff_output " ]]; then
44
44
echo " Non-matching $description :"
45
45
printf " \n$diff_output \n\n" | tee -a " $cxx_compiler -patch.diff"
@@ -103,7 +103,7 @@ expected_results_dir="test-results"
103
103
# ###############
104
104
# Get the directory with the exec outputs and compilation command
105
105
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:'
107
107
exec_out_dir=" $expected_results_dir /msvc-2022"
108
108
compiler_version=$( cl.exe)
109
109
else
@@ -144,14 +144,26 @@ if [[ $? -ne 0 ]]; then
144
144
exit 2
145
145
fi
146
146
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
+
147
159
# ###############
148
160
failed_tests=()
149
161
failed_compilations=()
150
162
skipped_tests=()
151
163
echo " Running regression tests"
152
164
for test_file in $tests ; do
153
165
test_name=${test_file% .* }
154
- expeced_output =" $expected_results_dir /$test_file .output"
166
+ expected_output =" $expected_results_dir /$test_file .output"
155
167
generated_cpp_name=$test_name .cpp
156
168
expected_src=" $expected_results_dir /$generated_cpp_name "
157
169
test_bin=" test.exe"
@@ -163,24 +175,19 @@ for test_file in $tests; do
163
175
if [[ $test_name == " pure2" * ]]; then
164
176
descr=" pure Cpp2 code"
165
177
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
171
178
fi
172
179
echo " Testing $descr : $test_name .cpp2"
173
180
174
181
# #######
175
182
# Run the translation test
176
183
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
178
185
179
186
failure=0
180
187
compiler_issue=0
181
188
# #######
182
189
# 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"
184
191
185
192
# #######
186
193
# Check the generated code
@@ -200,7 +207,7 @@ for test_file in $tests; do
200
207
# The source is temporarily copied to avoid issues with bash paths in cl.exe
201
208
(cd $exec_out_dir ; \
202
209
cp ../../$expected_src $generated_cpp_name ;
203
- $compiler_cmd " $test_bin " \
210
+ $compiler_cmd " $test_bin " $regression_test_link_obj \
204
211
$generated_cpp_name \
205
212
> $generated_cpp_name .output 2>&1 )
206
213
compilation_result=$?
@@ -239,7 +246,7 @@ for test_file in $tests; do
239
246
fi
240
247
fi
241
248
fi
242
- elif [[ $( cat " $expeced_output " ) != * " error" * ]]; then
249
+ elif [[ $( cat " $expected_output " ) != * " error" * ]]; then
243
250
echo " Missing generated src file treated as failure"
244
251
echo " Failing compilation message needs to contain 'error'"
245
252
failure=1
0 commit comments