diff --git a/t/README b/t/README index 8f12d48fe8..f208cf1db9 100644 --- a/t/README +++ b/t/README @@ -212,6 +212,24 @@ library for your script to use. is to summarize successes and failures in the test script and exit with an appropriate error code. + - test_tick + + Make commit and tag names consistent by setting the author and + committer times to defined stated. Subsequent calls will + advance the times by a fixed amount. + + - test_commit [ []] + + Creates a commit with the given message, committing the given + file with the given contents (default for both is to reuse the + message string), and adds a tag (again reusing the message + string as name). Calls test_tick to make the SHA-1s + reproducible. + + - test_merge + + Merges the given rev using the given message. Like test_commit, + creates a tag and calls test_tick before committing. Tips for Writing Tests ---------------------- diff --git a/t/test-lib.sh b/t/test-lib.sh index 41d5a5996e..c1839f70b9 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -193,6 +193,31 @@ test_tick () { export GIT_COMMITTER_DATE GIT_AUTHOR_DATE } +# Call test_commit with the arguments " [ []]" +# +# This will commit a file with the given contents and the given commit +# message. It will also add a tag with as name. +# +# Both and default to . + +test_commit () { + file=${2:-$(echo "$1" | tr 'A-Z' 'a-z')} + echo "${3-$1}" > "$file" && + git add "$file" && + test_tick && + git commit -m "$1" && + git tag "$1" +} + +# Call test_merge with the arguments " ", where +# can be a tag pointing to the commit-to-merge. + +test_merge () { + test_tick && + git merge -m "$1" "$2" && + git tag "$1" +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead.