texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[6047] findprog in info tests


From: Gavin D. Smith
Subject: [6047] findprog in info tests
Date: Thu, 15 Jan 2015 19:21:32 +0000

Revision: 6047
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6047
Author:   gavin
Date:     2015-01-15 19:21:31 +0000 (Thu, 15 Jan 2015)
Log Message:
-----------
findprog in info tests

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/t/Init-inter.inc
    trunk/info/t/resize-in-completions.sh

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-01-15 18:41:25 UTC (rev 6046)
+++ trunk/ChangeLog     2015-01-15 19:21:31 UTC (rev 6047)
@@ -1,3 +1,11 @@
+2015-01-15  Gavin Smith  <address@hidden>
+
+       * info/t/Init-inter.inc: (findprog) Add function from util/texi2dvi.
+       (run_ginfo) Call findprog to check for pgrep.  If not found, 
+       wait a short while for controlled process to start.
+       * info/t/resize-in-completions.sh: Print an informative message 
+       to standard error if test is skipped.
+
 2015-01-15  Karl Berry  <address@hidden>
 
        * Makefile.am (po-check): include ti.twjr, exclude parsetexi, etc.

Modified: trunk/info/t/Init-inter.inc
===================================================================
--- trunk/info/t/Init-inter.inc 2015-01-15 18:41:25 UTC (rev 6046)
+++ trunk/info/t/Init-inter.inc 2015-01-15 19:21:31 UTC (rev 6047)
@@ -43,6 +43,40 @@
 # files.
 LIBC_FATAL_STDERR_=1; export LIBC_FATAL_STDERR
 
+# Systems which define $COMSPEC or $ComSpec use semicolons to separate
+# directories in TEXINPUTS -- except for Cygwin et al., where COMSPEC
+# might be inherited, but : is used.
+if test -n "$COMSPEC$ComSpec" \
+   && uname | $EGREP -iv 'cygwin|mingw|djgpp' >/dev/null; then
+  path_sep=";"
+else
+  path_sep=":"
+fi
+
+# findprog PROG - Return true if PROG is somewhere in PATH, else false.
+findprog ()
+{
+  local saveIFS="$IFS"
+  IFS=$path_sep  # break path components at the path separator
+  for dir in $PATH; do
+    IFS=$saveIFS
+    # The basic test for an executable is `test -f $f && test -x $f'.
+    # (`test -x' is not enough, because it can also be true for directories.)
+    # We have to try this both for $1 and $1.exe.
+    #
+    # Note: On Cygwin and DJGPP, `test -x' also looks for .exe.  On Cygwin,
+    # also `test -f' has this enhancement, but not on DJGPP.  (Both are
+    # design decisions, so there is little chance to make them consistent.)
+    # Thusly, it seems to be difficult to make use of these enhancements.
+    #
+    if   { test -f "$dir/$1"     && test -x "$dir/$1"; } \
+      || { test -f "$dir/$1.exe" && test -x "$dir/$1.exe"; }; then
+      return 0
+    fi
+  done
+  return 1
+}
+
 run_ginfo ()
 {
   rm -f $FINISHEDFIFO
@@ -51,38 +85,51 @@
     echo finished >$FINISHEDFIFO ; } 0<>$PTS_DEVICE 1<&0 &
   SUBSHELL=$!
 
-  # Get the PID of the running ginfo process.  Look for a process called
-  # "ginfo" whose parent process is the subshell executed by the previous
-  # command.
-  echo 'Fetching PID of ginfo process under test...' >&2
-  GINFO_PID=
-  # Try 3 times and then give up.  The process may never have started, have
-  # started under a different name, or have already exited.
-  for i in 1 2 3; do
-    GINFO_PID=`pgrep -P $SUBSHELL $GINFO_NAME ; \
-      test $? -eq 0 || test $? -eq 1 || exit 99`
+  # Check for pgrep
+  if findprog pgrep; then
+    # Get the PID of the running ginfo process.  Look for a process called
+    # "ginfo" whose parent process is the subshell executed by the previous
+    # command.
+    echo 'Fetching PID of ginfo process under test...' >&2
+    GINFO_PID=
 
-    # This use of pgrep is likely not portable (works on procps).  Check if it
-    # is likely to have worked.
+    # Try 3 times and then give up.  The process may never have started, 
+    # have started under a different name, or have already exited.
+    for i in 1 2 3; do
+      GINFO_PID=`pgrep -P $SUBSHELL $GINFO_NAME ; \
+       test $? -eq 0 || test $? -eq 1 || exit 99`
 
-    # Exit status was anything other than 0 or 1
-    test $? -eq 99 && { GINFO_PID=unknown; break; }
+      # This use of pgrep is likely not portable (works on procps).
+      # Check if it is likely to have worked.
 
-    # More than one line in output
-    echo $GINFO_PID | wc -l | grep '^0$\|^1$' >/dev/null \
-      || { GINFO_PID=unknown; break; }
+      # Exit status was anything other than 0 or 1
+      test $? -eq 99 && { GINFO_PID=unknown; break; }
 
-    # Non-numeral characters present
-    echo $GINFO_PID | grep -v '^[0-9]*$' >/dev/null
-    test $? -eq 0 && { GINFO_PID=unknown; break; }
+      # More than one line in output
+      echo $GINFO_PID | wc -l | grep '^0$\|^1$' >/dev/null \
+       || { GINFO_PID=unknown; break; }
 
-    GINFO_PID=`echo $GINFO_PID | tr -d '\n'`
+      # Non-numeral characters present
+      echo $GINFO_PID | grep -v '^[0-9]*$' >/dev/null
+      test $? -eq 0 && { GINFO_PID=unknown; break; }
 
-    test "$GINFO_PID" = "" || break
-    sleep 1 # Give subshell time to spawn ginfo process
-  done
-  test "$GINFO_PID" = "" && GINFO_PID=unknown
-  echo ...$GINFO_PID >&2
+      GINFO_PID=`echo $GINFO_PID | tr -d '\n'`
+
+      test "$GINFO_PID" = "" || break
+      sleep 1 # Give subshell time to spawn ginfo process
+    done
+    test "$GINFO_PID" = "" && GINFO_PID=unknown
+    echo ...$GINFO_PID >&2
+  else
+    echo 'pgrep program not found - cannot get PID of ginfo process' >&2
+    GINFO_PID=unknown
+  fi
+  # If the PID is unknown, wait for a short time to wait for the program 
+  # to start.  Normally this isn't needed, but on a few tests, it breaks
+  # otherwise, possibly because some bytes have special meaning to the 
+  # terminal, like C-u for kill and C-s for stop, and haven't been 
+  # turned off yet.
+  test $GINFO_PID = unknown && sleep 1
 }
 
 

Modified: trunk/info/t/resize-in-completions.sh
===================================================================
--- trunk/info/t/resize-in-completions.sh       2015-01-15 18:41:25 UTC (rev 
6046)
+++ trunk/info/t/resize-in-completions.sh       2015-01-15 19:21:31 UTC (rev 
6047)
@@ -23,6 +23,7 @@
 run_ginfo -f file-menu
 if test $GINFO_PID = unknown; then
   printf 'q' >$PTY_TYPE
+  echo 'test skipped - don'\''t have PID of ginfo process' >&2
   RETVAL=77 # automake code for skipped test
 else
   printf 'g\t' >$PTY_TYPE




reply via email to

[Prev in Thread] Current Thread [Next in Thread]