diff options
| author | Tomi Ollila <tomi.ollila@iki.fi> | 2015-08-06 12:13:36 +0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2015-08-07 21:56:39 +0200 |
| commit | 02a2eeb427d6b424029f6e5e5ddad4c6ec987741 (patch) | |
| tree | abdc66ca743a1f21c70238e4c118a51d08c253f1 /test/test-lib.sh | |
| parent | af3eba97fde00d6bc922df87732b3d28f717f120 (diff) | |
test: make script exit (1) if it "fails" to source (.) a file
The files (test) scripts source (with builtin command `.`) provides
information which the scripts depend, and without the `source` to
succeed allowing script to continue may lead to dangerous situations
(e.g. rm -rf "${undefined_variable}"/*).
At the end of all source (.) lines construct ' || exit 1' was added;
In our case the script script will exit if it cannot find (or read) the
file to be sourced. Additionally script would also exits if the last
command of the sourced file exited nonzero.
Diffstat (limited to 'test/test-lib.sh')
| -rw-r--r-- | test/test-lib.sh | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index eeb5487b..0bf7163e 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -96,7 +96,8 @@ _x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04" # test_description='Description of this test... # This test checks if command xyzzy does the right thing... # ' -# . ./test-lib.sh +# . ./test-lib.sh || exit 1 + [ "x$ORIGINAL_TERM" != "xdumb" ] && ( TERM=$ORIGINAL_TERM && export TERM && @@ -1223,7 +1224,7 @@ test_init_ () { } -. ./test-lib-common.sh +. ./test-lib-common.sh || exit 1 emacs_generate_script |
