Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / dist-formats.tap
old mode 100755 (executable)
new mode 100644 (file)
index 8a287ff..49281d9
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # archives.
 
 am_create_testdir=empty
-. ./defs || Exit 1
+. test-init.sh
 
-plan_ 70
+plan_ 66
 
 # ---------------------------------------------------- #
 #  Common and/or auxiliary subroutines and variables.  #
 # ---------------------------------------------------- #
 
-ocwd=`pwd` || fatal_ "obtaining current working directory"
+ocwd=$(pwd) || fatal_ "getting current working directory"
 
-TAR='' && unset TAR
+unset TAR
 
 # Create common aclocal.m4 file, for later tests.
 mkdir setup \
@@ -56,55 +56,63 @@ setup_vars_for_compression_format ()
   suffix=NONE compressor=NONE
   case $1 in
     gzip) suffix=tar.gz  compressor=gzip     ;;
-    tarZ) suffix=tar.Z   compressor=compress ;;
     lzip) suffix=tar.lz  compressor=lzip     ;;
       xz) suffix=tar.xz  compressor=xz       ;;
    bzip2) suffix=tar.bz2 compressor=bzip2    ;;
      zip) suffix=zip     compressor=zip      ;;
-    shar) suffix=shar.gz compressor=shar     ;;
        *) fatal_ "invalid compression format '$1'";;
   esac
 }
 
-all_compression_formats='gzip tarZ lzip xz bzip2 zip shar'
+have_compressor ()
+{
+  test $# -eq 1 || fatal_ "have_compressor(): bad usage"
+  case $1 in
+    # Assume gzip(1) is available on every reasonable portability target.
+    gzip)
+      return 0;;
+    *)
+      case $1 in
+        # Do not use --version, or older versions bzip2 would try to
+        # compress stdin.  This would cause binary output in the test
+        # logs, with potential breakage of our testsuite harness.
+        bzip2) o=--help;;
+        # OpenSolaris zip do not support the '--version' option, but
+        # accepts the '-v' one with a similar meaning (if no further
+        # arguments are given).
+        zip) o=-v;;
+        # Assume the other compressors we care about support the
+        # '--version' option.
+        *) o=--version;;
+      esac
+      # Redirect to stderr to avoid polluting the output, in case this
+      # function is used in a command substitution (as it is, below).
+      if $1 $o </dev/null >&2; then
+        return 0
+      else
+        return 1
+      fi
+      ;;
+  esac
+  fatal_ "have_compressor(): dead code reached"
+}
+
+all_compression_formats='gzip lzip xz bzip2 zip'
 
-all_compressors=`
+all_compressors=$(
   for x in $all_compression_formats; do
     setup_vars_for_compression_format $x
     echo $compressor
-  done | tr "$nl" ' '`
+  done | tr "$nl" ' ')
 echo All compressors: $all_compressors
 
-missing_compressors=`
+missing_compressors=$(
   for c in $all_compressors; do
-    case $c in
-      # Assume gzip(1) is available on every reasonable portability target.
-      gzip)
-        continue
-        ;;
-      # On Cygwin, as of 9/2/2012, 'compress' is provided by sharutils
-      # and is just a dummy script that is not able to actually compress
-      # (it can only decompress).  So, check that the 'compress' program
-      # is actually able to compress input.
-      # Note that, at least on GNU/Linux, 'compress' does (and is
-      # documented to) exit with status 2 if the output is larger than
-      # the input after (attempted) compression; so we need to pass it
-      # an input that it can actually reduce in size when compressing.
-      compress)
-        for x in 1 2 3 4 5 6 7 8; do
-          echo aaaaaaaaaaaaaaa
-        done | $c -c >/dev/null && continue
-        : For shells with busted 'set -e'.
-        ;;
-      *)
-        $c --version </dev/null >&2 && continue
-        : For shells with busted 'set -e'.
-        ;;
-    esac
-    echo $c
-  done | tr "$nl" ' '`
+    have_compressor $c || echo $c
+  done | tr "$nl" ' ')
 echo Missing compressors: $missing_compressors
 
+# Redefine to avoid re-running the already executed checks.
 have_compressor ()
 {
   case " $missing_compressors " in *\ $1\ *) false;; *) : ;; esac
@@ -122,8 +130,8 @@ start_subtest ()
   if test $# -gt 0; then
     eval "$@" || fatal_ "start_subtest: evaluating assignments"
   fi
-  ac_opts=`echo $ac_opts | tr ',' ' '`
-  am_opts=`echo $am_opts | tr ',' ' '`
+  ac_opts=$(echo $ac_opts | tr ',' ' ')
+  am_opts=$(echo $am_opts | tr ',' ' ')
   mkdir "$name"
   cd "$name"
   unindent > configure.ac <<END
@@ -168,10 +176,10 @@ can_compress ()
   command_ok_if_have_compressor "'make dist-$format' work by default" \
     eval '
       rm -rf *$tarname* \
-        && make dist-$format \
+        && $MAKE dist-$format \
         && test -f $tarname-1.0.$suffix \
         && ls -l *$tarname* \
-        && test "`ls *$tarname*`" = $tarname-1.0.$suffix'
+        && test "$(echo *$tarname*)" = $tarname-1.0.$suffix'
 
   unset suffix compressor format tarname
 }
@@ -188,7 +196,7 @@ command_ok_ "default [configure]"       ./configure
 command_ok_ "default [make distcheck]"  $MAKE distcheck
 
 command_ok_ "'make dist' only builds *.tar.gz by default" \
-            test "`ls *defaults*`" = defaults-1.0.tar.gz
+            test "$(ls *defaults*)" = defaults-1.0.tar.gz
 
 rm -rf *defaults*
 
@@ -281,7 +289,7 @@ END
 nogzip in am  and  bzip2  in  am
 nogzip in ac  and  xz     in  am
 nogzip in am  and  lzip   in  ac
-nogzip in ac  and  tarZ   in  ac
+nogzip in ac  and  zip    in  ac
 
 
 # ----------------------------------------------------------- #
@@ -300,13 +308,13 @@ end_subtest
 #  Parallel compression.  #
 # ----------------------- #
 
-# We only use formats requiring 'gzip', 'bzip2' and 'compress' programs,
-# since there are the most likely to be all found on the great majority
+# We only use formats requiring 'gzip', 'bzip2' and 'xz' programs,
+# since there are the most likely to be all found on the majority
 # of systems.
 
-start_subtest parallel-compression ac_opts=dist-bzip2 am_opts=dist-tarZ
+start_subtest parallel-compression ac_opts=dist-bzip2 am_opts=dist-xz
 
-desc=gzip+bzip2+tarZ
+desc=gzip+bzip2+xz
 tarname=parallel-compression-1.0
 
 check_tarball ()
@@ -329,11 +337,17 @@ check_tarball ()
 
 command_ok_ "$desc [automake]" $AUTOMAKE
 
-skip_reason=
-have_compressor compress || skip_reason="'compress' not available"
-have_compressor bzip2 || skip_reason="'bzip2' not available"
+if ! have_compressor xz && ! have_compressor bzip2; then
+  skip_reason="both 'bzip2' and 'xz' are unavailable"
+elif ! have_compressor xz; then
+  skip_reason="'xz' not available"
+elif ! have_compressor bzip2; then
+  skip_reason="'bzip2' not available"
+else
+  skip_reason=
+fi
 if test "$MAKE_j4" = false; then
-  test -z "$skip_reason" || skip_reason="$skip_reason and "
+  test -z "$skip_reason" || skip_reason="$skip_reason, and "
   skip_reason="${skip_reason}make concurrency unavailable"
 fi
 
@@ -346,7 +360,7 @@ else
   ls -l # For debugging.
   command_ok_ "$desc [check .tar.gz tarball]"  check_tarball gzip
   command_ok_ "$desc [check .tar.bz2 tarball]" check_tarball bzip2
-  command_ok_ "$desc [check .tar.Z tarball]"   check_tarball tarZ
+  command_ok_ "$desc [check .tar.xz tarball]"  check_tarball xz
 fi
 
 unset tarname desc skip_reason
@@ -374,7 +388,7 @@ for fmt in $all_compression_formats; do
     echo "  dist-$fmt" >> am-init.m4
     flip=false
   else
-    echo "AUTOMAKE_OPTIONS += dist-$fmt" >> Makefil.am
+    echo "AUTOMAKE_OPTIONS += dist-$fmt" >> Makefile.am
     flip=:
   fi
 done
@@ -386,7 +400,7 @@ sed 's/AM_INIT_AUTOMAKE.*/m4_include([am-init.m4])/' configure.ac > t
 mv -f t configure.ac
 
 # For debugging.
-cat Makefil.am
+cat Makefile.am
 cat configure.ac
 cat am-init.m4
 
@@ -421,8 +435,8 @@ END
 chmod a+x check-distdir grep-distdir-error
 for prog in tar $all_compressors; do
   case $prog in
-    tar|shar|zip) cp check-distdir $prog;;
-               *) cp grep-distdir-error $prog;;
+    tar|zip) cp check-distdir $prog;;
+          *) cp grep-distdir-error $prog;;
   esac
 done
 unset prog
@@ -430,7 +444,7 @@ ls -l # For debugging.
 cd ..
 
 oPATH=$PATH
-PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
 
 command_ok_ \
   "$desc ['make dist-all', stubbed]" \