Skip to content

Commit 6ace80f

Browse files
committed
fix: guard POSIX-only unit tests on Windows
- test_toolchain_detect: fake shell script tests skip on Windows - test_toolchain_registry: expect clang++.exe on Windows - test_xpkg_emit: sha256_of_file uses sha256sum (Linux only)
1 parent d89931d commit 6ace80f

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/unit/test_toolchain_detect.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ esac
5454

5555
} // namespace
5656

57+
#if !defined(_WIN32)
58+
// Uses a fake shell script as a compiler — POSIX only.
5759
TEST(ToolchainDetect, ClangVersionOutputIsNotMisclassifiedByGccPaths) {
5860
auto clang = make_fake_clang();
5961
TempDirGuard cleanup{clang.parent_path()};
@@ -66,6 +68,7 @@ TEST(ToolchainDetect, ClangVersionOutputIsNotMisclassifiedByGccPaths) {
6668
EXPECT_EQ(tc->stdlibId, "libc++");
6769
EXPECT_FALSE(tc->hasImportStd);
6870
}
71+
#endif // !defined(_WIN32)
6972

7073
// ─── normalize_driver_output: path-free semantic identity ─────────────
7174
//
@@ -126,6 +129,7 @@ TEST(NormalizeDriverOutput, EmptyInputProducesEmpty) {
126129
EXPECT_EQ(normalize_driver_output("\n\n\n"), "");
127130
}
128131

132+
#if !defined(_WIN32)
129133
// ─── detect() populates driverIdent ─────────────────────────────────
130134
TEST(ToolchainDetect, PopulatesDriverIdentFromVersionOutput) {
131135
auto clang = make_fake_clang();
@@ -138,3 +142,4 @@ TEST(ToolchainDetect, PopulatesDriverIdentFromVersionOutput) {
138142
EXPECT_NE(tc->driverIdent.find("clang version 20.1.7"), std::string::npos)
139143
<< "driverIdent should contain the --version header: " << tc->driverIdent;
140144
}
145+
#endif // !defined(_WIN32)

tests/unit/test_toolchain_registry.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ TEST(ToolchainRegistry, MapsLlvmAndClangAliasesToLlvmPackage) {
4848
EXPECT_EQ(llvmPkg.display_spec(), "llvm@20.1.7");
4949
EXPECT_EQ(clangPkg.display_spec(), "clang@20.1.7");
5050
ASSERT_FALSE(clangPkg.frontendCandidates.empty());
51+
#if defined(_WIN32)
52+
EXPECT_EQ(clangPkg.frontendCandidates.front(), "clang++.exe");
53+
#else
5154
EXPECT_EQ(clangPkg.frontendCandidates.front(), "clang++");
55+
#endif
5256
}
5357

5458
TEST(ToolchainRegistry, ResolvesPartialMuslVersionForDisplayAndPackage) {

tests/unit/test_xpkg_emit.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ TEST(XpkgEmit, ReleaseTarballUrl) {
9696
EXPECT_EQ(release_tarball_url("git@github.com:foo/bar.git", "bar", "0.1.0"), "");
9797
}
9898

99+
#if !defined(_WIN32)
100+
// sha256_of_file uses sha256sum which is not available on Windows
99101
TEST(XpkgEmit, Sha256OfFile) {
100102
using namespace mcpp::publish;
101103

@@ -116,6 +118,7 @@ TEST(XpkgEmit, Sha256OfFile) {
116118
// Non-existent file → empty string
117119
EXPECT_EQ(sha256_of_file("/no/such/path/zzz"), "");
118120
}
121+
#endif // !defined(_WIN32)
119122

120123
TEST(XpkgEmit, LongBracketSequenceInValueIsHarmless) {
121124
// We emit `"..."` strings, not `[[...]]`, so a literal `]=]` in

0 commit comments

Comments
 (0)