From 20baeb9ea1419fd13ca1e76a33d1bb65a73f9e7e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 27 Feb 2018 13:48:18 -0500 Subject: [PATCH] run-tests.sh: add more tests for exit codes. --- run-tests.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/run-tests.sh b/run-tests.sh index fc7fed4..07ad496 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -810,6 +810,7 @@ ACTUAL="$?" EXPECTED="0" compare + # Test that our exit code fails on a symlink. TESTNUM=34 TARGET="${TESTDIR}/bar" @@ -820,3 +821,48 @@ setfacl --default --modify user:${USERS[0]}:rw "${TESTDIR}" ACTUAL="$?" EXPECTED="1" compare + + +# The previous test should "succeed" if we use --recursive. This is +# buggy, but it's documented. +TESTNUM=35 +TARGET="${TESTDIR}/bar" +touch "${TESTDIR}/foo" +ln -s foo "${TARGET}" +setfacl --default --modify user:${USERS[0]}:rw "${TESTDIR}" +"${BIN}" --recursive "${TARGET}" +ACTUAL="$?" +EXPECTED="0" +compare + + +# Test the return value for nonexistent paths. +TESTNUM=36 +TARGET="${TESTDIR}/foo" +"${BIN}" "${TARGET}" &>/dev/null +ACTUAL="$?" +EXPECTED="1" +compare + + +# Test that one "failure" exit code overrides two "successes" +TESTNUM=37 +mkdir "${TESTDIR}/foo" +ln -s foo "${TESTDIR}/bar" +mkdir "${TESTDIR}/baz" +"${BIN}" "${TESTDIR}/foo" "${TESTDIR}/bar" "${TESTDIR}/baz" +ACTUAL="$?" +EXPECTED="1" +compare + + +# And test the buggy behavior again; the previous test should return +# success (ignoring the failure) when --recursive is used. +TESTNUM=38 +mkdir "${TESTDIR}/foo" +ln -s foo "${TESTDIR}/bar" +mkdir "${TESTDIR}/baz" +"${BIN}" --recursive "${TESTDIR}" +ACTUAL="$?" +EXPECTED="0" +compare -- 2.44.2