Skip to content

Commit 382351f

Browse files
committed
document session shell environment, close #53
1 parent 30bc248 commit 382351f

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

docs/syntax.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,21 @@ $ test -d /etc/nonexistant || true
369369

370370
## Environment
371371

372-
To set envrionment variables for this test run, add an `envrionment` key to the
373-
frontmatter. `$VARIABLES` and `${VARIABLES}` are interpreted within the values
374-
of these entries using the shell environment of the controller.
372+
Shellinspector works with the environment like any other shell session.
373+
Variables stay within one session, i.e. `$` and `%` lines do not share the same
374+
environment. They are cleared after the ispec file ends. Variables from file
375+
scoped fixtures are not cleared before the actual tests. Variables from global
376+
fixtures are cleared. The `SI_USER` variable is always passed from fixtures to
377+
the actual tests to all sessions. The value is taken from the first available
378+
session that has a value set.
379+
380+
There are multiple ways to set environment variables.
381+
382+
### Frontmatter
383+
384+
Set the desired values in the `environment` key inside the frontmatter.
385+
`$VARIABLES` and `${VARIABLES}` are interpreted within the values of these
386+
entries using the shell environment of the controller.
375387

376388
`test.ispec`:
377389

@@ -387,6 +399,19 @@ $ echo $OUTSIDE_PAGER
387399
less
388400
```
389401

402+
### Shell
403+
404+
Use the `export` command like any shell session to set variables dynamically.
405+
To clear a variable, use the `unset` command.
406+
407+
```yaml
408+
$ export DNS_SERVER=1.1.1.1
409+
$ echo $DNS_SERVER
410+
1.1.1.1
411+
$ unset DNS_SERVER
412+
$ echo $DNS_SERVER
413+
```
414+
390415
## Parametrized tests
391416

392417
To run many similar tests, add an `examples` key to the frontmatter:

0 commit comments

Comments
 (0)