diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-07-04 08:24:08 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-07-04 08:24:08 +0100 |
commit | 8ed4d0938be659cc1a618ee74a9882bdad83dd74 (patch) | |
tree | 63852a0d55aff881311f86dd8944c3af0c088ae0 | |
parent | faff7b2b536218669216593068f063611cf80dab (diff) | |
parent | d07601b82bed17db1bec8c0d65402ee3bf644b6c (diff) | |
download | cmdtest-8ed4d0938be659cc1a618ee74a9882bdad83dd74.tar.gz |
Merge branch 'finally'
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | yarn.1.in | 16 | ||||
-rwxr-xr-x | yarn.tests/finally.script | 26 |
3 files changed, 39 insertions, 4 deletions
@@ -9,6 +9,7 @@ Version 0.X, released UNRELEASED * Yarn now warns if an input file has no code blocks. * There is no a `--shell-library` option for the user to use, which includes a shell library when running any IMPLEMENTS section. +* FINALLY always worked, but has now been added to the manual page as well. Bug fixes: @@ -42,11 +42,16 @@ GIVEN some live data in a directory AND an empty backup repository WHEN a backup is made THEN the data case be restored -.nf +FINALLY cleanup +.fi .PP -(Note the addition of AND: you can have multiple GIVEN, WHEN, and +Note the addition of AND: you can have multiple GIVEN, WHEN, and THEN statements. The AND keyword makes the text be more readable. -SENCARIO is also necessary, and gives the title.) +SCENARIO is also necessary, and gives the title. +.PP +FINALLY is for cleanups. +The FINALLY steps will be run regardless of whether the scenario succeeds +or not. .PP Scenarios are meant to be written in somewhat human readable language. However, they are not free form text. @@ -72,9 +77,12 @@ IMPLEMENTS THEN the data can be restored mkdir "$TESTDIR/restored" restore-program -r "$TESTDIR/repo" "$TESTDIR/restored" diff -rq "$TESTDIR/data" "$TESTDIR/restored" +.IP +IMPLEMENTS FINALLY cleanup +echo nothing to do, actually .fi .PP -Each "IMPLEMENT GIVEN" (or WHEN, THEN) is followed by a regular +Each "IMPLEMENTS GIVEN" (or WHEN, THEN, FINALLY) is followed by a regular expression on the same line, and then a shell script that gets executed to implement any step that matches the regular expression. diff --git a/yarn.tests/finally.script b/yarn.tests/finally.script new file mode 100755 index 0000000..2d383a0 --- /dev/null +++ b/yarn.tests/finally.script @@ -0,0 +1,26 @@ +#!/bin/sh + +set -eu + +cat <<EOF > "$DATADIR/finally.yarn" + SCENARIO finally + GIVEN nothing + WHEN nothing + THEN nothing + FINALLY yeehaa + + IMPLEMENTS GIVEN nothing + true + + IMPLEMENTS WHEN nothing + true + + IMPLEMENTS THEN nothing + true + + IMPLEMENTS FINALLY yeehaa + touch "$DATADIR/finally.has.run" +EOF + +./yarn -q "$DATADIR/finally.yarn" +test -e "$DATADIR/finally.has.run" |