summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
AgeCommit message (Collapse)AuthorFilesLines
2013-04-03Merge branch 'tr/valgrind'Libravatar Junio C Hamano1-0/+3
Let us use not just memgrind but other *grind debuggers. * tr/valgrind: tests: notice valgrind error in test_must_fail tests --valgrind: provide a mode without --track-origins tests: parameterize --valgrind option t/README: --valgrind already implies -v
2013-04-03Merge branch 'jc/apply-ws-fix-tab-in-indent'Libravatar Junio C Hamano1-0/+4
"git apply --whitespace=fix" was not prepared to see a line getting longer after fixing whitespaces (e.g. tab-in-indent aka Python). * jc/apply-ws-fix-tab-in-indent: test: resurrect q_to_tab apply --whitespace=fix: avoid running over the postimage buffer
2013-04-01Merge branch 'bc/append-signed-off-by'Libravatar Junio C Hamano1-4/+4
Consolidate codepaths that inspect log-message-to-be and decide to add a new Signed-off-by line in various commands. * bc/append-signed-off-by: git-commit: populate the edit buffer with 2 blank lines before s-o-b Unify appending signoff in format-patch, commit and sequencer format-patch: update append_signoff prototype t4014: more tests about appending s-o-b lines sequencer.c: teach append_signoff to avoid adding a duplicate newline sequencer.c: teach append_signoff how to detect duplicate s-o-b sequencer.c: always separate "(cherry picked from" from commit body sequencer.c: require a conforming footer to be preceded by a blank line sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footer t/t3511: add some tests of 'cherry-pick -s' functionality t/test-lib-functions.sh: allow to specify the tag name to test_commit commit, cherry-pick -s: remove broken support for multiline rfc2822 fields sequencer.c: rework search for start of footer to improve clarity
2013-04-01tests: notice valgrind error in test_must_failLibravatar Thomas Rast1-0/+3
We tell valgrind to return 126 if it notices that something is wrong, but we did not actually handle this in test_must_fail, leading to false negatives. Catch and report it. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-29test: resurrect q_to_tabLibravatar Junio C Hamano1-0/+4
New test may want to use this helper; keep it for them that do not need to protect literal SP. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-22apply --whitespace=fix: avoid running over the postimage bufferLibravatar Junio C Hamano1-2/+2
Originally update-pre-post-images could assume that any whitespace fixing will make the result only shorter by unexpanding runs of leading SPs into HTs and removing trailing whitespaces at the end of lines. Updating the post-image we read from the patch to match the actual result can be performed in-place under this assumption. These days, however, we have tab-in-indent (aka Python) rule whose result can be longer than the original, and we do need to allocate a larger buffer than the input and replace the result. Fortunately the support for lengthening rewrite was already added when we began supporting "match while ignoring whitespace differences" mode in 86c91f91794c (git apply: option to ignore whitespace differences, 2009-08-04). We only need to correctly count the number of bytes necessary to hold the updated result and tell the function to allocate a new buffer. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12t/test-lib-functions.sh: allow to specify the tag name to test_commitLibravatar Brandon Casey1-4/+4
The <message> part of test_commit() may not be appropriate for a tag name. So let's allow test_commit to accept a fourth argument to specify the tag name. Signed-off-by: Brandon Casey <bcasey@nvidia.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-22tests: move test_cmp_rev to test-lib-functionsLibravatar Martin von Zweigbergk1-0/+7
A function for checking that two given parameters refer to the same revision was defined in several places, so move the definition to test-lib-functions.sh instead. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-15test-lib: allow negation of prerequisitesLibravatar Jeff King1-1/+20
You can set and test a prerequisite like this: test_set_prereq FOO test_have_prereq FOO && echo yes You can negate the test in the shell like this: ! test_have_prereq && echo no However, when you are using the automatic prerequisite checking in test_expect_*, there is no opportunity to use the shell negation. This patch introduces the syntax "!FOO" to indicate that the test should only run if a prerequisite is not meant. One alternative is to set an explicit negative prerequisite, like: if system_has_foo; then test_set_prereq FOO else test_set_prereq NO_FOO fi However, this doesn't work for lazy prerequisites, which associate a single test with a single name. We could teach the lazy prereq evaluator to set both forms, but the code change ends up quite similar to this one (because we still need to convert NO_FOO into FOO to find the correct lazy script). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-14cherry-pick: don't forget -s on failureLibravatar Miklos Vajna1-5/+16
In case 'git cherry-pick -s <commit>' failed, the user had to use 'git commit -s' (i.e. state the -s option again), which is easy to forget about. Instead, write the signed-off-by line early, so plain 'git commit' will have the same result. Also update 'git commit -s', so that in case there is already a relevant Signed-off-by line before the Conflicts: line, it won't add one more at the end of the message. If there is no such line, then add it before the the Conflicts: line. Signed-off-by: Miklos Vajna <vmiklos@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-22Merge branch 'mk/test-seq'Libravatar Junio C Hamano1-0/+21
Add a compatibility/utility function to the test framework. * mk/test-seq: tests: Introduce test_seq
2012-08-04tests: Introduce test_seqLibravatar Michał Kiedrowicz1-0/+21
Jeff King wrote: The seq command is GNU-ism, and is missing at least in older BSD releases and their derivatives, not to mention antique commercial Unixes. We already purged it in b3431bc (Don't use seq in tests, not everyone has it, 2007-05-02), but a few new instances have crept in. They went unnoticed because they are in scripts that are not run by default. Replace them with test_seq that is implemented with a Perl snippet (proposed by Jeff). This is better than inlining this snippet everywhere it's needed because it's easier to read and it's easier to change the implementation (e.g. to C) if we ever decide to remove Perl from the test suite. Note that test_seq is not a complete replacement for seq(1). It just has what we need now, in addition that it makes it possible for us to do something like "test_seq a m" if we wanted to in the future. There are also many places that do `for i in 1 2 3 ...` but I'm not sure if it's worth converting them to test_seq. That would introduce running more processes of Perl. Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-30Merge branch 'jc/maint-filter-branch-epoch-date' into maintLibravatar Junio C Hamano1-2/+11
In 1.7.9 era, we taught "git rebase" about the raw timestamp format but we did not teach the same trick to "filter-branch", which rolled a similar logic on its own. * jc/maint-filter-branch-epoch-date: t7003: add test to filter a branch with a commit at epoch date.c: Fix off by one error in object-header date parsing filter-branch: do not forget the '@' prefix to force git-timestamp
2012-07-27test: allow prerequisite to be evaluated lazilyLibravatar Junio C Hamano1-0/+42
The test prerequisite mechanism is a useful way to allow some tests in a test script to be skipped in environments that do not support certain features (e.g. it is pointless to attempt checking how well symbolic links are handled by Git on filesystems that do not support them). It is OK for commonly used prerequisites to be always tested during start-up of a test script by having a codeblock that tests a feature and calls test_set_prereq, but for an uncommon feature, forcing 90% of scripts to pay the same probing overhead for prerequisite they do not care about is wasteful. Introduce a mechanism to probe the prerequiste lazily. Changes are: - test_lazy_prereq () function, which takes the name of the prerequisite it probes and the script to probe for it, is added. This only registers the name of the prerequiste that can be lazily probed and the script to eval (without running). - test_have_prereq() function (which is used by test_expect_success and also can be called directly by test scripts) learns to look at the list of prerequisites that can be lazily probed, and the prerequisites that have already been probed that way. When asked for a prerequiste that can be but haven't been probed, the script registered with an earlier call to test_lazy_prereq is evaluated and the prerequisite is set. - test_run_lazy_prereq_() function is a helper to run the probe script with the same kind of sandbox as regular tests, helped by Jeff King. Update the codeblock to probe and set SYMLINKS prerequisite using the new mechanism as an example. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-27test: rename $satisfied to $satisfied_prereqLibravatar Junio C Hamano1-3/+3
All other shell variables that are used to globally keep track of states related to prerequisite have "prereq" somewhere in their names. Be consistent and avoid potential name crashes with other kinds of satisfaction in the future. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22Merge branch 'jc/maint-filter-branch-epoch-date'Libravatar Junio C Hamano1-2/+11
In 1.7.9 era, we taught "git rebase" about the raw timestamp format but we did not teach the same trick to "filter-branch", which rolled a similar logic on its own. Because of this, "filter-branch" failed to rewrite commits with ancient timestamps. * jc/maint-filter-branch-epoch-date: t7003: add test to filter a branch with a commit at epoch date.c: Fix off by one error in object-header date parsing filter-branch: do not forget the '@' prefix to force git-timestamp
2012-06-24tests: enclose $PERL_PATH in double quotesLibravatar Junio C Hamano1-2/+2
Otherwise it will be split at a space after "Program" when it is set to "\\Program Files\perl" or something silly like that. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-12t: Replace 'perl' by $PERL_PATHLibravatar Vincent van Ravesteijn1-2/+2
GIT-BUILD-OPTIONS defines PERL_PATH to be used in the test suite. Only a few tests already actually use this variable when perl is needed. The other test just call 'perl' and it might happen that the wrong perl interpreter is used. This becomes problematic on Windows, when the perl interpreter that is compiled and installed on the Windows system is used, because this perl interpreter might introduce some unexpected LF->CRLF conversions. This patch makes sure that $PERL_PATH is used everywhere in the test suite and that the correct perl interpreter is used. Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-17Move the user-facing test library to test-lib-functions.shLibravatar Thomas Rast1-0/+565
This just moves all the user-facing functions to a separate file and sources that instead. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>