Skip to content

Commit 9adc5ad

Browse files
committed
fix(test): 新的 hostflags fixture 用了 MSVC 没有的 getpid/<unistd.h>
它在写下它的那台机器上编过了,在 Windows CI 上编不过 —— 而 Windows 是这个项目 一半的面唯一可见的地方。改成固定名 + 先 remove_all:gtest 在一个二进制里串行 跑测试,一个名字就够。
1 parent 31fa043 commit 9adc5ad

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/unit/test_hostflags.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <gtest/gtest.h>
22
#include <fstream>
3-
#include <unistd.h>
43

54
import std;
65
import mcpp.platform;
@@ -319,8 +318,12 @@ TEST(HostFlags, TheCfgBypassSurvivesAGraphSuppliedTargetSide) {
319318
// must not have. `resolve_clang_driver` only asks whether a sibling
320319
// `<driver>.cfg` EXISTS, so two empty files are a complete fixture.
321320
namespace fs = std::filesystem;
322-
const auto root = fs::temp_directory_path()
323-
/ ("mcpp_hostflags_" + std::to_string(::getpid()));
321+
// ⚠️ A FIXED NAME AND `remove_all` FIRST, NOT A PROCESS ID. The first
322+
// draft reached for `::getpid()` and `<unistd.h>`, which do not exist under
323+
// MSVC — it built on the machine it was written on and failed on Windows
324+
// CI, which is the only place that half of this project is visible.
325+
// gtest runs a binary's tests serially, so one name is enough.
326+
const auto root = fs::temp_directory_path() / "mcpp_hostflags_cfg_fixture";
324327
fs::remove_all(root);
325328
fs::create_directories(root / "bin");
326329
fs::create_directories(root / "include" / "c++" / "v1");

0 commit comments

Comments
 (0)