Skip to content

Commit fb76d5b

Browse files
committed
tests: add tests for devshell entrypoint script
1 parent 45a6cc2 commit fb76d5b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tests/core/devshell.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,35 @@
4646
# Check that the profile got loaded
4747
assert "$FAKE_PROFILE" == "1"
4848
'';
49+
50+
# Devshell entrypoint script features
51+
devshell-entrypoint-1 =
52+
let
53+
shell = devshell.mkShell {
54+
devshell.name = "devshell-entrypoint-1";
55+
devshell.packages = [ pkgs.git ];
56+
};
57+
in
58+
runTest "devshell-entrypoint-1" { } ''
59+
entrypoint_clean() {
60+
env -u IN_NIX_SHELL -u PRJ_ROOT ${shell}/entrypoint "$@"
61+
}
62+
63+
# No packages in PATH
64+
! type -p git
65+
66+
# Exits badly if PRJ_ROOT isn't set, or if we cannot assume PRJ_ROOT
67+
# should be PWD.
68+
! msg="$(entrypoint_clean /bin/sh -c 'exit 0' 2>&1)"
69+
assert "$msg" == 'ERROR: please set the PRJ_ROOT env var to point to the project root'
70+
71+
# Succeeds with --prj-root set
72+
entrypoint_clean --prj-root . /bin/sh -c 'exit 0'
73+
74+
# Packages available through entrypoint
75+
entrypoint_clean --prj-root . /bin/sh -c 'type -p git'
76+
77+
# Packages available through entrypoint in pure mode
78+
entrypoint_clean --pure --env-bin env --prj-root . /bin/sh -c 'type -p git'
79+
'';
4980
}

0 commit comments

Comments
 (0)