summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-04-13 17:59:22 +0200
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-04-30 02:07:20 +0200
commit62992295d67958683e97c4dbafeb3f5396bb6742 (patch)
tree04e3d8ebca72561ca615ac9c106bf280754694a7 /tests
parent85a7d902c039d82a646f771f661d6935f0a6a1cf (diff)
shell: Add --cwd.
* guix/scripts/environment.scm (show-environment-options-help): Document --cwd. (%options): Add cwd. (launch-environment/container): Add cwd parameter. Implement passing it to the container. (guix-environment*): Reject --cwd without --container. * doc/guix.texi (Invoking guix shell): Document it. * tests/guix-environment-container.sh: Add tests. * tests/guix-shell.sh: Add tests. Fixes: guix/guix# 7825 Change-Id: Iba4ff3d2058e92f504fbcbf688346357ce913213
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-environment-container.sh18
-rw-r--r--tests/guix-shell.sh3
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh
index 5b89f8383b..8947a4ea1b 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -186,6 +186,24 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
-- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
)
+# '--cwd' is independent from sharing the host current working directory.
+(
+ cd "$tmpdir" \
+ && guix environment --bootstrap --container --no-cwd --cwd=/tmp \
+ --ad-hoc guile-bootstrap --pure \
+ -- /bin/sh -c 'test $(pwd) == "/tmp" -a ! -d '"$tmpdir"
+)
+
+# Relative '--cwd' is resolved against the host CWD and still honors '--user'.
+mkdir -p "$tmpdir/home/wd"
+home_dir="$(cd "$tmpdir/home"; pwd -P)"
+(
+ cd "$tmpdir/home/wd" \
+ && HOME="$home_dir" guix environment --bootstrap --container --user=foo \
+ --cwd=. --ad-hoc guile-bootstrap --pure \
+ -- /bin/sh -c 'test "$(pwd)" = "/home/foo/wd"'
+)
+
# Check that the root file system is read-only by default...
guix environment --bootstrap --container --ad-hoc guile-bootstrap \
-- guile -c '(mkdir "/whatever")' && false
diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh
index b2f820bf26..4eb4a3196c 100644
--- a/tests/guix-shell.sh
+++ b/tests/guix-shell.sh
@@ -35,6 +35,9 @@ guix shell --bootstrap --pure guile-bootstrap -- guile --version
# '--symlink' can only be used with --container.
guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile && false
+# '--cwd' can only be used with --container.
+guix shell --cwd=/tmp -n hello && false
+
# '--ad-hoc' is a thing of the past.
guix shell --ad-hoc guile-bootstrap && false