test: drop transport runners (ssh/sshwin/wsl) and the Shell-quoting enum
All checks were successful
CI / build-test-release (pull_request) Successful in 9m56s

With test.toml + ForTarget covering the cross-arch + Windows-on-Linux
cases, the env-var-driven transport runners are dead weight. This commit
removes them and the retired tests that exercised the env-var plumbing:

  - TestRunner::Ssh / SshWin / Wsl factories and their copy/exec/cleanup
    template machinery.
  - TestRunner::Shell enum (Host/Sh/Cmd) and the ShellQuoteSh helper —
    only Host shell quoting is needed once the remote shells are gone.
  - TestRunner::copy / cleanup / remoteDir / argsShell fields.
  - WindowsPathToWsl and the {remote_bundle}/{bin_win}/{bundle_wsl}
    placeholder substitution in RunSingleTest's transport branch.
  - ParseRunnerSpec narrowed from {local, cmd, ssh, sshwin, wsl} to
    {local, cmd} — the override hatch is preserved, just simpler.
  - tests/SshRunner, tests/WindowsViaSsh, tests/QemuUser: these tested
    the CRAFTER_BUILD_RUNNER_<target> → runner plumbing that has been
    replaced by ForTarget. The runner derivation is exercised every
    time CrossArchAarch64 / Wasi / WindowsViaWine runs.
  - tests/UnitLib: ssh/sshwin spec assertions become "throws on bogus
    spec" assertions.

Refs issue #8.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-05-27 18:07:33 +02:00
commit 8de93aaf06
15 changed files with 35 additions and 516 deletions

View file

@ -1,58 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 Catcrafts®
Catcrafts.net
LGPL-3.0-only.
*/
import std;
import Crafter.Build;
#include "../_shared/TestUtil.h"
namespace fs = std::filesystem;
using namespace TestUtil;
using namespace Crafter;
namespace {
std::string PickQemu() {
if (const char* v = std::getenv("CRAFTER_TEST_QEMU"); v && *v) return v;
return "qemu-x86_64";
}
bool QemuPresent(const std::string& qemu) {
return std::system(std::format("which {} > /dev/null 2>&1", qemu).c_str()) == 0;
}
}
int main() {
try {
std::string qemu = PickQemu();
if (!QemuPresent(qemu)) Skip(std::format("{} not on PATH", qemu));
std::string spec = std::format("cmd:{}", qemu);
::setenv("CRAFTER_BUILD_RUNNER_x86_64_pc_linux_gnu", spec.c_str(), 1);
// Verify env-var translation independently of RunTests.
auto runner = TestRunner::FromEnv("x86_64-pc-linux-gnu", TestRunner::Local());
if (runner.name != spec) {
std::println(std::cerr, "FromEnv produced '{}', expected '{}'", runner.name, spec);
return 1;
}
fs::path src = fs::current_path() / "tests" / "QemuUser" / "inner";
Configuration cfg = LoadFixture("QemuUser", src);
RunTestsOptions opts;
TestSummary summary = RunTests(cfg, opts);
if (summary.passed != 1 || summary.failed != 0 || summary.crashed != 0 ||
summary.timedOut != 0 || summary.skipped != 0) {
std::println(std::cerr,
"outcome counts mismatch: passed={} failed={} crashed={} timedOut={} skipped={}",
summary.passed, summary.failed, summary.crashed, summary.timedOut, summary.skipped);
return 1;
}
return 0;
} catch (const std::exception& e) {
std::println(std::cerr, "test exception: {}", e.what());
return 1;
}
}

View file

@ -1,27 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "./";
cfg.name = "qemu-meta";
cfg.outputName = "qemu-meta";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
Test t;
t.config.path = "./";
t.config.name = "Hello";
t.config.outputName = "Hello";
t.config.target = "x86_64-pc-linux-gnu";
t.config.type = ConfigurationType::Executable;
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "tests/Hello" };
t.config.GetInterfacesAndImplementations(ifaces, impls);
t.runner = TestRunner::FromEnv(t.config.target);
cfg.tests.push_back(std::move(t));
return cfg;
}

View file

@ -1,6 +0,0 @@
import std;
int main() {
std::println("hello-from-qemu");
return 0;
}

View file

@ -1,20 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "tests/QemuUser/";
cfg.name = "QemuUser";
cfg.outputName = "QemuUser";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
cfg.dependencies = { ParentLib("crafter.build-lib") };
cfg.linkFlags.push_back("-Wl,--export-dynamic");
cfg.linkFlags.push_back("-ldl");
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "QemuUser" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
return cfg;
}

View file

@ -1,52 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 Catcrafts®
Catcrafts.net
LGPL-3.0-only.
*/
import std;
import Crafter.Build;
#include "../_shared/TestUtil.h"
namespace fs = std::filesystem;
using namespace TestUtil;
using namespace Crafter;
int main() {
try {
const char* hostEnv = std::getenv("CRAFTER_TEST_SSH_HOST");
if (!hostEnv || !*hostEnv) Skip("set CRAFTER_TEST_SSH_HOST to enable");
std::string host = hostEnv;
std::string probe = std::format("ssh -o BatchMode=yes -o ConnectTimeout=5 {} true > /dev/null 2>&1", host);
if (std::system(probe.c_str()) != 0) Skip(std::format("ssh {} not reachable", host));
std::string remoteDir = "/tmp/crafter-test-ssh-runner";
std::string spec = std::format("ssh:{}:{}", host, remoteDir);
::setenv("CRAFTER_BUILD_RUNNER_x86_64_pc_linux_gnu", spec.c_str(), 1);
auto runner = TestRunner::FromEnv("x86_64-pc-linux-gnu", TestRunner::Local());
if (runner.name != std::format("ssh:{}", host)) {
std::println(std::cerr, "FromEnv produced '{}', expected 'ssh:{}'", runner.name, host);
return 1;
}
fs::path src = fs::current_path() / "tests" / "SshRunner" / "inner";
Configuration cfg = LoadFixture("SshRunner", src);
RunTestsOptions opts;
TestSummary summary = RunTests(cfg, opts);
if (summary.passed != 1 || summary.failed != 0 || summary.crashed != 0 ||
summary.timedOut != 0 || summary.skipped != 0) {
std::println(std::cerr,
"outcome counts mismatch: passed={} failed={} crashed={} timedOut={} skipped={}",
summary.passed, summary.failed, summary.crashed, summary.timedOut, summary.skipped);
return 1;
}
return 0;
} catch (const std::exception& e) {
std::println(std::cerr, "test exception: {}", e.what());
return 1;
}
}

View file

@ -1,27 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "./";
cfg.name = "ssh-meta";
cfg.outputName = "ssh-meta";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
Test t;
t.config.path = "./";
t.config.name = "Hello";
t.config.outputName = "Hello";
t.config.target = "x86_64-pc-linux-gnu";
t.config.type = ConfigurationType::Executable;
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "tests/Hello" };
t.config.GetInterfacesAndImplementations(ifaces, impls);
t.runner = TestRunner::FromEnv(t.config.target);
cfg.tests.push_back(std::move(t));
return cfg;
}

View file

@ -1,6 +0,0 @@
import std;
int main() {
std::println("hello-from-ssh");
return 0;
}

View file

@ -1,20 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "tests/SshRunner/";
cfg.name = "SshRunner";
cfg.outputName = "SshRunner";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
cfg.dependencies = { ParentLib("crafter.build-lib") };
cfg.linkFlags.push_back("-Wl,--export-dynamic");
cfg.linkFlags.push_back("-ldl");
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "SshRunner" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
return cfg;
}

View file

@ -13,21 +13,15 @@ int main() {
auto local = TestRunner::FromSpec("local");
if (!local || local->name != "local") return 1;
auto ssh = TestRunner::FromSpec("ssh:somehost");
if (!ssh || ssh->name != "ssh:somehost") return 1;
auto sshWithDir = TestRunner::FromSpec("ssh:somehost:/var/tmp/x");
if (!sshWithDir || sshWithDir->remoteDir != "/var/tmp/x") return 1;
auto sshWin = TestRunner::FromSpec("sshwin:winhost");
if (!sshWin || sshWin->name != "sshwin:winhost") return 1;
// Empty input returns nullopt; bogus prefix throws.
// Empty input returns nullopt; anything else unrecognized throws.
// ssh/sshwin/wsl used to be valid specs; they're now bogus (issue #8).
if (TestRunner::FromSpec("")) return 1;
try {
TestRunner::FromSpec("nonsense:thing");
return 1;
} catch (const std::exception&) {}
for (auto bogus : { "nonsense:thing", "ssh:somehost", "sshwin:winhost", "wsl" }) {
try {
TestRunner::FromSpec(bogus);
return 1;
} catch (const std::exception&) {}
}
return 0;
}

View file

@ -1,68 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 Catcrafts®
Catcrafts.net
LGPL-3.0-only.
End-to-end LinuxWindows via SSH:
the inner fixture cross-compiles main.cpp for x86_64-w64-mingw32, the runner
specified via CRAFTER_BUILD_RUNNER_x86_64_w64_mingw32 scp's it to a Windows
host (winvm by default) and runs the .exe under cmd.exe via ssh. Gated on:
- mingw cross-toolchain installed (x86_64-w64-mingw32-g++)
- CRAFTER_TEST_WIN_SSH_HOST env var set
- the host reachable via ssh
*/
import std;
import Crafter.Build;
#include "../_shared/TestUtil.h"
namespace fs = std::filesystem;
using namespace TestUtil;
using namespace Crafter;
namespace {
bool ToolPresent(std::string_view name) {
return std::system(std::format("which {} > /dev/null 2>&1", name).c_str()) == 0;
}
}
int main() {
try {
const char* hostEnv = std::getenv("CRAFTER_TEST_WIN_SSH_HOST");
if (!hostEnv || !*hostEnv) Skip("set CRAFTER_TEST_WIN_SSH_HOST to enable, e.g. winvm");
std::string host = hostEnv;
if (!ToolPresent("x86_64-w64-mingw32-g++")) Skip("mingw cross-toolchain not on PATH");
std::string probe = std::format("ssh -o BatchMode=yes -o ConnectTimeout=5 {} \"ver\" > /dev/null 2>&1", host);
if (std::system(probe.c_str()) != 0) Skip(std::format("ssh {} not reachable", host));
std::string remoteDir = "C:/temp/crafter-test-winhello";
std::string spec = std::format("sshwin:{}:{}", host, remoteDir);
::setenv("CRAFTER_BUILD_RUNNER_x86_64_w64_mingw32", spec.c_str(), 1);
auto runner = TestRunner::FromEnv("x86_64-w64-mingw32", TestRunner::Local());
if (runner.name != std::format("sshwin:{}", host)) {
std::println(std::cerr, "FromEnv produced '{}', expected 'sshwin:{}'", runner.name, host);
return 1;
}
fs::path src = fs::current_path() / "tests" / "WindowsViaSsh" / "inner";
Configuration cfg = LoadFixture("WindowsViaSsh", src);
RunTestsOptions opts;
TestSummary summary = RunTests(cfg, opts);
if (summary.passed != 1 || summary.failed != 0 || summary.crashed != 0 ||
summary.timedOut != 0 || summary.skipped != 0) {
std::println(std::cerr,
"outcome counts mismatch: passed={} failed={} crashed={} timedOut={} skipped={}",
summary.passed, summary.failed, summary.crashed, summary.timedOut, summary.skipped);
return 1;
}
return 0;
} catch (const std::exception& e) {
std::println(std::cerr, "test exception: {}", e.what());
return 1;
}
}

View file

@ -1,6 +0,0 @@
import std;
int main() {
std::println("hi from windows");
return 0;
}

View file

@ -1,28 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "./";
cfg.name = "winhello-meta";
cfg.outputName = "winhello-meta";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
Test t;
t.config.path = "./";
t.config.name = "winhello";
t.config.outputName = "winhello";
t.config.target = "x86_64-w64-mingw32";
t.config.type = ConfigurationType::Executable;
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "main" };
t.config.GetInterfacesAndImplementations(ifaces, impls);
t.runner = TestRunner::FromEnv(t.config.target);
cfg.tests.push_back(std::move(t));
return cfg;
}

View file

@ -1,20 +0,0 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "tests/WindowsViaSsh/";
cfg.name = "WindowsViaSsh";
cfg.outputName = "WindowsViaSsh";
cfg.target = "x86_64-pc-linux-gnu";
cfg.type = ConfigurationType::Executable;
cfg.dependencies = { ParentLib("crafter.build-lib") };
cfg.linkFlags.push_back("-Wl,--export-dynamic");
cfg.linkFlags.push_back("-ldl");
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "WindowsViaSsh" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
return cfg;
}