Skip to content

Commit

Permalink
Functional Test for builtins.storeDir and builtins.currentSystem
Browse files Browse the repository at this point in the history
These were under-tested. This tests the status quo and especially
previous commit of this PR better.
  • Loading branch information
Ericson2314 committed Dec 15, 2023
1 parent bcbdb09 commit 70f50cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/functional/impure-eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
source common.sh

export REMOTE_STORE="dummy://"

simpleTest () {
local expr=$1; shift
local result=$1; shift
# rest, extra args

[[ "$(nix eval --impure --raw "$@" --expr "$expr")" == "$result" ]]
}

# `builtins.storeDir`

## Store dir follows `store` store setting
simpleTest 'builtins.storeDir' '/foo' --store "$REMOTE_STORE?store=/foo"
simpleTest 'builtins.storeDir' '/bar' --store "$REMOTE_STORE?store=/bar"

# `builtins.currentSystem`

## `system` alone affects by default
simpleTest 'builtins.currentSystem' 'foo' --system 'foo'
simpleTest 'builtins.currentSystem' 'bar' --system 'bar'

## `system` affects if `eval-system` is an empty string
simpleTest 'builtins.currentSystem' 'foo' --system 'foo' --eval-system ''
simpleTest 'builtins.currentSystem' 'bar' --system 'bar' --eval-system ''

## `eval-system` alone affects
simpleTest 'builtins.currentSystem' 'foo' --eval-system 'foo'
simpleTest 'builtins.currentSystem' 'bar' --eval-system 'bar'

## `eval-system` overrides `system`
simpleTest 'builtins.currentSystem' 'bar' --system 'foo' --eval-system 'bar'
simpleTest 'builtins.currentSystem' 'baz' --system 'foo' --eval-system 'baz'
1 change: 1 addition & 0 deletions tests/functional/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ nix_tests = \
build-remote-trustless-should-fail-0.sh \
build-remote-with-mounted-ssh-ng.sh \
nar-access.sh \
impure-eval.sh \
pure-eval.sh \
eval.sh \
repl.sh \
Expand Down

0 comments on commit 70f50cb

Please sign in to comment.