Debian Codegraph @

testscript/plugin/testdata/demo.txtar

raw
1 # The demo plugin reads its parameter directory and the GREETING variable from
2 # the test environment when its instance is created, then exposes a result
3 # variable built from both. The commands it provides ("echo", "warn", ...)
4 # become available directly after the "plugin" command runs.
5 env GREETING=howdy
6 plugin demo params
7
8 # The variable provided by the plugin instance (via Env) is set in the script
9 # environment.
10 echo $DEMO_MESSAGE
11 stdout '^howdy, world$'
12
13 # A command writes to standard output.
14 echo one two three
15 stdout '^one two three$'
16
17 # A command writes to standard error.
18 warn something is wrong
19 stderr '^something is wrong$'
20
21 # A command runs in the script's current working directory.
22 cd sub
23 cwd
24 stdout '[/\\]sub$'
25 cd ..
26
27 # A command can set an environment variable mid-script (via CmdResult.Environ).
28 settoken sesame
29 echo $DEMO_TOKEN
30 stdout '^sesame$'
31
32 # A failing command is reported as a failure, can be negated, and its output
33 # is still captured.
34 ! fail
35 stderr '^deliberate failure$'
36
37 # A second plugin can be used alongside the first. The kv plugin is invoked
38 # without a parameter directory, and its instance keeps state across commands.
39 plugin kv
40 set color blue
41 get color
42 stdout '^blue$'
43 get missing
44 stdout '^$'
45
46 -- params/name.txt --
47 world
48 -- sub/keep.txt --
49 placeholder