test: migrate cross-arch tests to declarative test.toml; add WindowsViaWine
Collapses three outer-driver tests into declarative top-level fixtures:
- CrossArchAarch64: outer + inner pair becomes main.cpp + test.toml. The
'is this really an ARM aarch64 ELF?' artifact-introspection check is
dropped — qemu-aarch64 refuses to run wrong-arch ELFs anyway, so a
silent host-arch fallback would still fail the run.
- Wasi: outer + inner pair becomes main.cpp + test.toml. The WASM
magic-byte check is dropped on the same logic (wasmtime refuses
non-WASM input).
- Defines: simple defines-propagation smoke test becomes test.toml with
[defines] CRAFTER_TEST_FOO = "42".
Adds WindowsViaWine to replace the (forthcoming-deletion) WindowsViaSsh:
declarative target=x86_64-w64-mingw32 + requires=[tool:wine,
tool:x86_64-w64-mingw32-g++]. Exercises the new Wine runner and the
ForTarget derivation end-to-end.
Diamond and CrossProjectModule had speculative --target= reading that
made them attempt cross-compilation under the multi-target sweep. They
have no sysroot/toolchain plumbing, so those cross-builds always fail.
Hardcoded them to HostTarget(); cross-arch tests live in their own
test.toml from now on.
Refs issue #8.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dc27c5c204
commit
406a406420
16 changed files with 50 additions and 238 deletions
|
|
@ -1,44 +0,0 @@
|
|||
import std;
|
||||
import Crafter.Build;
|
||||
#include "../_shared/TestUtil.h"
|
||||
namespace fs = std::filesystem;
|
||||
using namespace TestUtil;
|
||||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
try {
|
||||
if (!fs::exists("/usr/share/wasi-sysroot/share/libc++/v1/std.cppm")) {
|
||||
Skip("WASI sysroot/libc++ missing — install wasi-libc, wasi-libc++, wasi-libc++abi");
|
||||
}
|
||||
|
||||
fs::path src = fs::current_path() / "tests" / "Wasi" / "inner";
|
||||
Configuration cfg = LoadFixture("Wasi", src);
|
||||
fs::path work = fs::current_path();
|
||||
|
||||
auto br = BuildOnce(cfg);
|
||||
if (!br.result.empty()) {
|
||||
std::println(std::cerr, "build failed:\n{}", br.result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fs::path artifact = cfg.BinDir() / "wasi-hello.wasm";
|
||||
if (!fs::exists(artifact)) {
|
||||
std::println(std::cerr, "expected artifact missing at {}", artifact.string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Verify WASM magic bytes: \0asm
|
||||
std::ifstream f(artifact, std::ios::binary);
|
||||
char magic[4] = {};
|
||||
f.read(magic, 4);
|
||||
if (magic[0] != '\0' || magic[1] != 'a' || magic[2] != 's' || magic[3] != 'm') {
|
||||
std::println(std::cerr, "artifact is not a valid WASM file (bad magic bytes)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::println(std::cerr, "test exception: {}", e.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +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 = "wasi-hello";
|
||||
cfg.outputName = "wasi-hello";
|
||||
cfg.target = "wasm32-wasip1";
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
|
||||
std::array<fs::path, 0> ifaces = {};
|
||||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
|
@ -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/Wasi/";
|
||||
cfg.name = "Wasi";
|
||||
cfg.outputName = "Wasi";
|
||||
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 = { "Wasi" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
return cfg;
|
||||
}
|
||||
7
tests/Wasi/test.toml
Normal file
7
tests/Wasi/test.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# WASI build via the WASI SDK's libc++ + the wasm32-wasip1 target. The
|
||||
# runner derivation routes the .wasm artifact through `wasmtime`.
|
||||
target = "wasm32-wasip1"
|
||||
requires = [
|
||||
"tool:wasmtime",
|
||||
"file:/usr/share/wasi-sysroot/share/libc++/v1/std.cppm",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue