tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / install-info-dir.sh
old mode 100755 (executable)
new mode 100644 (file)
index 9e40f54..b16824f
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-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
 # inlined, below.
 
 # FIXME: this test is a good candidate for a conversion to TAP,
-# FIXME: and could be merged with 'txinfo27.test'.
+# FIXME: and could be merged with 'txinfo27.sh'.
 
 required=makeinfo
-. ./defs || Exit 1
+. test-init.sh
 
-cwd=`pwd` || fatal_ "cannot get current working directory"
+cwd=$(pwd) || fatal_ "cannot get current working directory"
 
 mkdir bin
 saved_PATH=$PATH; export saved_PATH
@@ -67,7 +67,15 @@ $MAKE info
 test -f foo.info
 
 if install-info --version; then
-  have_installinfo=yes
+  # Skip some checks even if 'install-info' is the one from dpkg, not
+  # the one from GNU info, as the former might try to create files in
+  # '/var/backups/', causing spurious failures like this for non-root
+  # users.
+  if install-info --version | $EGREP -i '(dpkg|debian) install-info'; then
+    have_installinfo=no
+  else
+    have_installinfo=yes
+  fi
 else
   have_installinfo=no
 fi
@@ -83,8 +91,8 @@ if test $have_installinfo = yes; then
   $FGREP 'Does nothing at all, but has a nice name' $instdir/info/dir
 
   $MAKE uninstall
-  test ! -f $instdir/info/foo.info
-  $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+  test ! -e $instdir/info/foo.info
+  $FGREP 'but has a nice name' $instdir/info/dir && exit 1
 
   dir="$destdir/$cwd/$instdir/info"
 
@@ -93,8 +101,8 @@ if test $have_installinfo = yes; then
   test -f "$dir"/dir
   $FGREP 'Does nothing at all, but has a nice name' "$dir"/dir
   $MAKE DESTDIR="$cwd/$destdir" uninstall
-  test ! -f "$dir"/foo.info
-  $FGREP 'but has a nice name' "$dir"/dir && Exit 1
+  test ! -e "$dir"/foo.info
+  $FGREP 'but has a nice name' "$dir"/dir && exit 1
 
   unset dir
 
@@ -110,11 +118,10 @@ echo error from install-info >&2
 exit 127
 END
 chmod a+x bin/install-info
-$MAKE install-info >output 2>&1 || { cat output; Exit 1; }
-cat output
+run_make -M install-info
 test -f $instdir/info/foo.info
-test ! -f $instdir/info/dir
-grep 'error from install-info' output && Exit 1
+test ! -e $instdir/info/dir
+grep 'error from install-info' output && exit 1
 
 rm -rf $instdir output
 
@@ -136,9 +143,9 @@ END
   test -f $instdir/info/foo.info
   test -f $instdir/info/dir
   $MAKE uninstall
-  test ! -f $instdir/info/foo.info
+  test ! -e $instdir/info/foo.info
   test -f $instdir/info/dir
-  $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+  $FGREP 'but has a nice name' $instdir/info/dir && exit 1
   : For shells with busted 'set -e'.
 fi
 
@@ -151,10 +158,14 @@ for val in no NO n; do
   rm -rf $instdir
   env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
   test -f $instdir/info/foo.info
-  test ! -f $instdir/info/dir
+  test ! -e $instdir/info/dir
 done
 
 $MAKE install-info
+if test $have_installinfo != yes; then
+  echo 'Does nothing at all, but has a nice name' > $instdir/info/dir
+fi
+
 chmod a-w $instdir/info/dir
 for val in no NO n; do
   env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
@@ -168,8 +179,8 @@ if test $have_installinfo = yes; then
     test -f $instdir/info/foo.info
     test -f $instdir/info/dir
     env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
-    test ! -f $instdir/info/foo.info
-    $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+    test ! -e $instdir/info/foo.info
+    $FGREP 'but has a nice name' $instdir/info/dir && exit 1
     : For shells with busted 'set -e'.
   done
 fi