This commit is contained in:
parent
725910eb9c
commit
603840879d
11 changed files with 283 additions and 18235 deletions
2
tests/HelloWorld/fixture/main.cpp
Normal file
2
tests/HelloWorld/fixture/main.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import std;
|
||||
int main() { return 0; }
|
||||
39
tests/HelloWorld/main.cpp
Normal file
39
tests/HelloWorld/main.cpp
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue