Crafter.Build/tests/Diamond/project.cpp
Jorijn van der Graaf 406a406420 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>
2026-05-27 18:01:49 +02:00

50 lines
1.9 KiB
C++

import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
namespace {
std::unique_ptr<Configuration> MakeLib(std::string_view dir, std::string_view modName,
std::string_view target,
std::span<Configuration*> deps) {
auto lib = std::make_unique<Configuration>();
lib->path = std::format("tests/Diamond/{}/", dir);
lib->name = std::format("{}-Diamond-{}", modName, target);
lib->outputName = std::string(modName);
lib->target = std::string(target);
lib->type = ConfigurationType::LibraryStatic;
lib->dependencies.assign(deps.begin(), deps.end());
std::array<fs::path, 1> ifaces = { fs::path(modName) };
std::array<fs::path, 0> impls = {};
lib->GetInterfacesAndImplementations(ifaces, impls);
return lib;
}
}
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
// Diamond exercises the build engine's dependency wiring at the host
// target. There's no cross-compile plumbing (no sysroot, no per-target
// toolchain), so we don't honor --target=. A real cross-arch test would
// live in its own tests/<Name>/test.toml.
std::string target = HostTarget();
static std::unique_ptr<Configuration> X, B, C;
X = MakeLib("X", "X", target, {});
Configuration* xDeps[] = { X.get() };
B = MakeLib("B", "B", target, xDeps);
C = MakeLib("C", "C", target, xDeps);
Configuration* mainDeps[] = { B.get(), C.get() };
Configuration cfg;
cfg.path = "tests/Diamond/";
cfg.name = "Diamond";
cfg.outputName = "diamond-app";
cfg.target = target;
cfg.type = ConfigurationType::Executable;
cfg.dependencies.assign(mainDeps, mainDeps + 2);
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "main" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
return cfg;
}