aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Locati <michele@locati.it>2018-03-14 17:28:02 +0100
committerMichele Locati <michele@locati.it>2018-03-14 17:28:02 +0100
commitd807ec71e2451e50ac5c392ac6f38b0a56e146ea (patch)
treefd7486300d6ad19b0b537088479060879cc0dfe1
parentaee7a2706dd96ee595ffc870584d737f78bab79e (diff)
downloadincremental-git-filter-branch-d807ec71e2451e50ac5c392ac6f38b0a56e146ea.zip
incremental-git-filter-branch-d807ec71e2451e50ac5c392ac6f38b0a56e146ea.tar.gz
incremental-git-filter-branch-d807ec71e2451e50ac5c392ac6f38b0a56e146ea.tar.bz2
Fix and simplify tests
-rwxr-xr-xtest/bootstrap.sh87
-rwxr-xr-xtest/tests/empty-filter-options.fail2
-rwxr-xr-xtest/tests/filter-directory-visited-tags.success21
-rwxr-xr-xtest/tests/invalid-filter-options.fail2
4 files changed, 53 insertions, 59 deletions
diff --git a/test/bootstrap.sh b/test/bootstrap.sh
index 831c13d..47db6ea 100755
--- a/test/bootstrap.sh
+++ b/test/bootstrap.sh
@@ -26,62 +26,65 @@ then
exit 1
fi
-alias git-source='git -C "${DIR_SOURCE}"'
-alias git-destination='git -C "${DIR_DESTINATION}"'
-
initializeRepositories () {
rm -rf "${DIR_TEMP}"
mkdir "${DIR_TEMP}"
git init --quiet "${DIR_SOURCE}"
- git-source config --local user.email 'email@example.com'
- git-source config --local user.name 'John Doe'
+ 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"
- echo 'test'>"${DIR_SOURCE}/in-root"
- git-source add --all
- git-source commit --quiet --message 'Commit #1'
- git-source tag tag-01
+ touch "${DIR_SOURCE}/rootfile1"
+ git -C "${DIR_SOURCE}" add --all
+ git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #1'
- mkdir "${DIR_SOURCE}/subdir"
- echo 'test'>"${DIR_SOURCE}/subdir/subfile"
- git-source add --all
- git-source commit --quiet --message 'Commit #2'
+ 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'
- git-source tag tag-02
+ touch "${DIR_SOURCE}/subdir/subfile2"
+ git -C "${DIR_SOURCE}" add --all
+ git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #3'
- echo 'test'>>"${DIR_SOURCE}/in-root"
- git-source add --all
- git-source commit --quiet --message 'Commit #3'
+ git -C "${DIR_SOURCE}" tag tag-02
- git-source tag tag-03
+ 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
- echo 'test'>>"${DIR_SOURCE}/in-root"
- git-source add --all
- git-source commit --quiet --message 'Commit #3'
+ touch "${DIR_SOURCE}/rootfile3"
+ git -C "${DIR_SOURCE}" add --all
+ git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #6'
- git init --bare --quiet "${DIR_DESTINATION}"
-}
+ touch "${DIR_SOURCE}/subdir/subfile3b"
+ git -C "${DIR_SOURCE}" add --all
+ git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4b'
-getTagList () {
- printf '%s\n' $(git -C "${1}" show-ref --tags | sed -E 's:^.*?refs/tags/::' || true)
-}
+ 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
-itemInList () {
- for itemInListItem in ${2}
- do
- if test "${1}" = "${itemInListItem}"
- then
- return 0
- fi
- done
- return 1
+ 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}"
}
-itemNotInList () {
- if itemInList "${1}" "${2}"
- then
- return 1
- else
- return 0
- fi
+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/tests/empty-filter-options.fail b/test/tests/empty-filter-options.fail
index 59d086d..ebfcbfb 100755
--- a/test/tests/empty-filter-options.fail
+++ b/test/tests/empty-filter-options.fail
@@ -2,4 +2,4 @@
. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh"
-"${BIN_MAIN}" -- "${DIR_SOURCE}" '' "${DIR_DESTINATION}"
+"${BIN_MAIN}" --workdir "${DIR_TEMP}" -- "${DIR_SOURCE}" '' "${DIR_DESTINATION}"
diff --git a/test/tests/filter-directory-visited-tags.success b/test/tests/filter-directory-visited-tags.success
index 527ee5a..ea788ed 100755
--- a/test/tests/filter-directory-visited-tags.success
+++ b/test/tests/filter-directory-visited-tags.success
@@ -1,25 +1,16 @@
#!/bin/sh
-. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh"
+. "$(cd -- "$(dirname -- "${0}")" && pwd -P)/../bootstrap.sh"
initializeRepositories
-"${BIN_MAIN}" "${DIR_SOURCE}" '--prune-empty --subdirectory-filter subdir' "${DIR_DESTINATION}"
+"${BIN_MAIN}" --workdir "${DIR_TEMP}" --whitelist 'master' -- "${DIR_SOURCE}" '--prune-empty --subdirectory-filter subdir' "${DIR_DESTINATION}"
echo 'Fetching tags'
-tags=$(getTagList "${DIR_DESTINATION}")
-if itemInList 'tag-01' "${tags}"
+actualTags="$(getTagList "${DIR_DESTINATION}")"
+expectedTags='tag-02'
+if test "${actualTags}" != "${expectedTags}"
then
- printf '%s should not be in tag list:\n%s\n' 'tag-01' "${tags}" >&2
- exit 1
-fi
-if itemNotInList 'tag-02' "${tags}"
-then
- printf '%s should be in tag list:\n%s\n' 'tag-02' "${tags}" >&2
- exit 1
-fi
-if itemInList 'tag-03' "${tags}"
-then
- printf '%s should not be in tag list:\n%s\n' 'tag-02' "${tags}" >&2
+ printf 'Expected tags: %s\nResulting tags: %s\n' "${expectedTags}" "${actualTags}">&2
exit 1
fi
diff --git a/test/tests/invalid-filter-options.fail b/test/tests/invalid-filter-options.fail
index 5ee6680..b830d36 100755
--- a/test/tests/invalid-filter-options.fail
+++ b/test/tests/invalid-filter-options.fail
@@ -2,4 +2,4 @@
. "$(cd -- "$(dirname -- "$0")" && pwd -P)/../bootstrap.sh"
-"${BIN_MAIN}" -- "${DIR_SOURCE}" b "${DIR_DESTINATION}"
+"${BIN_MAIN}" --workdir "${DIR_TEMP}" -- "${DIR_SOURCE}" b "${DIR_DESTINATION}"

© 2014-2020 Faster IT GmbH | imprint | privacy policy