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>
90 lines
3.2 KiB
C++
90 lines
3.2 KiB
C++
import std;
|
|
import Crafter.Build;
|
|
namespace fs = std::filesystem;
|
|
using namespace Crafter;
|
|
|
|
// Two-config build: an exe linked against a sibling static library via
|
|
// cfg.dependencies. Exercises cross-config module import resolution (the
|
|
// exe imports Calc, which is defined in the lib's interface set) and the
|
|
// dep-archive linking step.
|
|
int main() {
|
|
fs::path fixtureRoot = fs::current_path() / "tests" / "DependencyLink" / "fixture";
|
|
|
|
auto lib = std::make_unique<Configuration>();
|
|
lib->path = fixtureRoot / "mathlib";
|
|
lib->name = "calc";
|
|
lib->outputName = "calc";
|
|
lib->target = HostTarget();
|
|
lib->type = ConfigurationType::LibraryStatic;
|
|
{
|
|
std::array<fs::path, 1> ifaces = { "Calc" };
|
|
std::array<fs::path, 0> impls = {};
|
|
lib->GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
|
|
Configuration app;
|
|
app.path = fixtureRoot;
|
|
app.name = "calc-app";
|
|
app.outputName = "calc-app";
|
|
app.target = HostTarget();
|
|
app.type = ConfigurationType::Executable;
|
|
app.dependencies = { lib.get() };
|
|
{
|
|
std::array<fs::path, 0> ifaces = {};
|
|
std::array<fs::path, 1> impls = { "main" };
|
|
app.GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
|
|
if (app.implementations.size() != 1) {
|
|
std::println(std::cerr, "expected 1 implementation, got {}", app.implementations.size());
|
|
return 1;
|
|
}
|
|
// The import resolves to the dependency's interface, not a local one.
|
|
if (!app.implementations[0].moduleDependencies.empty()) {
|
|
std::println(std::cerr, "expected no local module deps, got {}",
|
|
app.implementations[0].moduleDependencies.size());
|
|
return 1;
|
|
}
|
|
if (app.implementations[0].externalModuleDependencies.size() != 1) {
|
|
std::println(std::cerr, "expected 1 external module dep, got {}",
|
|
app.implementations[0].externalModuleDependencies.size());
|
|
return 1;
|
|
}
|
|
if (app.implementations[0].externalModuleDependencies[0].first->name != "Calc") {
|
|
std::println(std::cerr, "expected external dep 'Calc', got '{}'",
|
|
app.implementations[0].externalModuleDependencies[0].first->name);
|
|
return 1;
|
|
}
|
|
|
|
std::unordered_map<fs::path, std::shared_future<BuildResult>> depResults;
|
|
std::mutex depMutex;
|
|
BuildResult r = Build(app, depResults, depMutex);
|
|
if (!r.result.empty()) {
|
|
std::println(std::cerr, "build failed: {}", r.result);
|
|
return 1;
|
|
}
|
|
|
|
fs::path libArchive = lib->BinDir() / "libcalc.a";
|
|
if (!fs::exists(libArchive)) {
|
|
std::println(std::cerr, "dep archive not produced at {}", libArchive.string());
|
|
return 1;
|
|
}
|
|
|
|
fs::path bin = app.BinDir() / "calc-app";
|
|
if (!fs::exists(bin)) {
|
|
std::println(std::cerr, "binary not produced at {}", bin.string());
|
|
return 1;
|
|
}
|
|
|
|
auto run = RunCommandWithTimeout(bin.string(), std::chrono::seconds(10));
|
|
if (run.exitCode != 0 || run.timedOut || run.crashed) {
|
|
std::println(std::cerr, "exe did not exit cleanly: exit={} output={}",
|
|
run.exitCode, run.output);
|
|
return 1;
|
|
}
|
|
if (run.output != "7") {
|
|
std::println(std::cerr, "expected '7', got '{}'", run.output);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|