Skip to content

Commit 6f51d5e

Browse files
committed
refactor(runtime_search): 删掉两个只有测试在用的导出函数
paths_of 与 parse_origin 在 src/ 下零消费者。导出面只有测试在撑,就是没有理由存在的 导出面。origin 名字的往返测试改成直接钉 to_string 的字面值 —— 那才是真正要紧的: 它们是 resolution.json 里 runtime.search.closure 的 origin 字段,改名等于改 wire 格式。
1 parent fd330c2 commit 6f51d5e

2 files changed

Lines changed: 9 additions & 36 deletions

File tree

src/platform/runtime_search.cppm

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ std::string_view to_string(Origin origin) {
117117
return "unknown";
118118
}
119119

120-
std::optional<Origin> parse_origin(std::string_view value) {
121-
if (value == "payload") return Origin::Payload;
122-
if (value == "package") return Origin::Package;
123-
if (value == "subos_farm") return Origin::SubosFarm;
124-
if (value == "host_default") return Origin::HostDefault;
125-
return std::nullopt;
126-
}
127-
128120
struct Dir {
129121
std::filesystem::path path;
130122
Origin origin = Origin::Payload;
@@ -169,15 +161,6 @@ std::vector<Dir> ordered(std::vector<Dir> dirs) {
169161
return merged;
170162
}
171163

172-
// Just the paths, in contract order — for the callers that render a flag or
173-
// walk a search path and have no use for the provenance.
174-
std::vector<std::filesystem::path> paths_of(std::span<const Dir> dirs) {
175-
std::vector<std::filesystem::path> out;
176-
out.reserve(dirs.size());
177-
for (auto const& dir : dirs) out.push_back(dir.path);
178-
return out;
179-
}
180-
181164
// The declarative exit from xlings' linker wrapper (openxlings/xlings#540).
182165
//
183166
// That wrapper appends `-rpath "$XLINGS_SUBOS_LIB" --disable-new-dtags` to

tests/unit/test_runtime_search.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ TEST(RuntimeSearch, MachineLocalIsEverythingButTheHostDefaults) {
3737
EXPECT_FALSE(search::is_machine_local(Origin::HostDefault));
3838
}
3939

40-
TEST(RuntimeSearch, OriginNamesRoundTrip) {
41-
for (auto origin : {Origin::Payload, Origin::Package,
42-
Origin::SubosFarm, Origin::HostDefault}) {
43-
auto parsed = search::parse_origin(search::to_string(origin));
44-
ASSERT_TRUE(parsed.has_value()) << search::to_string(origin);
45-
EXPECT_EQ(*parsed, origin);
46-
}
47-
EXPECT_FALSE(search::parse_origin("something_else").has_value());
40+
// These strings are PUBLISHED — they are the `origin` field of every entry in
41+
// `resolution.json`'s `runtime.search.closure`, which CI, `mcpp why runtime` and
42+
// e2e 219 all read. Renaming one is a wire-format change, so it is pinned here
43+
// rather than left to whatever `to_string` happens to say.
44+
TEST(RuntimeSearch, OriginNamesArePublishedAndStable) {
45+
EXPECT_EQ(search::to_string(Origin::Payload), "payload");
46+
EXPECT_EQ(search::to_string(Origin::Package), "package");
47+
EXPECT_EQ(search::to_string(Origin::SubosFarm), "subos_farm");
48+
EXPECT_EQ(search::to_string(Origin::HostDefault), "host_default");
4849
}
4950

5051
TEST(RuntimeSearch, OrderedSortsByRankNotByInsertion) {
@@ -104,17 +105,6 @@ TEST(RuntimeSearch, OrderedNormalizesAndDropsEmpty) {
104105
EXPECT_EQ(out[0].path, std::filesystem::path("/a/b"));
105106
}
106107

107-
TEST(RuntimeSearch, PathsOfPreservesContractOrder) {
108-
auto out = search::ordered({
109-
{"/farm", Origin::SubosFarm},
110-
{"/pay", Origin::Payload},
111-
});
112-
auto paths = search::paths_of(out);
113-
ASSERT_EQ(paths.size(), 2u);
114-
EXPECT_EQ(paths[0], std::filesystem::path("/pay"));
115-
EXPECT_EQ(paths[1], std::filesystem::path("/farm"));
116-
}
117-
118108
// The opt-out is a CROSS-REPO name (openxlings/xlings#540). Pinning the
119109
// spelling here means a rename shows up as a failed test rather than as a
120110
// silently ineffective declaration — the failure mode of an env var nobody

0 commit comments

Comments
 (0)