aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-06-10 17:04:54 -0700
committerJade Lovelace <lix@jade.fyi>2024-06-12 15:34:23 -0700
commitd9345d8836d295a205eab19ce9e969bcc9a35b42 (patch)
tree252c63f3217115ed947c2167faaf658328316764 /tests
parent6939ffc9f9b23878d5960dabd92a7884feec689b (diff)
tests: verify that NIX_DAEMON_PACKAGE's version looks like a version
Followup to https://gerrit.lix.systems/c/lix/+/1417 to ensure that this parser will never take something that doesn't look like a version. It turns out this problem is less alarming than initially thought because it only applies to the testsuite in a non-default mode. Change-Id: I26aba24aaf0215f2b782966314b94784db766266
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/common/vars-and-functions.sh.in14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/functional/common/vars-and-functions.sh.in b/tests/functional/common/vars-and-functions.sh.in
index bd1990973..bfc4fbc44 100644
--- a/tests/functional/common/vars-and-functions.sh.in
+++ b/tests/functional/common/vars-and-functions.sh.in
@@ -144,11 +144,15 @@ if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true
fi
isDaemonNewer () {
- [[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0
- local requiredVersion="$1"
- local versionOutput=$($NIX_DAEMON_PACKAGE/bin/nix daemon --version)
- local daemonVersion=${versionOutput##* }
- [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
+ [[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0
+ local requiredVersion="$1"
+ local versionOutput
+ versionOutput=$("$NIX_DAEMON_PACKAGE/bin/nix" daemon --version)
+ local daemonVersion=${versionOutput##* }
+ if [[ ! $daemonVersion =~ [[:digit:]]+\.[[:digit:]]+\..* ]]; then
+ fail "Daemon version '$daemonVersion' does not look plausible, this is a testsuite bug!"
+ fi
+ [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
}
skipTest () {