@@ -14,6 +14,7 @@ import mcpp.platform;
1414import mcpp.toolchain.clang;
1515import mcpp.toolchain.gcc;
1616import mcpp.toolchain.model;
17+ import mcpp.toolchain.msvc;
1718
1819namespace db = mcpp::build::database;
1920using mcpp::modgraph::ModuleDeclaration;
@@ -138,6 +139,37 @@ TEST(BuildDatabase, RecoversTheClangStdUnitsFromTheirBuilders) {
138139 EXPECT_TRUE (contains (compat->arguments , tc.stdCompatSource .string ()));
139140}
140141
142+ TEST (BuildDatabase, RecoversTheMsvcStdUnitsFromTheirBuilders) {
143+ Toolchain tc;
144+ tc.compiler = CompilerId::MSVC ;
145+ tc.version = " 19.44.35207" ;
146+ tc.binaryPath = host_path (
147+ " /vs/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe" ,
148+ " C:\\ Program Files\\ Microsoft Visual Studio\\ VC\\ Tools\\ MSVC\\ 14.44.35207\\ bin\\ Hostx64\\ x64\\ cl.exe" );
149+ tc.targetTriple = " x86_64-windows-msvc" ;
150+ tc.stdModuleSource = host_path (" /vs/VC/Tools/MSVC/14.44.35207/modules/std.ixx" ,
151+ " C:\\ Program Files\\ Microsoft Visual Studio\\ VC\\ Tools\\ MSVC\\ 14.44.35207\\ modules\\ std.ixx" );
152+ tc.stdCompatSource = host_path (" /vs/VC/Tools/MSVC/14.44.35207/modules/std.compat.ixx" ,
153+ " C:\\ Program Files\\ Microsoft Visual Studio\\ VC\\ Tools\\ MSVC\\ 14.44.35207\\ modules\\ std.compat.ixx" );
154+ const auto cache = host_path (" /home/u/.mcpp/cache/std/k3" , " C:\\ u\\ .mcpp\\ std\\ k3" );
155+
156+ auto stdCommands = msvc::std_module_build_commands (tc, cache, " /std:c++latest" , " /MD" );
157+ auto inv = db::recover_invocation (stdCommands, tc.stdModuleSource , tc.binaryPath ,
158+ " /unused" , kWindows );
159+ ASSERT_TRUE (inv.has_value ()) << stdCommands.front ();
160+ EXPECT_EQ (inv->workDirectory , cache) << stdCommands.front ();
161+ EXPECT_EQ (inv->arguments .front (), tc.binaryPath .string ()) << stdCommands.front ();
162+ EXPECT_TRUE (contains (inv->arguments , " /std:c++latest" )) << stdCommands.front ();
163+ EXPECT_TRUE (contains (inv->arguments , tc.stdModuleSource .string ())) << stdCommands.front ();
164+ EXPECT_FALSE (contains (inv->arguments , " 2>&1" )) << stdCommands.front ();
165+
166+ auto compatCommands = msvc::std_compat_build_commands (tc, cache, " /std:c++latest" , " /MD" );
167+ auto compat = db::recover_invocation (compatCommands, tc.stdCompatSource ,
168+ tc.binaryPath , " /unused" , kWindows );
169+ ASSERT_TRUE (compat.has_value ()) << compatCommands.front ();
170+ EXPECT_TRUE (contains (compat->arguments , " /reference" )) << compatCommands.front ();
171+ }
172+
141173TEST (BuildDatabase, NoCommandNamingTheSourceRecoversNothing) {
142174 auto inv = db::recover_invocation ({" cd /c && /bin/g++ -c other.cc -o o.o" },
143175 " /src/std.cc" , " /bin/g++" , " /c" , false );
0 commit comments