From 30bf11d417eb0d65cb3620e44afe4efb8c7a1d09 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Thu, 15 Mar 2018 18:36:04 +0100 Subject: Remove useless .sh file extension --- test/all-tests.sh | 69 ----------------- test/bootstrap | 90 ++++++++++++++++++++++ test/bootstrap.sh | 90 ---------------------- test/run-tests | 69 +++++++++++++++++ test/tests/empty-filter-options.fail | 2 +- test/tests/filter-directory-all-tags.success | 2 +- .../filter-directory-filtered-tags-bl.success | 2 +- .../filter-directory-filtered-tags-blrx.success | 2 +- .../filter-directory-filtered-tags-wl.success | 2 +- .../filter-directory-filtered-tags-wlrx.success | 2 +- test/tests/filter-directory-visited-tags.success | 2 +- test/tests/get-help.success | 2 +- test/tests/invalid-filter-options.fail | 2 +- test/tests/misplaced-help.fail | 2 +- 14 files changed, 169 insertions(+), 169 deletions(-) delete mode 100755 test/all-tests.sh create mode 100755 test/bootstrap delete mode 100755 test/bootstrap.sh create mode 100755 test/run-tests (limited to 'test') diff --git a/test/all-tests.sh b/test/all-tests.sh deleted file mode 100755 index be10e10..0000000 --- a/test/all-tests.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -IS_TEST_CASE=0 -if ! . "$(cd -- "$(dirname -- "$0")" && pwd -P)/bootstrap.sh" -then - echo 'Unable to find bootstrap script'>&2 - exit 1 -fi - -wantedFilter='' -if test $# -eq 1 -then - wantedFilter="${1}" -else - wantedFilter='' -fi - -someTestExecuted=0 -for testFile in "${DIR_TESTCASES}"/* -do - fullTestName="$(basename "${testFile}")" - testName=${fullTestName%.success} - if test "${fullTestName}" != "${testName}" - then - should='succeed' - else - testName=${fullTestName%.fail} - if test "${fullTestName}" != "${testName}" - then - should='fail' - else - printf 'Unrecognized test case: %s\n', "${fullTestName}" - exit 1 - fi - fi - if test -z "${wantedFilter}" -o "${testName}" = "${wantedFilter}" - then - printf '%s should %s... ' "${testName}" "${should}" - case "${should}" in - 'succeed') - if testOutput="$(${testFile} 2>&1)" - then - printf 'ok.\n' - else - printf 'FAILED!\n' - printf '%s\n' "${testOutput}" >&2 - exit 1 - fi - ;; - 'fail') - if testOutput="$(${testFile} 2>&1)" - then - printf 'FAILED!\n' - printf '%s\n' "${testOutput}" >&2 - exit 1 - else - printf 'ok.\n' - fi - ;; - esac - someTestExecuted=1 - fi -done - -if test ${someTestExecuted} -eq 0 -then - echo 'No test found!'>&2 - exit 1 -fi diff --git a/test/bootstrap b/test/bootstrap new file mode 100755 index 0000000..fe9c0ba --- /dev/null +++ b/test/bootstrap @@ -0,0 +1,90 @@ +#!/bin/sh + +set -o errexit +set -o nounset +IFS=' +' + +if test "${IS_TEST_CASE:-1}" -eq '1' +then + DIR_TESTCASES="$(cd -- "$(dirname -- "$0")" && pwd -P)" + DIR_TEST="$(dirname "${DIR_TESTCASES}")" +else + DIR_TEST="$(cd -- "$(dirname -- "$0")" && pwd -P)" + DIR_TESTCASES="${DIR_TEST}/tests" +fi +DIR_ROOT="$(dirname "${DIR_TEST}")" +DIR_BIN="${DIR_ROOT}/bin" +DIR_TEMP="${DIR_TEST}/temp" +DIR_SOURCE="${DIR_TEMP}/source" +DIR_DESTINATION="${DIR_TEMP}/destination" + +BIN_MAIN="${DIR_BIN}/incremental-git-filterbranch" +if test ! -f "${BIN_MAIN}" +then + echo 'Failed to detect environment'>&2 + exit 1 +fi + +initializeRepositories () { + rm -rf "${DIR_TEMP}" + mkdir "${DIR_TEMP}" + + git init --quiet "${DIR_SOURCE}" + git -C "${DIR_SOURCE}" config --local user.email 'email@example.com' + git -C "${DIR_SOURCE}" config --local user.name 'John Doe' + mkdir "${DIR_SOURCE}/subdir" + + touch "${DIR_SOURCE}/rootfile1" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #1' + + git -C "${DIR_SOURCE}" tag tag-01 + + touch "${DIR_SOURCE}/subdir/subfile1" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #2' + + touch "${DIR_SOURCE}/subdir/subfile2" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #3' + + git -C "${DIR_SOURCE}" tag tag-02 + + touch "${DIR_SOURCE}/subdir/subfile3" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4' + + touch "${DIR_SOURCE}/rootfile2" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #5' + + git -C "${DIR_SOURCE}" tag tag-03 + + touch "${DIR_SOURCE}/rootfile3" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #6' + + touch "${DIR_SOURCE}/subdir/subfile3b" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4b' + + git -C "${DIR_SOURCE}" checkout --quiet -b slave tag-02 + + touch "${DIR_SOURCE}/in-root-2" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #7' + + git -C "${DIR_SOURCE}" tag tag-04 + + touch "${DIR_SOURCE}/in-root-3" + git -C "${DIR_SOURCE}" add --all + git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #8' + + git init --bare --quiet "${DIR_DESTINATION}" +} + +getTagList () { + getTagList_multiline=$(git -C "${1}" show-ref --tags | sed -E 's:^.*?refs/tags/::' || true) + printf '%s' "${getTagList_multiline}" | sort -b | tr '\n' ' ' | sed -E 's:^ | $::g' +} diff --git a/test/bootstrap.sh b/test/bootstrap.sh deleted file mode 100755 index 47db6ea..0000000 --- a/test/bootstrap.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh - -set -o errexit -set -o nounset -IFS=' -' - -if test "${IS_TEST_CASE:-1}" -eq '1' -then - DIR_TESTCASES="$(cd -- "$(dirname -- "$0")" && pwd -P)" - DIR_TEST="$(dirname "${DIR_TESTCASES}")" -else - DIR_TEST="$(cd -- "$(dirname -- "$0")" && pwd -P)" - DIR_TESTCASES="${DIR_TEST}/tests" -fi -DIR_ROOT="$(dirname "${DIR_TEST}")" -DIR_BIN="${DIR_ROOT}/bin" -DIR_TEMP="${DIR_TEST}/temp" -DIR_SOURCE="${DIR_TEMP}/source" -DIR_DESTINATION="${DIR_TEMP}/destination" - -BIN_MAIN="${DIR_BIN}/incremental-git-filterbranch.sh" -if test ! -f "${BIN_MAIN}" -then - echo 'Failed to detect environment'>&2 - exit 1 -fi - -initializeRepositories () { - rm -rf "${DIR_TEMP}" - mkdir "${DIR_TEMP}" - - git init --quiet "${DIR_SOURCE}" - git -C "${DIR_SOURCE}" config --local user.email 'email@example.com' - git -C "${DIR_SOURCE}" config --local user.name 'John Doe' - mkdir "${DIR_SOURCE}/subdir" - - touch "${DIR_SOURCE}/rootfile1" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #1' - - git -C "${DIR_SOURCE}" tag tag-01 - - touch "${DIR_SOURCE}/subdir/subfile1" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #2' - - touch "${DIR_SOURCE}/subdir/subfile2" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #3' - - git -C "${DIR_SOURCE}" tag tag-02 - - touch "${DIR_SOURCE}/subdir/subfile3" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4' - - touch "${DIR_SOURCE}/rootfile2" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #5' - - git -C "${DIR_SOURCE}" tag tag-03 - - touch "${DIR_SOURCE}/rootfile3" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #6' - - touch "${DIR_SOURCE}/subdir/subfile3b" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4b' - - git -C "${DIR_SOURCE}" checkout --quiet -b slave tag-02 - - touch "${DIR_SOURCE}/in-root-2" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #7' - - git -C "${DIR_SOURCE}" tag tag-04 - - touch "${DIR_SOURCE}/in-root-3" - git -C "${DIR_SOURCE}" add --all - git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #8' - - git init --bare --quiet "${DIR_DESTINATION}" -} - -getTagList () { - getTagList_multiline=$(git -C "${1}" show-ref --tags | sed -E 's:^.*?refs/tags/::' || true) - printf '%s' "${getTagList_multiline}" | sort -b | tr '\n' ' ' | sed -E 's:^ | $::g' -} diff --git a/test/run-tests b/test/run-tests new file mode 100755 index 0000000..8be4720 --- /dev/null +++ b/test/run-tests @@ -0,0 +1,69 @@ +#!/bin/sh + +IS_TEST_CASE=0 +if ! . "$(cd -- "$(dirname -- "$0")" && pwd -P)/bootstrap" +then + echo 'Unable to find bootstrap script'>&2 + exit 1 +fi + +wantedFilter='' +if test $# -eq 1 +then + wantedFilter="${1}" +else + wantedFilter='' +fi + +someTestExecuted=0 +for testFile in "${DIR_TESTCASES}"/* +do + fullTestName="$(basename "${testFile}")" + testName=${fullTestName%.success} + if test "${fullTestName}" != "${testName}" + then + should='succeed' + else + testName=${fullTestName%.fail} + if test "${fullTestName}" != "${testName}" + then + should='fail' + else + printf 'Unrecognized test case: %s\n', "${fullTestName}" + exit 1 + fi + fi + if test -z "${wantedFilter}" -o "${testName}" = "${wantedFilter}" + then + printf '%s should %s... ' "${testName}" "${should}" + case "${should}" in + 'succeed') + if testOutput="$(${testFile} 2>&1)" + then + printf 'ok.\n' + else + printf 'FAILED!\n' + printf '%s\n' "${testOutput}" >&2 + exit 1 + fi + ;; + 'fail') + if testOutput="$(${testFile} 2>&1)" + then + printf 'FAILED!\n' + printf '%s\n' "${testOutput}" >&2 + exit 1 + else + printf 'ok.\n' + fi + ;; + esac + someTestExecuted=1 + fi +done + +if test ${someTestExecuted} -eq 0 +then + echo 'No test found!'>&2 + exit 1 +fi diff --git a/test/tests/empty-filter-options.fail b/test/tests/empty-filter-options.fail index ebfcbfb..4e865e5 100755 --- a/test/tests/empty-filter-options.fail +++ b/test/tests/empty-filter-options.fail @@ -1,5 +1,5 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap" "${BIN_MAIN}" --workdir "${DIR_TEMP}" -- "${DIR_SOURCE}" '' "${DIR_DESTINATION}" diff --git a/test/tests/filter-directory-all-tags.success b/test/tests/filter-directory-all-tags.success index f9a1017..035317a 100755 --- a/test/tests/filter-directory-all-tags.success +++ b/test/tests/filter-directory-all-tags.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/filter-directory-filtered-tags-bl.success b/test/tests/filter-directory-filtered-tags-bl.success index 8bc0c46..082d39c 100755 --- a/test/tests/filter-directory-filtered-tags-bl.success +++ b/test/tests/filter-directory-filtered-tags-bl.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/filter-directory-filtered-tags-blrx.success b/test/tests/filter-directory-filtered-tags-blrx.success index ff6e155..6e70290 100755 --- a/test/tests/filter-directory-filtered-tags-blrx.success +++ b/test/tests/filter-directory-filtered-tags-blrx.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/filter-directory-filtered-tags-wl.success b/test/tests/filter-directory-filtered-tags-wl.success index 3e08be0..5383fa2 100755 --- a/test/tests/filter-directory-filtered-tags-wl.success +++ b/test/tests/filter-directory-filtered-tags-wl.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/filter-directory-filtered-tags-wlrx.success b/test/tests/filter-directory-filtered-tags-wlrx.success index 7e101a0..f01c51d 100755 --- a/test/tests/filter-directory-filtered-tags-wlrx.success +++ b/test/tests/filter-directory-filtered-tags-wlrx.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/filter-directory-visited-tags.success b/test/tests/filter-directory-visited-tags.success index eec88ee..f23a749 100755 --- a/test/tests/filter-directory-visited-tags.success +++ b/test/tests/filter-directory-visited-tags.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap" initializeRepositories diff --git a/test/tests/get-help.success b/test/tests/get-help.success index 58036a8..8be9fa1 100755 --- a/test/tests/get-help.success +++ b/test/tests/get-help.success @@ -1,6 +1,6 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap" "${BIN_MAIN}" -h "${BIN_MAIN}" --help diff --git a/test/tests/invalid-filter-options.fail b/test/tests/invalid-filter-options.fail index b830d36..a6af95a 100755 --- a/test/tests/invalid-filter-options.fail +++ b/test/tests/invalid-filter-options.fail @@ -1,5 +1,5 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap" "${BIN_MAIN}" --workdir "${DIR_TEMP}" -- "${DIR_SOURCE}" b "${DIR_DESTINATION}" diff --git a/test/tests/misplaced-help.fail b/test/tests/misplaced-help.fail index a5c2e8f..8803df3 100755 --- a/test/tests/misplaced-help.fail +++ b/test/tests/misplaced-help.fail @@ -1,5 +1,5 @@ #!/bin/sh -. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh" +. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap" "${BIN_MAIN}" -- --help -- cgit v1.2.3