[M6] tests: levenshtein + pc_scan + brute_scan + findmodule_scan + last_failure_dir + cmd_linkdb_add + codegen PkgConfig/brute-force
This commit is contained in:
@@ -342,3 +342,70 @@ TEST_CASE("cmake_lists threads dev_recipes through find_package and tests",
|
||||
auto block = out.substr(link, end - link);
|
||||
REQUIRE(block.find("Catch2::Catch2WithMain") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("cmake_lists emits pkg_check_modules for pkg_config recipes",
|
||||
"[codegen][cmake]") {
|
||||
Manifest m{
|
||||
.package = pkg("app"),
|
||||
.dependencies = {{.name = "sqlite", .version_spec = "*"}},
|
||||
};
|
||||
DiscoveredLayout layout{
|
||||
.library = std::nullopt,
|
||||
.binaries = {src_target(TargetKind::Binary, "app", "src/main.cpp")},
|
||||
.tests = {},
|
||||
.examples = {},
|
||||
};
|
||||
Lockfile lock = lock_minimal();
|
||||
Recipe sqlite{
|
||||
.nixpkgs_attr = "sqlite",
|
||||
.find_package = "PkgConfig REQUIRED",
|
||||
.targets = {"PkgConfig::SQLITE3"},
|
||||
.source = "pkg-config",
|
||||
.pkg_config_module = "sqlite3",
|
||||
};
|
||||
GenerateInputs in{m, layout, lock, {sqlite}, {}, ROOT};
|
||||
|
||||
auto out = cmake_lists(in);
|
||||
REQUIRE(out.find("find_package(PkgConfig REQUIRED)") != std::string::npos);
|
||||
REQUIRE(out.find("pkg_check_modules(SQLITE3 REQUIRED IMPORTED_TARGET sqlite3)") !=
|
||||
std::string::npos);
|
||||
auto link = out.find("target_link_libraries(app_bin PRIVATE");
|
||||
REQUIRE(link != std::string::npos);
|
||||
auto block = out.substr(link, out.find(')', link) - link);
|
||||
REQUIRE(block.find("PkgConfig::SQLITE3") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("cmake_lists synthesizes INTERFACE IMPORTED target for brute-force "
|
||||
"recipes",
|
||||
"[codegen][cmake]") {
|
||||
Manifest m{
|
||||
.package = pkg("app"),
|
||||
.dependencies = {{.name = "obscure", .version_spec = "*"}},
|
||||
};
|
||||
DiscoveredLayout layout{
|
||||
.library = std::nullopt,
|
||||
.binaries = {src_target(TargetKind::Binary, "app", "src/main.cpp")},
|
||||
.tests = {},
|
||||
.examples = {},
|
||||
};
|
||||
Lockfile lock = lock_minimal();
|
||||
Recipe brute{
|
||||
.nixpkgs_attr = "obscure",
|
||||
.find_package = "",
|
||||
.targets = {"obscure::obscure"},
|
||||
.source = "brute-force",
|
||||
.brute_force_libs = {"/nix/store/abc-obscure/lib/libobscure.a"},
|
||||
.brute_force_includes = {"/nix/store/abc-obscure/include"},
|
||||
};
|
||||
GenerateInputs in{m, layout, lock, {brute}, {}, ROOT};
|
||||
|
||||
auto out = cmake_lists(in);
|
||||
REQUIRE(out.find("add_library(obscure::obscure INTERFACE IMPORTED)") !=
|
||||
std::string::npos);
|
||||
REQUIRE(out.find("INTERFACE_LINK_LIBRARIES") != std::string::npos);
|
||||
REQUIRE(out.find("/nix/store/abc-obscure/lib/libobscure.a") !=
|
||||
std::string::npos);
|
||||
REQUIRE(out.find("INTERFACE_INCLUDE_DIRECTORIES") != std::string::npos);
|
||||
REQUIRE(out.find("/nix/store/abc-obscure/include") != std::string::npos);
|
||||
REQUIRE(out.find("find_package()") == std::string::npos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user