mirror of
https://github.com/NixOS/nix
synced 2025-07-07 22:33:57 +02:00
Merge pull request #10166 from bobvanderlinden/profile-regex-all
profile: introduce --regex and --all
This commit is contained in:
commit
ae2bd460a8
6 changed files with 252 additions and 76 deletions
|
@ -74,10 +74,49 @@ nix profile upgrade flake1
|
|||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello NixOS" ]]
|
||||
nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 2.0, 2.0-man"
|
||||
|
||||
# Test upgrading package using regular expression.
|
||||
printf 2.1 > $flake1Dir/version
|
||||
nix profile upgrade --regex '.*'
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.1/bin/hello ]]
|
||||
nix profile rollback
|
||||
|
||||
# Test upgrading all packages
|
||||
printf 2.2 > $flake1Dir/version
|
||||
nix profile upgrade --all
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.2/bin/hello ]]
|
||||
nix profile rollback
|
||||
printf 1.0 > $flake1Dir/version
|
||||
|
||||
# Test --all exclusivity.
|
||||
assertStderr nix --offline profile upgrade --all foo << EOF
|
||||
error: --all cannot be used with package names or regular expressions.
|
||||
Try 'nix --help' for more information.
|
||||
EOF
|
||||
|
||||
# Test matching no packages using literal package name.
|
||||
assertStderr nix --offline profile upgrade this_package_is_not_installed << EOF
|
||||
warning: Package name 'this_package_is_not_installed' does not match any packages in the profile.
|
||||
warning: No packages to upgrade. Use 'nix profile list' to see the current profile.
|
||||
EOF
|
||||
|
||||
# Test matching no packages using regular expression.
|
||||
assertStderr nix --offline profile upgrade --regex '.*unknown_package.*' << EOF
|
||||
warning: Regex '.*unknown_package.*' does not match any packages in the profile.
|
||||
warning: No packages to upgrade. Use 'nix profile list' to see the current profile.
|
||||
EOF
|
||||
|
||||
# Test removing all packages using regular expression.
|
||||
nix profile remove --regex '.*' 2>&1 | grep "removed 2 packages, kept 0 packages"
|
||||
nix profile rollback
|
||||
|
||||
# Test 'history', 'diff-closures'.
|
||||
nix profile diff-closures
|
||||
|
||||
# Test rollback.
|
||||
printf World > $flake1Dir/who
|
||||
nix profile upgrade flake1
|
||||
printf NixOS > $flake1Dir/who
|
||||
nix profile upgrade flake1
|
||||
nix profile rollback
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue