Merge branch 'ep/avoid-test-a-o'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 19:23:56 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 19:23:56 +0000 (12:23 -0700)
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 <cond> -a/-o <cond>"
t/test-lib-functions.sh: avoid "test <cond> -a/-o <cond>"
t/t9814-git-p4-rename.sh: avoid "test <cond> -a/-o <cond>"
t/t5538-push-shallow.sh: avoid "test <cond> -a/-o <cond>"
t/t5403-post-checkout-hook.sh: avoid "test <cond> -a/-o <cond>"
t/t5000-tar-tree.sh: avoid "test <cond> -a/-o <cond>"
t/t4102-apply-rename.sh: avoid "test <cond> -a/-o <cond>"
t/t0026-eol-config.sh: avoid "test <cond> -a/-o <cond>"
t/t0025-crlf-auto.sh: avoid "test <cond> -a/-o <cond>"
t/lib-httpd.sh: avoid "test <cond> -a/-o <cond>"
git-rebase--interactive.sh: avoid "test <cond> -a/-o <cond>"
git-mergetool.sh: avoid "test <cond> -a/-o <cond>"
git-bisect.sh: avoid "test <cond> -a/-o <cond>"
contrib/examples/git-resolve.sh: avoid "test <cond> -a/-o <cond>"
contrib/examples/git-repack.sh: avoid "test <cond> -a/-o <cond>"
contrib/examples/git-merge.sh: avoid "test <cond> -a/-o <cond>"
contrib/examples/git-commit.sh: avoid "test <cond> -a/-o <cond>"
contrib/examples/git-clone.sh: avoid "test <cond> -a/-o <cond>"
check_bindir: avoid "test <cond> -a/-o <cond>"

1  2 
git-rebase--interactive.sh
t/lib-httpd.sh
t/t5000-tar-tree.sh
t/test-lib-functions.sh
index f267d8b6c3eea5c557e63814e40a9ef38b776354,797571f50ceac7a31a7051e4a852977a70fb55f0..7e1eda008815cca80561d6013d41479ea8c90f4a
@@@ -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,
  
  
  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 272fceef96c06e6e104d6341f36b1764e7d0c8db,38a47fe20ed510a82e5908e29ccc649f507b7b5c..fd53b5718780e25f03924e38438706acc54598db
@@@ -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"
  
        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 bad84a36e81dbebbad89bf66cb1411ebf27fe66a,ad6fa0d4e43652e74b73980ee881860ebc78b692..899c1c5bbcb2e994a1462eb8048344b68d23767d
@@@ -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 \
  
  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.foo >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.bar >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' '
  
  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.tgz >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 c617c826db94f2e3c0ed01fe079d3ae14ac3b883,0681003b347ffb9152dee3f5866ccda415aa3dc9..0377d3e2960cc282ce1a2c7cb629245728c82092
@@@ -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
  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" "$@"
  }