fix(test): run the binary the link wrote, .wasm included

RunTests worked each test binary's path out with a rule of its own,
TestBinaryPath: BinDir()/<name>, plus .exe for any triple naming windows
or mingw, and nothing for wasm. The link writes <name>.wasm for a wasm32
executable, so every wasm test declared with AddTest was handed to
wasmtime without its extension and failed with "failed to open wasm
module", inside the Flatpak as well, where wasmtime is bundled. RunTests
now asks ExpectedOutput(), the name the staleness checks and -r read,
which for a wasm32 executable is the <name>.wasm the link writes.
This commit is contained in:
Jorijn van der Graaf 2026-11-01 18:40:32 +01:00
commit 5d843f3967
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB

View file

@ -16,11 +16,6 @@ namespace {
return target.find("windows") != std::string_view::npos || target.find("mingw") != std::string_view::npos;
}
fs::path TestBinaryPath(const Configuration& cfg) {
fs::path outputDir = cfg.BinDir();
return outputDir / (TargetIsWindows(cfg.target) ? std::format("{}.exe", cfg.outputName) : cfg.outputName);
}
// MatchGlob/MatchAny live in :Platform — shared with the lint verb.
std::string JoinAndQuoteArgs(std::span<const std::string> args) {
@ -615,7 +610,12 @@ TestSummary Crafter::RunTests(Configuration& projectCfg, const RunTestsOptions&
}
std::chrono::seconds timeout = opts.timeoutOverride.value_or(t.timeout);
fs::path binary = TestBinaryPath(t.config);
// The file the link wrote, by the rule the staleness checks and -r
// use, which for a wasm32 executable is the <name>.wasm the link
// writes. A rule of its own here once added .exe for any Windows
// triple and nothing for wasm, so every wasm test was handed to
// wasmtime without the .wasm it was linked as.
fs::path binary = ExpectedOutput(t.config);
try {
r = RunSingleTest(t, binary, timeout);
} catch (const std::exception& e) {