summaryrefslogtreecommitdiff
path: root/subplot.md
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-11-17 09:16:51 +0200
committerLars Wirzenius <liw@liw.fi>2020-11-17 09:16:51 +0200
commitd67e20c6e29fcaff08340adf5eb7103f18f9fc81 (patch)
treea1d68ee101b87565f583ec2d63b0cc9a0ead9325 /subplot.md
parent34cbe3d66c6a03d405915eac35a002a3c4013cd0 (diff)
downloadsubplot-d67e20c6e29fcaff08340adf5eb7103f18f9fc81.tar.gz
fix: set TMPDIR for each scenario to its datadir
Diffstat (limited to 'subplot.md')
-rw-r--r--subplot.md50
1 files changed, 50 insertions, 0 deletions
diff --git a/subplot.md b/subplot.md
index 4f10165..05450e8 100644
--- a/subplot.md
+++ b/subplot.md
@@ -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