[M5+] nix_cmake_scan filters Find*.cmake shims and picks public targets
This commit is contained in:
@@ -5,6 +5,7 @@ import cargoxx.util;
|
||||
import std;
|
||||
|
||||
using cargoxx::resolver::config_stem_to_package;
|
||||
using cargoxx::resolver::filter_public_targets;
|
||||
using cargoxx::resolver::nix_cmake_scan;
|
||||
using cargoxx::resolver::scan_imported_targets;
|
||||
using cargoxx::util::ErrorCode;
|
||||
@@ -64,6 +65,36 @@ TEST_CASE("scan_imported_targets does not match _add_library or similar",
|
||||
REQUIRE(out.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("filter_public_targets keeps namespaced targets when present",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
auto out = filter_public_targets(
|
||||
{"fmt::fmt", "fmt::fmt-header-only", "fmt_internal_helper"}, "fmt");
|
||||
REQUIRE(out == std::vector<std::string>{"fmt::fmt", "fmt::fmt-header-only"});
|
||||
}
|
||||
|
||||
TEST_CASE("filter_public_targets picks the umbrella when no targets are namespaced",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Mirrors LLVMExports: 213 bare targets, only `LLVM` is the
|
||||
// intended downstream entry point.
|
||||
auto out = filter_public_targets(
|
||||
{"LLVM", "LLVMSupport", "LLVMCore", "LLVMWindowsManifest"}, "LLVM");
|
||||
REQUIRE(out == std::vector<std::string>{"LLVM"});
|
||||
}
|
||||
|
||||
TEST_CASE("filter_public_targets is case-insensitive when picking the umbrella",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
auto out = filter_public_targets({"GRPC", "grpc_internal"}, "gRPC");
|
||||
REQUIRE(out == std::vector<std::string>{"GRPC"});
|
||||
}
|
||||
|
||||
TEST_CASE("filter_public_targets keeps everything when no umbrella matches",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Stem doesn't match any bare target — fall back to passthrough so
|
||||
// we still emit a non-empty link line.
|
||||
auto out = filter_public_targets({"alpha", "beta", "gamma"}, "Whatever");
|
||||
REQUIRE(out == std::vector<std::string>{"alpha", "beta", "gamma"});
|
||||
}
|
||||
|
||||
TEST_CASE("scan_imported_targets dedupes duplicate target names",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
constexpr std::string_view text = R"(
|
||||
|
||||
Reference in New Issue
Block a user