new tests
All checks were successful
CI / build-test-release (push) Successful in 1h4m52s

This commit is contained in:
Jorijn van der Graaf 2026-05-27 19:45:05 +02:00
commit 603840879d
11 changed files with 283 additions and 18235 deletions

39
tests/HelloWorld/main.cpp Normal file
View file

@ -0,0 +1,39 @@
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
// Smoke test for the local Crafter.Build library: construct a Configuration
// for the fixture/ subdir, call Build() in-process, and assert the binary
// was produced. The build engine being exercised here is whatever this
// test exe was statically linked against — which, via the parent
// project.cpp's .Dependencies({ crafterBuildLib.get() }), is the local
// checkout's library form. Edits to implementations/*.cpp show up here on
// the next test run with no install step required.
int main() {
Configuration cfg;
cfg.path = fs::current_path() / "tests" / "HelloWorld" / "fixture";
cfg.name = "hello";
cfg.outputName = "hello";
cfg.target = HostTarget();
cfg.type = ConfigurationType::Executable;
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "main" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
std::unordered_map<fs::path, std::shared_future<BuildResult>> depResults;
std::mutex depMutex;
BuildResult r = Build(cfg, depResults, depMutex);
if (!r.result.empty()) {
std::println(std::cerr, "build failed: {}", r.result);
return 1;
}
fs::path bin = cfg.BinDir() / "hello";
if (!fs::exists(bin)) {
std::println(std::cerr, "binary not produced at {}", bin.string());
return 1;
}
return 0;
}