mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
tests: fix negative asserts with grep
not working
Using `grep -v` without `-z` will return 0 even if there is a match found as all the non-matching lines will be matched. Instead of using `grep -vqz`, `(! grep ...)` is more readable. The brackets are necessary as `! grep` will not trigger `set -e`[0], so we run it inside a subshell to use its non-zero exit code. [0]: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin
This commit is contained in:
parent
2eb472230a
commit
fd6660cb91
3 changed files with 11 additions and 11 deletions
|
@ -118,7 +118,7 @@ stdenv.mkDerivation {
|
|||
test -e /etc/static
|
||||
echo >&2 "checking profile"
|
||||
cat /etc/profile
|
||||
grep -v nix-daemon.sh /etc/profile
|
||||
(! grep nix-daemon.sh /etc/profile)
|
||||
echo >&2 "checking /run/current-system"
|
||||
readlink /run
|
||||
test -e /run
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
echo >&2 "checking compinit in /etc/zshrc"
|
||||
grep 'autoload -U compinit && compinit' ${config.out}/etc/zshrc
|
||||
echo >&2 "checking bashcompinit in /etc/zshrc"
|
||||
grep -vq 'bashcompinit' ${config.out}/etc/zshrc
|
||||
(! grep 'bashcompinit' ${config.out}/etc/zshrc)
|
||||
|
||||
echo >&2 "checking zprofile.d in /etc/zprofile"
|
||||
grep 'source /etc/zprofile.d/\*.conf' ${config.out}/etc/zprofile
|
||||
|
|
|
@ -28,37 +28,37 @@
|
|||
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} PrimaryGroupID 42000" ${config.out}/activate
|
||||
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} RealName ${lib.escapeShellArg "Foo group"}" ${config.out}/activate
|
||||
grep "dscl . -create ${lib.escapeShellArg "/Groups/created.group"} PrimaryGroupID 42001" ${config.out}/activate
|
||||
grep -qv "dscl . -delete ${lib.escapeShellArg "/Groups/created.group"}" ${config.out}/activate
|
||||
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/created.group"}" ${config.out}/activate)
|
||||
|
||||
# checking group deletion in /activate
|
||||
grep "dscl . -delete ${lib.escapeShellArg "/Groups/deleted.group"}" ${config.out}/activate
|
||||
grep -qv "dscl . -create ${lib.escapeShellArg "/Groups/deleted.group"}" ${config.out}/activate
|
||||
(! grep "dscl . -create ${lib.escapeShellArg "/Groups/deleted.group"}" ${config.out}/activate)
|
||||
|
||||
echo "checking group membership in /activate" >&2
|
||||
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} GroupMembership ${lib.escapeShellArgs [ "admin" "foo" ]}" ${config.out}/activate
|
||||
grep "dscl . -create ${lib.escapeShellArg "/Groups/created.group"} GroupMembership" ${config.out}/activate
|
||||
|
||||
# checking unknown group in /activate
|
||||
grep -qv "dscl . -create ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate
|
||||
grep -qv "dscl . -delete ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate
|
||||
(! grep "dscl . -create ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate)
|
||||
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate)
|
||||
|
||||
# checking user creation in /activate
|
||||
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "foo" "-UID" 42000 "-GID" 42000 "-fullName" "Foo user" "-home" "/Users/foo" "-shell" "/run/current-system/sw/bin/bash" ]}" ${config.out}/activate
|
||||
grep "createhomedir -cu ${lib.escapeShellArg "foo"}" ${config.out}/activate
|
||||
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "created.user" "-UID" 42001 ]} .* ${lib.escapeShellArgs [ "-shell" "/sbin/nologin" ]}" ${config.out}/activate
|
||||
grep -qv "deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
|
||||
grep -qv "deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
|
||||
(! grep "deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate)
|
||||
(! grep "deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate)
|
||||
|
||||
# checking user properties always get updated in /activate
|
||||
grep "dscl . -create ${lib.escapeShellArg "/Users/foo"} UserShell ${lib.escapeShellArg "/run/current-system/sw/bin/bash"}" ${config.out}/activate
|
||||
|
||||
# checking user deletion in /activate
|
||||
grep "deleteUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate
|
||||
grep -qv "sysadminctl -addUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate
|
||||
(! grep "sysadminctl -addUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate)
|
||||
|
||||
# checking unknown user in /activate
|
||||
grep -qv "sysadminctl -addUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate
|
||||
grep -qv "deleteUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate
|
||||
(! grep "sysadminctl -addUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate)
|
||||
(! grep "deleteUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate)
|
||||
|
||||
set +v
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue