From: Junio C Hamano Date: Wed, 25 Jun 2014 19:23:56 +0000 (-0700) Subject: Merge branch 'ep/avoid-test-a-o' X-Git-Tag: v2.1.0-rc0~79 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e56857246adbd3ab0ded490f300da8ef34374cbc?ds=inline;hp=-c Merge branch 'ep/avoid-test-a-o' Update tests and scripts to avoid "test ... -a ...", which is often more error-prone than "test ... && test ...". Squashed misconversion fix-up into git-submodule.sh updates. * ep/avoid-test-a-o: git-submodule.sh: avoid "echo" path-like values git-submodule.sh: avoid "test -a/-o " t/test-lib-functions.sh: avoid "test -a/-o " t/t9814-git-p4-rename.sh: avoid "test -a/-o " t/t5538-push-shallow.sh: avoid "test -a/-o " t/t5403-post-checkout-hook.sh: avoid "test -a/-o " t/t5000-tar-tree.sh: avoid "test -a/-o " t/t4102-apply-rename.sh: avoid "test -a/-o " t/t0026-eol-config.sh: avoid "test -a/-o " t/t0025-crlf-auto.sh: avoid "test -a/-o " t/lib-httpd.sh: avoid "test -a/-o " git-rebase--interactive.sh: avoid "test -a/-o " git-mergetool.sh: avoid "test -a/-o " git-bisect.sh: avoid "test -a/-o " contrib/examples/git-resolve.sh: avoid "test -a/-o " contrib/examples/git-repack.sh: avoid "test -a/-o " contrib/examples/git-merge.sh: avoid "test -a/-o " contrib/examples/git-commit.sh: avoid "test -a/-o " contrib/examples/git-clone.sh: avoid "test -a/-o " check_bindir: avoid "test -a/-o " --- e56857246adbd3ab0ded490f300da8ef34374cbc diff --combined git-rebase--interactive.sh index f267d8b6c3,797571f50c..7e1eda0088 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -1013,7 -1013,7 +1013,7 @@@ the git rev-list $revisions | while read rev do - if test -f "$rewritten"/$rev -a "$(sane_grep "$rev" "$state_dir"/not-cherry-picks)" = "" + if test -f "$rewritten"/$rev && test "$(sane_grep "$rev" "$state_dir"/not-cherry-picks)" = "" then # Use -f2 because if rev-list is telling us this commit is # not worthwhile, we don't want to track its multiple heads, @@@ -1049,14 -1049,14 +1049,14 @@@ f has_action "$todo" || - die_abort "Nothing to do" + return 2 cp "$todo" "$todo".backup git_sequence_editor "$todo" || die_abort "Could not execute editor" has_action "$todo" || - die_abort "Nothing to do" + return 2 expand_todo_ids diff --combined t/lib-httpd.sh index 272fceef96,38a47fe20e..fd53b57187 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@@ -37,11 -37,6 +37,11 @@@ the test_done fi +if ! test_have_prereq SANITY; then + test_skip_or_die $GIT_TEST_HTTPD \ + "Cannot run httpd tests as root" +fi + HTTPD_PARA="" for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2' @@@ -110,15 -105,10 +110,15 @@@ els "Could not identify web server at '$LIB_HTTPD_PATH'" fi +install_script () { + write_script "$HTTPD_ROOT_PATH/$1" <"$TEST_PATH/$1" +} + prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" - cp "$TEST_PATH"/broken-smart-http.sh "$HTTPD_ROOT_PATH" + install_script broken-smart-http.sh + install_script error.sh ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" @@@ -142,7 -132,7 +142,7 @@@ HTTPD_URL_USER=$HTTPD_PROTO://user%40host@$HTTPD_DEST HTTPD_URL_USER_PASS=$HTTPD_PROTO://user%40host:pass%40host@$HTTPD_DEST - if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN" + if test -n "$LIB_HTTPD_DAV" || test -n "$LIB_HTTPD_SVN" then HTTPD_PARA="$HTTPD_PARA -DDAV" diff --combined t/t5000-tar-tree.sh index bad84a36e8,ad6fa0d4e4..899c1c5bbc --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@@ -72,7 -72,7 +72,7 @@@ check_tar() for header in *.paxheader do data=${header%.paxheader}.data && - if test -h $data -o -e $data + if test -h $data || test -e $data then path=$(get_pax_header $header path) && if test -n "$path" @@@ -164,7 -164,7 +164,7 @@@ check_tar with_olde-prefix olde test_expect_success 'git archive on large files' ' test_config core.bigfilethreshold 1 && git archive HEAD >b3.tar && - test_cmp b.tar b3.tar + test_cmp_bin b.tar b3.tar ' test_expect_success \ @@@ -173,15 -173,15 +173,15 @@@ test_expect_success \ 'git archive vs. the same in a bare repo' \ - 'test_cmp b.tar b3.tar' + 'test_cmp_bin b.tar b3.tar' test_expect_success 'git archive with --output' \ 'git archive --output=b4.tar HEAD && - test_cmp b.tar b4.tar' + test_cmp_bin b.tar b4.tar' test_expect_success 'git archive --remote' \ 'git archive --remote=. HEAD >b5.tar && - test_cmp b.tar b5.tar' + test_cmp_bin b.tar b5.tar' test_expect_success \ 'validate file modification time' \ @@@ -198,7 -198,7 +198,7 @@@ test_expect_success test_expect_success 'git archive with --output, override inferred format' ' git archive --format=tar --output=d4.zip HEAD && - test_cmp b.tar d4.zip + test_cmp_bin b.tar d4.zip ' test_expect_success \ @@@ -244,34 -244,34 +244,34 @@@ test_expect_success 'archive --list sho test_expect_success 'invoke tar filter by format' ' git archive --format=tar.foo HEAD >config.tar.foo && tr ab ba config.tar && - test_cmp b.tar config.tar && + test_cmp_bin b.tar config.tar && git archive --format=bar HEAD >config.bar && tr ab ba config.tar && - test_cmp b.tar config.tar + test_cmp_bin b.tar config.tar ' test_expect_success 'invoke tar filter by extension' ' git archive -o config-implicit.tar.foo HEAD && - test_cmp config.tar.foo config-implicit.tar.foo && + test_cmp_bin config.tar.foo config-implicit.tar.foo && git archive -o config-implicit.bar HEAD && - test_cmp config.tar.foo config-implicit.bar + test_cmp_bin config.tar.foo config-implicit.bar ' test_expect_success 'default output format remains tar' ' git archive -o config-implicit.baz HEAD && - test_cmp b.tar config-implicit.baz + test_cmp_bin b.tar config-implicit.baz ' test_expect_success 'extension matching requires dot' ' git archive -o config-implicittar.foo HEAD && - test_cmp b.tar config-implicittar.foo + test_cmp_bin b.tar config-implicittar.foo ' test_expect_success 'only enabled filters are available remotely' ' test_must_fail git archive --remote=. --format=tar.foo HEAD \ >remote.tar.foo && git archive --remote=. --format=bar >remote.bar HEAD && - test_cmp remote.bar config.bar + test_cmp_bin remote.bar config.bar ' test_expect_success GZIP 'git archive --format=tgz' ' @@@ -280,27 -280,27 +280,27 @@@ test_expect_success GZIP 'git archive --format=tar.gz' ' git archive --format=tar.gz HEAD >j1.tar.gz && - test_cmp j.tgz j1.tar.gz + test_cmp_bin j.tgz j1.tar.gz ' test_expect_success GZIP 'infer tgz from .tgz filename' ' git archive --output=j2.tgz HEAD && - test_cmp j.tgz j2.tgz + test_cmp_bin j.tgz j2.tgz ' test_expect_success GZIP 'infer tgz from .tar.gz filename' ' git archive --output=j3.tar.gz HEAD && - test_cmp j.tgz j3.tar.gz + test_cmp_bin j.tgz j3.tar.gz ' test_expect_success GZIP 'extract tgz file' ' gzip -d -c j.tar && - test_cmp b.tar j.tar + test_cmp_bin b.tar j.tar ' test_expect_success GZIP 'remote tar.gz is allowed by default' ' git archive --remote=. --format=tar.gz HEAD >remote.tar.gz && - test_cmp j.tgz remote.tar.gz + test_cmp_bin j.tgz remote.tar.gz ' test_expect_success GZIP 'remote tar.gz can be disabled' ' diff --combined t/test-lib-functions.sh index c617c826db,0681003b34..0377d3e296 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@@ -542,7 -542,7 +542,7 @@@ test_must_fail () if test $exit_code = 0; then echo >&2 "test_must_fail: command succeeded: $*" return 1 - elif test $exit_code -gt 129 -a $exit_code -le 192; then + elif test $exit_code -gt 129 && test $exit_code -le 192; then echo >&2 "test_must_fail: died by signal: $*" return 1 elif test $exit_code = 127; then @@@ -569,7 -569,7 +569,7 @@@ test_might_fail () { "$@" exit_code=$? - if test $exit_code -gt 129 -a $exit_code -le 192; then + if test $exit_code -gt 129 && test $exit_code -le 192; then echo >&2 "test_might_fail: died by signal: $*" return 1 elif test $exit_code = 127; then @@@ -617,12 -617,6 +617,12 @@@ test_cmp() $GIT_TEST_CMP "$@" } +# test_cmp_bin - helper to compare binary files + +test_cmp_bin() { + cmp "$@" +} + # Check if the file expected to be empty is indeed empty, and barfs # otherwise. @@@ -723,11 -717,6 +723,11 @@@ test_ln_s_add () fi } +# This function writes out its parameters, one per line +test_write_lines () { + printf "%s\n" "$@" +} + perl () { command "$PERL_PATH" "$@" }