From 191b2acd1f69d9e0a2f10bcaf7e536c022618a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 20 Apr 2020 15:26:27 +0200 Subject: [PATCH] Fail test execution if there were duplicate test names (#106) --- test.sh | 26 +++++++++++++++++++++++++- test/empty-dirs.bats | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 5f5d988..1a40cd8 100755 --- a/test.sh +++ b/test.sh @@ -38,4 +38,28 @@ else fi mkdir -p "$SCRIPT_DIR/build/tmp" -TMPDIR="$SCRIPT_DIR/build/tmp" test/libs/bats-core/bin/bats "$@" +{ + TMPDIR="$SCRIPT_DIR/build/tmp" \ + test/libs/bats-core/bin/bats "$@" \ + 4>&1 1>&2 2>&4 | + awk ' + BEGIN { + duplicate_test_names = "" + } + + { + print + } + + /duplicate test name/ { + duplicate_test_names = duplicate_test_names "\n\t" $0 + } + + END { + if (length(duplicate_test_names)) { + print "\nERROR: duplicate test name(s) found:" duplicate_test_names + exit 1 + } + } + ' +} 4>&1 1>&2 2>&4 diff --git a/test/empty-dirs.bats b/test/empty-dirs.bats index 8f5b20f..f07429a 100644 --- a/test/empty-dirs.bats +++ b/test/empty-dirs.bats @@ -1060,7 +1060,7 @@ load 'common' assert_equal "$(git -C git-repo show branch-a:dir-a/.gitignore)" '/ignore-a' } -@test 'branching with svn-ignore, svn-branches and empty-dirs parameter should not replace filled .gitignore files with empty ones' { +@test 'branching with svn-ignore, svn-branches and empty-dirs parameter should not replace filled .gitignore files with empty ones (nested)' { svn mkdir project-a cd project-a svn mkdir --parents trunk/dir-a