All checks were successful
CI / build-test-release (push) Successful in 1h4m52s
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
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;
|
|
}
|