diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-17 09:16:51 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-17 09:16:51 +0200 |
commit | d67e20c6e29fcaff08340adf5eb7103f18f9fc81 (patch) | |
tree | a1d68ee101b87565f583ec2d63b0cc9a0ead9325 /subplot.md | |
parent | 34cbe3d66c6a03d405915eac35a002a3c4013cd0 (diff) | |
download | subplot-d67e20c6e29fcaff08340adf5eb7103f18f9fc81.tar.gz |
fix: set TMPDIR for each scenario to its datadir
Diffstat (limited to 'subplot.md')
-rw-r--r-- | subplot.md | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -1025,6 +1025,56 @@ given failure +## Temporary files in scenarios in Python + +The Python template for generating test programs supports the +`--save-on-failure` option. If the test program fails, it produces a +dump of the data directories of all the scenarios it has run. Any +temporary files created by the scenario using the usual mechanisms +need to be in that dump. For this to happen, the test runner must set +the `TMPDIR` environment variable to point at the data directory. This +scenario verifies that it happens. + +~~~scenario +given file tmpdir.md +and file tmpdir.yaml +and file tmpdir.py +and an installed subplot +when I run sp-codegen --run tmpdir.md -o test.py +then command is successful +and scenario "TMPDIR" was run +and step "then TMPDIR is set" was run +~~~ + +~~~~{#tmpdir.md .file .markdown .numberLines} +--- +title: TMPDIR +bindings: tmpdir.yaml +functions: tmpdir.py +... + +# TMPDIR + +~~~scenario +then TMPDIR is set +~~~ +~~~~ + +~~~{#tmpdir.yaml .file .yaml .numberLines} +- then: TMPDIR is set + function: tmpdir_is_set +~~~ + +~~~{#tmpdir.py .file .python .numberLines} +import os +def tmpdir_is_set(ctx): + assert_eq(os.environ.get("TMPDIR"), os.getcwd()) +~~~ + + + + + ## Capturing parts of steps for functions A scenario step binding can capture parts of a scenario step, to be |