Skip to content

Commit 24fb8d4

Browse files
committed
test(ninja): make 3 emission-format tests host-aware (fix windows CI)
test_ninja_backend asserted Linux/POSIX-shaped output that fails on the windows self-host runner (unrelated to product behavior, which is correct per-platform): (1) CxxModule...Depfile asserts the POSIX-only filtered gcc depfile → skip on Windows (MSVC uses deps=msvc); (2) MsvcIncludeDirs... breaks on the runner's C:\ temp path whose ':' is ninja-escaped → run the (host- independent) MSVC-dialect check on POSIX; (3) QuotesFlagValueWithSpace expects single-quote but shell_quote_arg uses double-quote on Windows → assert the platform-appropriate spelling. Product unchanged.
1 parent 3340e3c commit 24fb8d4

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

tests/unit/test_ninja_backend.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import mcpp.build.ninja;
77
import mcpp.build.plan;
88
import mcpp.manifest;
99
import mcpp.toolchain.model;
10+
import mcpp.platform;
1011

1112
using namespace mcpp::build;
1213

@@ -82,6 +83,12 @@ TEST(NinjaBackend, ObjectiveCSourceUsesCObjectRuleAndCFlags) {
8283
// -MMD output that ninja's depfile loader rejects — see the long comment at
8384
// the definition site for the empirically-confirmed failure mode.
8485
TEST(NinjaBackend, CxxModuleAndCxxObjectRulesTrackHeaderDepsViaGccDepfile) {
86+
// The filtered gcc depfile (#235) is POSIX-only: `posixDepfile =
87+
// !msvcDeps && !is_windows` (awk isn't available on native Windows, and
88+
// MSVC uses `deps = msvc` instead). This asserts the POSIX emission.
89+
if constexpr (mcpp::platform::is_windows)
90+
GTEST_SKIP() << "gcc depfile filter is POSIX-only (Windows uses deps=msvc)";
91+
8592
auto plan = minimal_plan();
8693

8794
auto ninja = emit_ninja_string(plan);
@@ -175,6 +182,13 @@ TEST(NinjaBackend, CxxFlagsIncludeBuildIncludeDirs) {
175182
// prepending the dialect prefix. This test would FAIL before the fix
176183
// (emitting the literal, unrewritten "/Iinclude") and passes after.
177184
TEST(NinjaBackend, MsvcIncludeDirsAreAbsolutizedNotGnuNormalized) {
185+
// The MSVC-dialect logic under test is host-independent; run it on POSIX
186+
// where the test's temp projectRoot has no drive letter. On Windows the
187+
// runner's `C:\...` temp path gets its `:` ninja-escaped (`C$:`), which
188+
// would need escape-aware matching unrelated to what this test verifies.
189+
if constexpr (mcpp::platform::is_windows)
190+
GTEST_SKIP() << "MSVC-dialect path check runs on POSIX (avoids Windows drive-colon ninja escaping)";
191+
178192
auto plan = minimal_plan();
179193
plan.toolchain.compiler = mcpp::toolchain::CompilerId::MSVC;
180194
plan.toolchain.binaryPath = "cl.exe";
@@ -300,8 +314,12 @@ TEST(NinjaBackend, QuotesFlagValueWithSpace) {
300314

301315
auto ninja = emit_ninja_string(plan);
302316

303-
EXPECT_NE(ninja.find("unit_cflags = '-DT=long long'"), std::string::npos)
304-
<< ninja;
317+
// shell_quote_arg wraps in single quotes on POSIX, double quotes on
318+
// Windows — assert the platform-appropriate spelling.
319+
const std::string quoted = mcpp::platform::is_windows
320+
? "unit_cflags = \"-DT=long long\""
321+
: "unit_cflags = '-DT=long long'";
322+
EXPECT_NE(ninja.find(quoted), std::string::npos) << ninja;
305323
// Must NOT appear as two bare, unquoted words split on the space.
306324
EXPECT_EQ(ninja.find("unit_cflags = -DT=long long"), std::string::npos)
307325
<< ninja;

0 commit comments

Comments
 (0)