All checks were successful
CI / build-test-release (pull_request) Successful in 7m26s
The suite had only HelloWorld, which built and exited an empty exe. Add in-process tests covering each public surface area users actually touch: - StaticLib / ModuleInterface / DependencyLink — Build() against fixtures for libraries, project-local module interfaces, and cross-config module deps with link verification (runs the built exe). - ShaderCompile — drives Shader::Compile directly, validates SPIR-V magic + Check() idempotency. - StandardArgs — covers --debug, --target=, --march=, --mtune=, --lib/--shared promotions, and ArgQuery::Has / Get. - TestRunnerSpec — FromSpec parse rules, ForTarget routing for host, wasm32-wasip1, aarch64-linux-gnu (+ sysroot QEMU_LD_PREFIX), i686 → qemu-i386 rewrite, mingw → wine on Linux hosts, FromEnv. - VariantId — confirms type / debug / sysroot / defines / compileFlags / target / march all perturb the cache key, plus PcmDir routing. - WasiBrowserRuntime — calls EnableWasiBrowserRuntime, asserts the three cfg.files entries get registered and index.html had its template placeholder substituted. - RunSingleTestExit — drives RunSingleTest against tiny sh scripts and pins the documented exit-code mapping (0/77/non-zero) and the Cmd-prefix runner path. Closes #12. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
75 lines
2.9 KiB
C++
75 lines
2.9 KiB
C++
import std;
|
|
import Crafter.Build;
|
|
using namespace Crafter;
|
|
|
|
namespace {
|
|
int failures = 0;
|
|
|
|
void Check(bool cond, std::string_view msg) {
|
|
if (!cond) {
|
|
std::println(std::cerr, "FAIL: {}", msg);
|
|
++failures;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pure-data tests for ApplyStandardArgs and ArgQuery — no build/run, just
|
|
// confirms the documented arg parsing produces the documented mutations.
|
|
int main() {
|
|
// --debug + --target= + --march= + --mtune=
|
|
{
|
|
Configuration cfg;
|
|
cfg.target = "ignored";
|
|
std::array<std::string_view, 4> raw = {
|
|
"--debug", "--target=aarch64-linux-gnu", "--march=armv8-a", "--mtune=cortex-a72",
|
|
};
|
|
ApplyStandardArgs(cfg, raw);
|
|
Check(cfg.debug, "--debug should set cfg.debug");
|
|
Check(cfg.target == "aarch64-linux-gnu", "--target= should overwrite cfg.target");
|
|
Check(cfg.march == "armv8-a", "--march= should overwrite cfg.march");
|
|
Check(cfg.mtune == "cortex-a72", "--mtune= should overwrite cfg.mtune");
|
|
}
|
|
|
|
// --lib promotes Executable -> LibraryStatic; --shared then promotes to Dynamic.
|
|
{
|
|
Configuration cfg;
|
|
cfg.type = ConfigurationType::Executable;
|
|
std::array<std::string_view, 1> raw = { "--lib" };
|
|
ApplyStandardArgs(cfg, raw);
|
|
Check(cfg.type == ConfigurationType::LibraryStatic, "--lib promotes Exe -> Static");
|
|
}
|
|
{
|
|
Configuration cfg;
|
|
cfg.type = ConfigurationType::Executable;
|
|
// Order shouldn't matter — promotions chain in priority order.
|
|
std::array<std::string_view, 2> raw = { "--shared", "--lib" };
|
|
ApplyStandardArgs(cfg, raw);
|
|
Check(cfg.type == ConfigurationType::LibraryDynamic, "--lib + --shared lands on Dynamic regardless of order");
|
|
}
|
|
{
|
|
Configuration cfg;
|
|
cfg.type = ConfigurationType::Executable;
|
|
std::array<std::string_view, 1> raw = { "--shared" };
|
|
ApplyStandardArgs(cfg, raw);
|
|
Check(cfg.type == ConfigurationType::Executable, "--shared alone on Executable is a no-op");
|
|
}
|
|
|
|
// ArgQuery is returned over the same args span and exposes Has/Get.
|
|
{
|
|
Configuration cfg;
|
|
std::array<std::string_view, 3> raw = { "--timing", "--prefix=/opt/x", "extra" };
|
|
ArgQuery q = ApplyStandardArgs(cfg, raw);
|
|
Check(q.Has("--timing"), "ArgQuery::Has true for present flag");
|
|
Check(!q.Has("--missing"), "ArgQuery::Has false for absent flag");
|
|
auto prefix = q.Get("--prefix=");
|
|
Check(prefix.has_value(), "ArgQuery::Get returns a value for known prefix");
|
|
Check(prefix.value_or("") == "/opt/x", "ArgQuery::Get returns the substring after =");
|
|
Check(!q.Get("--other=").has_value(), "ArgQuery::Get returns nullopt for absent prefix");
|
|
}
|
|
|
|
if (failures > 0) {
|
|
std::println(std::cerr, "{} assertions failed", failures);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|