Skip to content

Commit bdd9029

Browse files
runs_on: a platform that states no runner hosts is read as every system of each architecture
Under openkal-platform 0.17.3 a vendored universal package's runs_on came out empty and emit xpkg refused it (e2e 957). Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 87ab153 commit bdd9029

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎src/pack/distribution.cppm‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ struct Package {
117117

118118
// `runs_on` for `p`, from its legs, the runners it carries (`systems`), its
119119
// mode, and the platform's statement of where its runner exists (`runnerHosts`;
120-
// `runnerAnyArch` for a runner that reaches an artifact from any machine).
120+
// `runnerAnyArch` for a runner that reaches an artifact from any machine). A
121+
// platform that states no hosts is read as every system of each architecture.
121122
// A native package of one leg runs where its triple's program runs; a
122123
// WebAssembly, Android, iOS or bare-metal package is no program of a system and
123124
// runs nowhere an index entry could name.
@@ -1206,8 +1207,15 @@ void compute_runs_on(Package& p, const std::vector<std::string>& runnerHosts, bo
12061207
if (p.mode == "self-contained")
12071208
for (auto const& s : p.systems)
12081209
if (archs.contains(arch_of_pair(s))) p.runsOnSelf.push_back(s);
1210+
// A platform that does not state where its runner exists is read as
1211+
// before runs_on existed: every system, for each architecture of the
1212+
// images. Unknown is not "nowhere".
1213+
std::vector<std::string> every;
1214+
if (runnerHosts.empty())
1215+
for (auto system : { "linux", "macos", "windows" })
1216+
for (auto const& arch : archs) every.push_back(std::format("{}-{}", system, arch));
12091217
std::vector<std::string> with;
1210-
for (auto const& h : runnerHosts)
1218+
for (auto const& h : runnerHosts.empty() ? every : runnerHosts)
12111219
if ((runnerAnyArch || archs.contains(arch_of_pair(h)))
12121220
&& std::ranges::find(p.runsOnSelf, h) == p.runsOnSelf.end())
12131221
with.push_back(h);

‎tests/unit/test_pack_distribution.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ TEST(PackDistribution, AnEntryNamesWhereThePackageRuns) {
660660
ASSERT_TRUE(v) << v.error();
661661
EXPECT_NE(v->find("deps = { \"xim:okrun\" }"), std::string::npos) << *v;
662662

663+
// A platform that states no hosts for its runner is read as every system
664+
// of each architecture, as before runs_on existed.
665+
d::compute_runs_on(a.pkg, {}, false);
666+
EXPECT_EQ(a.pkg.runsOnWith.at("okrun").size(), 6u);
667+
663668
// The document carries it, and a reader takes it back.
664669
auto j = d::to_json(a.pkg);
665670
EXPECT_NE(j.find("\"runs_on\""), std::string::npos) << j;

0 commit comments

Comments
 (0)