diff options
| author | Danny Milosavljevic <dannym@friendly-machines.com> | 2026-04-13 17:59:22 +0200 |
|---|---|---|
| committer | Danny Milosavljevic <dannym@friendly-machines.com> | 2026-04-30 02:07:20 +0200 |
| commit | 62992295d67958683e97c4dbafeb3f5396bb6742 (patch) | |
| tree | 04e3d8ebca72561ca615ac9c106bf280754694a7 /tests | |
| parent | 85a7d902c039d82a646f771f661d6935f0a6a1cf (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.sh | 18 | ||||
| -rw-r--r-- | tests/guix-shell.sh | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 5b89f8383b6..8947a4ea1ba 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 \ | |||
| 186 | -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir" | 186 | -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir" |
| 187 | ) | 187 | ) |
| 188 | 188 | ||
| 189 | # '--cwd' is independent from sharing the host current working directory. | ||
| 190 | ( | ||
| 191 | cd "$tmpdir" \ | ||
| 192 | && guix environment --bootstrap --container --no-cwd --cwd=/tmp \ | ||
| 193 | --ad-hoc guile-bootstrap --pure \ | ||
| 194 | -- /bin/sh -c 'test $(pwd) == "/tmp" -a ! -d '"$tmpdir" | ||
| 195 | ) | ||
| 196 | |||
| 197 | # Relative '--cwd' is resolved against the host CWD and still honors '--user'. | ||
| 198 | mkdir -p "$tmpdir/home/wd" | ||
| 199 | home_dir="$(cd "$tmpdir/home"; pwd -P)" | ||
| 200 | ( | ||
| 201 | cd "$tmpdir/home/wd" \ | ||
| 202 | && HOME="$home_dir" guix environment --bootstrap --container --user=foo \ | ||
| 203 | --cwd=. --ad-hoc guile-bootstrap --pure \ | ||
| 204 | -- /bin/sh -c 'test "$(pwd)" = "/home/foo/wd"' | ||
| 205 | ) | ||
| 206 | |||
| 189 | # Check that the root file system is read-only by default... | 207 | # Check that the root file system is read-only by default... |
| 190 | guix environment --bootstrap --container --ad-hoc guile-bootstrap \ | 208 | guix environment --bootstrap --container --ad-hoc guile-bootstrap \ |
| 191 | -- guile -c '(mkdir "/whatever")' && false | 209 | -- guile -c '(mkdir "/whatever")' && false |
diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh index b2f820bf26d..4eb4a3196cd 100644 --- a/tests/guix-shell.sh +++ b/tests/guix-shell.sh | |||
| @@ -35,6 +35,9 @@ guix shell --bootstrap --pure guile-bootstrap -- guile --version | |||
| 35 | # '--symlink' can only be used with --container. | 35 | # '--symlink' can only be used with --container. |
| 36 | guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile && false | 36 | guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile && false |
| 37 | 37 | ||
| 38 | # '--cwd' can only be used with --container. | ||
| 39 | guix shell --cwd=/tmp -n hello && false | ||
| 40 | |||
| 38 | # '--ad-hoc' is a thing of the past. | 41 | # '--ad-hoc' is a thing of the past. |
| 39 | guix shell --ad-hoc guile-bootstrap && false | 42 | guix shell --ad-hoc guile-bootstrap && false |
| 40 | 43 | ||
