[M5+] resolve_version + cmd_add lockfile pin
This commit is contained in:
@@ -12,6 +12,14 @@ namespace manifest = cargoxx::manifest;
|
||||
|
||||
namespace {
|
||||
|
||||
// Disable resolve_version for the whole TU — these unit tests don't
|
||||
// want to hit search.devbox.sh or clone nixpkgs. Individual cases that
|
||||
// actually want to test the network path still set the env locally.
|
||||
struct DisableAutoResolveScope {
|
||||
DisableAutoResolveScope() { setenv("CARGOXX_NO_AUTORESOLVE", "1", 1); }
|
||||
};
|
||||
const DisableAutoResolveScope autoresolve_disabled_;
|
||||
|
||||
auto fresh_dir() -> std::filesystem::path {
|
||||
auto d = std::filesystem::temp_directory_path() /
|
||||
std::format("cargoxx-add-test-{}", std::random_device{}());
|
||||
@@ -80,9 +88,7 @@ TEST_CASE("cmd_add with wildcard version still rejects unknown packages",
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
|
||||
setenv("CARGOXX_NO_AUTORESOLVE", "1", /*overwrite=*/1);
|
||||
auto r = cmd_add(root, "obscurelib", "", {}, overlay_path(parent));
|
||||
unsetenv("CARGOXX_NO_AUTORESOLVE");
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == ErrorCode::LinkdbUnknownPackage);
|
||||
}
|
||||
@@ -91,11 +97,7 @@ TEST_CASE("cmd_add rejects an unknown package", "[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
|
||||
// Disable the auto-resolution chain — keeps the unit test fast and
|
||||
// independent of nixpkgs / Conan / vcpkg availability.
|
||||
setenv("CARGOXX_NO_AUTORESOLVE", "1", /*overwrite=*/1);
|
||||
auto r = cmd_add(root, "obscurelib", "0.0.1", {}, overlay_path(parent));
|
||||
unsetenv("CARGOXX_NO_AUTORESOLVE");
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == ErrorCode::LinkdbUnknownPackage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user