Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/bin/sh Add some tests for the (likely forthcoming) pip...
details: https://anonhg.NetBSD.org/src/rev/2b92a098feb7
branches: trunk
changeset: 355164:2b92a098feb7
user: kre <kre%NetBSD.org@localhost>
date: Sat Jul 15 18:52:21 2017 +0000
description:
Add some tests for the (likely forthcoming) pipefail option (modelled
after than in ksh and bash, and the similar thing in zsh) for which a
request has been made for support in the NetBSD sh.
Until the support is committed, the test will be skipped.
diffstat:
tests/bin/sh/t_option.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 54 insertions(+), 1 deletions(-)
diffs (75 lines):
diff -r 1f7a132f459e -r 2b92a098feb7 tests/bin/sh/t_option.sh
--- a/tests/bin/sh/t_option.sh Sat Jul 15 18:50:42 2017 +0000
+++ b/tests/bin/sh/t_option.sh Sat Jul 15 18:52:21 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_option.sh,v 1.4 2017/06/02 01:38:44 kre Exp $
+# $NetBSD: t_option.sh,v 1.5 2017/07/15 18:52:21 kre Exp $
#
# Copyright (c) 2016 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -598,6 +598,56 @@
'
}
+atf_test_case pipefail
+pipefail_head() {
+ atf_set "descr" "Basic tests of the pipefail option"
+}
+pipefail_body() {
+ ${TEST_SH} -c 'set -o pipefail' 2>/dev/null ||
+ atf_skip "pipefail option not supported by ${TEST_SH}"
+
+ atf_check -s exit:0 -o match:'pipefail.*off' -e empty ${TEST_SH} -c \
+ 'set -o | grep pipefail'
+ atf_check -s exit:0 -o match:'pipefail.*on' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; set -o | grep pipefail'
+
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ '(exit 1) | (exit 2) | (exit 0)'
+ atf_check -s exit:2 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 1) | (exit 2) | (exit 0)'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 1) | (exit 0) | (exit 0)'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 0) | (exit 0) | (exit 0)'
+
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ '! (exit 1) | (exit 2) | (exit 0)'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 1) | (exit 2) | (exit 0)'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 1) | (exit 0) | (exit 0)'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 0) | (exit 0) | (exit 0)'
+
+ atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
+ '(exit 1) | (exit 2) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 1) | (exit 2) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 1) | (exit 0) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; (exit 0) | (exit 0) | (exit 0); echo $?'
+
+ atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+ '! (exit 1) | (exit 2) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 1) | (exit 2) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 1) | (exit 0) | (exit 0); echo $?'
+ atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+ 'set -o pipefail; ! (exit 0) | (exit 0) | (exit 0); echo $?'
+}
+
atf_test_case xx_bogus
xx_bogus_head() {
atf_set "descr" "Tests that attempting to set a nonsense option fails."
@@ -672,5 +722,8 @@
atf_add_test_case set_x
atf_add_test_case vi_emacs_VE_toggle
+
+ atf_add_test_case pipefail
+
atf_add_test_case xx_bogus
}
Home |
Main Index |
Thread Index |
Old Index