46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
|
|
/*
|
||
|
|
Crafter® Build
|
||
|
|
Copyright (C) 2026 Catcrafts®
|
||
|
|
Catcrafts.net
|
||
|
|
|
||
|
|
LGPL-3.0-only.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import std;
|
||
|
|
#include "TestUtil.h"
|
||
|
|
namespace fs = std::filesystem;
|
||
|
|
using namespace TestUtil;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
try {
|
||
|
|
fs::path projectRoot = fs::current_path();
|
||
|
|
fs::path src = projectRoot / "tests" / "fixtures" / "build-error";
|
||
|
|
fs::path crafterBuild = projectRoot / "bin" / "crafter-build";
|
||
|
|
|
||
|
|
fs::path work = CopyFixtureToTemp("BuildError", src);
|
||
|
|
|
||
|
|
auto build = RunInDir(work, std::format("'{}'", crafterBuild.string()));
|
||
|
|
if (build.exitCode == 0) {
|
||
|
|
std::println(std::cerr, "expected nonzero exit, got 0; build output:\n{}", build.output);
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// diagnostic must surface the unresolved name; fragile-ish but recognizable
|
||
|
|
if (build.output.find("undefined_symbol_xyzzy_oqv") == std::string::npos) {
|
||
|
|
std::println(std::cerr, "diagnostic missing unresolved-name reference:\n{}", build.output);
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// and the artifact must NOT have been produced
|
||
|
|
fs::path artifact = work / "bin" / "broken-x86_64-pc-linux-gnu-native" / "broken";
|
||
|
|
if (fs::exists(artifact)) {
|
||
|
|
std::println(std::cerr, "artifact unexpectedly produced at {}", artifact.string());
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
} catch (const std::exception& e) {
|
||
|
|
std::println(std::cerr, "test exception: {}", e.what());
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
}
|