diff --git a/tests/common.sh.in b/tests/common.sh.in index 979b68e15..21f633607 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -121,6 +121,13 @@ if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true _canUseSandbox=1 fi +isDaemonOlder () { + [[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0 + local requiredVersion="$1" + local daemonVersion=$($NIX_DAEMON_PACKAGE/bin/nix-daemon --version | cut -d' ' -f3) + [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -lt 0 ]] +} + isDaemonNewer () { [[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0 local requiredVersion="$1" @@ -128,6 +135,10 @@ isDaemonNewer () { [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]] } +requireDaemonOlderThan () { + isDaemonOlder "$1" || exit 99 +} + requireDaemonNewerThan () { isDaemonNewer "$1" || exit 99 } diff --git a/tests/structured-attrs.sh b/tests/structured-attrs.sh index fcc00c4e0..e5018e15b 100644 --- a/tests/structured-attrs.sh +++ b/tests/structured-attrs.sh @@ -1,8 +1,8 @@ source common.sh # 27ce722638 required some incompatible changes to the nix file, so skip this -# tests for the older versions -requireDaemonNewerThan "2.4pre20210622" +# tests for the newer versions +requireDaemonOlderThan "2.4pre20210622" clearStore