[M6] tests: levenshtein + pc_scan + brute_scan + findmodule_scan + last_failure_dir + cmd_linkdb_add + codegen PkgConfig/brute-force

This commit is contained in:
2026-05-15 14:41:17 +00:00
parent 94e658fdf1
commit 65a749f088
9 changed files with 557 additions and 0 deletions

View File

@@ -73,6 +73,37 @@ auto dep_pkg(std::string name, std::string version,
} // namespace
TEST_CASE("flake_nix adds pkgs.pkg-config to nativeBuildInputs only when needed",
"[codegen][flake]") {
Manifest m{pkg("app"), {dep("sqlite", "*")}, {}};
DiscoveredLayout layout{};
Lockfile lock{1, {root_pkg("app", "0.1.0")}};
std::vector<Recipe> recipes = {Recipe{
.nixpkgs_attr = "sqlite",
.find_package = "PkgConfig REQUIRED",
.targets = {"PkgConfig::SQLITE3"},
.source = "pkg-config",
.pkg_config_module = "sqlite3",
}};
GenerateInputs in{m, layout, lock, recipes, {}, "/tmp/app"};
auto out = flake_nix(in);
REQUIRE(out.find("pkgs.pkg-config") != std::string::npos);
REQUIRE(out.find("pkgs.sqlite") != std::string::npos);
}
TEST_CASE("flake_nix omits pkgs.pkg-config when no recipe needs it",
"[codegen][flake]") {
Manifest m{pkg("hello"), {dep("fmt", "*")}, {}};
DiscoveredLayout layout{};
Lockfile lock{1, {root_pkg("hello", "0.1.0")}};
std::vector<Recipe> recipes = {recipe("fmt_10")};
GenerateInputs in{m, layout, lock, recipes, {}, "/tmp/hello"};
auto out = flake_nix(in);
REQUIRE(out.find("pkgs.pkg-config") == std::string::npos);
}
TEST_CASE("flake_nix always emits the shared nixos-unstable nixpkgs input",
"[codegen][flake]") {
Manifest m{pkg("hello"), {}, {}};