code:
/* session.h -- Functions found in session.c.
   $Id$

   Copyright 1993, 1998, 1999, 2001, 2002, 2004, 2007, 2011, 2013, 2014,
   2015, 2016
   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
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

   Originally written by Brian Fox. */

#ifndef SESSION_H
#define SESSION_H

#include "info.h"
#include "window.h"
#include "dribble.h"

/* Variable controlling the garbage collection of files briefly visited
   during searches.  Such files are normally gc'ed, unless they were
   compressed to begin with.  If this variable is non-zero, it says
   to gc even those file buffer contents which had to be uncompressed. */
extern int gc_compressed_files;

/* When non-zero, tiling takes place automatically when info_split_window
   is called. */
extern int auto_tiling_p;

/* Variable controlling the behaviour of default scrolling when you are
   already at the bottom of a node. */
extern int info_scroll_behaviour;

/* Values for info_scroll_behaviour. */
#define IS_Continuous 0 /* Try to get first menu item, or failing that, the
                           "Next:" pointer, or failing that, the "Up:" and
                           "Next:" of the up. */
#define IS_NextOnly   1 /* Try to get "Next:" menu item. */
#define IS_PageOnly   2 /* Simply give up at the bottom of a node. */

extern int cursor_movement_scrolls_p;

/* Controls what to do when a scrolling command is issued at the end of the
   last node. */
extern int scroll_last_node;

/* Values for scroll_last_node */
#define SLN_Stop   0 /* Stop at the last node */
#define SLN_Top    1 /* Go to the top node */

int get_input_key (void);
int get_another_input_key (void);

VFunction *read_key_sequence (Keymap map, int menu, int mouse,
                              int insert, int *count);
unsigned char info_input_pending_p (void);
void info_set_node_of_window (WINDOW *window, NODE *node);
void info_set_node_of_window_fast (WINDOW *window, NODE *node);
void initialize_keyseq (void);
void add_char_to_keyseq (int character);
FILE_BUFFER *file_buffer_of_window (WINDOW *window);
int info_select_reference (WINDOW *window, REFERENCE *entry);
int info_any_buffered_input_p (void);

void dump_nodes_to_file (REFERENCE **references,
				char *output_filename, int flags);
int write_node_to_stream (NODE *node, FILE *stream);

char *program_name_from_file_name (char *file_name);

/* Do the physical deletion of WINDOW, and forget this window and
   associated nodes. */
void info_delete_window_internal (WINDOW *window);

void forget_window_and_nodes (WINDOW *window);
void forget_node (WINDOW *win);
int forget_node_fast (WINDOW *win);

/* Tell Info that input is coming from the file FILENAME. */
void info_set_input_from_file (char *filename);

/* Error and debugging messages */
extern unsigned debug_level;

#define debug(n,c)							\
  do									\
    {									\
      if (debug_level >= (n))						\
        info_debug c;							\
    }									\
  while (0)

void info_debug (const char *format, ...) TEXINFO_PRINTFLIKE(1,2);

/* Print args as per FORMAT.  If the window system was initialized,
   then the message is printed in the echo area.  Otherwise, a message is
   output to stderr. */
void info_error (const char *format, ...) TEXINFO_PRINTFLIKE(1,2);

void initialize_info_session (void);
void info_read_and_dispatch (void);
void close_info_session (void);
void info_session (REFERENCE **ref_list, char *user_filename, char *error);
void initialize_terminal_and_keymaps (char *init_file);
REFERENCE *info_intuit_options_node (NODE *initial_node, char *program);

void info_scroll_forward (WINDOW *window, int count);
void info_abort_key (WINDOW *window, int count);

NODE *info_follow_menus (NODE *initial_node, char **menus,
                         char **error_msg, int strict);

/* Adding numeric arguments. */
extern int info_explicit_arg;
extern int ea_explicit_arg;
void info_initialize_numeric_arg (void);

/* Found in m-x.c.  */
char *read_function_name (char *prompt, WINDOW *window);

void show_error_node (char *error_msg);

#endif /* not SESSION_H */

repo_name: mthl/texinfo

license: mit


code:
/* signals.c -- install and maintain signal handlers.
   $Id$

   Copyright 1993, 1994, 1995, 1998, 2002, 2003, 2004, 2007, 2012, 2013, 2014
   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
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

   Originally written by Brian Fox. */

#include "info.h"
#include "display.h"
#include "footnotes.h"
#include "window.h"
#include "signals.h"

void initialize_info_signal_handler (void);

/* **************************************************************** */
/*                                                                  */
/*              Pretending That We Have POSIX Signals               */
/*                                                                  */
/* **************************************************************** */

#if !defined (HAVE_SIGPROCMASK) && defined (HAVE_SIGSETMASK)
/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */
static void
sigprocmask (int operation, int *newset, int *oldset)
{
  switch (operation)
    {
    case SIG_UNBLOCK:
      sigsetmask (sigblock (0) & ~(*newset));
      break;

    case SIG_BLOCK:
      *oldset = sigblock (*newset);
      break;

    case SIG_SETMASK:
      sigsetmask (*newset);
      break;

    default:
      abort ();
    }
}
#endif /* !HAVE_SIGPROCMASK && HAVE_SIGSETMASK */

/* **************************************************************** */
/*                                                                  */
/*                  Signal Handling for Info                        */
/*                                                                  */
/* **************************************************************** */

#if defined (HAVE_SIGACTION) || defined (HAVE_SIGPROCMASK) ||\
  defined (HAVE_SIGSETMASK)
static void
mask_termsig (sigset_t *set)
{
# if defined (SIGTSTP)
  sigaddset (set, SIGTSTP);
  sigaddset (set, SIGTTOU);
  sigaddset (set, SIGTTIN);
# endif
# if defined (SIGWINCH)
  sigaddset (set, SIGWINCH);
# endif
#if defined (SIGQUIT)
  sigaddset (set, SIGQUIT);
#endif
#if defined (SIGINT)
  sigaddset (set, SIGINT);
#endif
#if defined (SIGTERM)
  sigaddset (set, SIGTERM);
#endif
# if defined (SIGUSR1)
  sigaddset (set, SIGUSR1);
# endif
}
#endif /* HAVE_SIGACTION || HAVE_SIGPROCMASK || HAVE_SIGSETMASK */

static RETSIGTYPE info_signal_proc (int sig);
#if defined (HAVE_SIGACTION)
typedef struct sigaction signal_info;
signal_info info_signal_handler;

static void
set_termsig (int sig, signal_info *old)
{
  sigaction (sig, &info_signal_handler, old);
}

static void
restore_termsig (int sig, const signal_info *saved)
{
  sigaction (sig, saved, NULL);
}
#else /* !HAVE_SIGACTION */
typedef RETSIGTYPE (*signal_info) ();
#define set_termsig(sig, old) (void)(*(old) = signal (sig, info_signal_proc))
#define restore_termsig(sig, saved) (void)signal (sig, *(saved))
#define info_signal_handler info_signal_proc
static int term_conf_busy = 0;
#endif /* !HAVE_SIGACTION */

static signal_info old_TSTP, old_TTOU, old_TTIN;
static signal_info old_WINCH, old_INT, old_TERM, old_USR1;
static signal_info old_QUIT;

void
initialize_info_signal_handler (void)
{
#ifdef SA_NOCLDSTOP
  /* (Based on info from Paul Eggert found in coreutils.)  Don't use
     HAVE_SIGACTION to decide whether to use the sa_handler, sa_flags,
     sa_mask members, as some systems (Solaris 7+) don't define them.  Use
     SA_NOCLDSTOP instead; it's been part of POSIX.1 since day 1 (in 1988).  */
  info_signal_handler.sa_handler = info_signal_proc;
  info_signal_handler.sa_flags = 0;
  mask_termsig (&info_signal_handler.sa_mask);
#endif /* SA_NOCLDSTOP */

#if defined (SIGTSTP)
  set_termsig (SIGTSTP, &old_TSTP);
  set_termsig (SIGTTOU, &old_TTOU);
  set_termsig (SIGTTIN, &old_TTIN);
#endif /* SIGTSTP */

#if defined (SIGWINCH)
  set_termsig (SIGWINCH, &old_WINCH);
#endif

#if defined (SIGQUIT)
  set_termsig (SIGQUIT, &old_QUIT);
#endif

#if defined (SIGINT)
  set_termsig (SIGINT, &old_INT);
#endif

#if defined (SIGTERM)
  set_termsig (SIGTERM, &old_TERM);
#endif

#if defined (SIGUSR1)
  /* Used by DJGPP to simulate SIGTSTP on Ctrl-Z.  */
  set_termsig (SIGUSR1, &old_USR1);
#endif
}

void
redisplay_after_signal (void)
{
  terminal_clear_screen ();
  display_clear_display (the_display);
  if (auto_footnotes_p)
    info_get_or_remove_footnotes (active_window);
  window_mark_chain (windows, W_UpdateWindow);
  display_update_display ();
  display_cursor_at_point (active_window);
  fflush (stdout);
}

void
reset_info_window_sizes (void)
{
  terminal_get_screen_size ();
  display_initialize_display (screenwidth, screenheight);
  window_new_screen_size (screenwidth, screenheight);
  redisplay_after_signal ();
}

/* Number of times we were told to ignore SIGWINCH. */
static int sigwinch_block_count = 0;

void
signal_block_winch (void)
{
#if defined (SIGWINCH)
  if (sigwinch_block_count == 0)
    BLOCK_SIGNAL (SIGWINCH);
  sigwinch_block_count++;
#endif
}

void
signal_unblock_winch (void)
{
#if defined (SIGWINCH)
  sigwinch_block_count--;
  if (sigwinch_block_count == 0)
    UNBLOCK_SIGNAL (SIGWINCH);
#endif
}

static RETSIGTYPE
info_signal_proc (int sig)
{
  signal_info *old_signal_handler = NULL;

#if !defined (HAVE_SIGACTION)
  /* best effort: first increment this counter and later block signals */
  if (term_conf_busy)
    return;
  term_conf_busy++;
#if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
    {
      sigset_t nvar, ovar;
      sigemptyset (&nvar);
      mask_termsig (&nvar);
      sigprocmask (SIG_BLOCK, &nvar, &ovar);
    }
#endif /* HAVE_SIGPROCMASK || HAVE_SIGSETMASK */
#endif /* !HAVE_SIGACTION */
  switch (sig)
    {
#if defined (SIGTSTP)
    case SIGTSTP:
    case SIGTTOU:
    case SIGTTIN:
#endif
#if defined (SIGQUIT)
    case SIGQUIT:
#endif
#if defined (SIGINT)
    case SIGINT:
#endif
#if defined (SIGTERM)
    case SIGTERM:
#endif
      {
#if defined (SIGTSTP)
        if (sig == SIGTSTP)
          old_signal_handler = &old_TSTP;
        if (sig == SIGTTOU)
          old_signal_handler = &old_TTOU;
        if (sig == SIGTTIN)
          old_signal_handler = &old_TTIN;
#endif /* SIGTSTP */
#if defined (SIGQUIT)
        if (sig == SIGQUIT)
          old_signal_handler = &old_QUIT;
#endif /* SIGQUIT */
#if defined (SIGINT)
        if (sig == SIGINT)
          old_signal_handler = &old_INT;
#endif /* SIGINT */
#if defined (SIGTERM)
        if (sig == SIGTERM)
          old_signal_handler = &old_TERM;
#endif /* SIGTERM */

        /* For stop signals, restore the terminal IO, leave the cursor
           at the bottom of the window, and stop us. */
        terminal_goto_xy (0, screenheight - 1);
        terminal_clear_to_eol ();
        fflush (stdout);
        terminal_unprep_terminal ();
	restore_termsig (sig, old_signal_handler);
	UNBLOCK_SIGNAL (sig);
	kill (getpid (), sig);

        /* The program is returning now.  Restore our signal handler,
           turn on terminal handling, redraw the screen, and place the
           cursor where it belongs. */
        terminal_prep_terminal ();
	set_termsig (sig, old_signal_handler);
	/* window size might be changed while sleeping */
	reset_info_window_sizes ();
      }
      break;

#if defined (SIGWINCH) || defined (SIGUSR1)
#ifdef SIGWINCH
    case SIGWINCH:
#endif
#ifdef SIGUSR1
    case SIGUSR1:
#endif
      {
	/* Turn off terminal IO, tell our parent that the window has changed,
	   then reinitialize the terminal and rebuild our windows. */
#ifdef SIGWINCH
	if (sig == SIGWINCH)
	  old_signal_handler = &old_WINCH;
#endif
#ifdef SIGUSR1
	if (sig == SIGUSR1)
	  old_signal_handler = &old_USR1;
#endif

        /* This seems risky: what if we receive a (real) signal before
           the next line is reached? */
#if 0
	restore_termsig (sig, old_signal_handler);
	kill (getpid (), sig);
#endif

	/* After our old signal handler returns... */
	set_termsig (sig, old_signal_handler); /* needless? */

        if (sigwinch_block_count != 0)
          abort ();

        /* Avoid any of the code unblocking the signal too early.  This
           should set the variable to 1 because we shouldn't be here if
           sigwinch_block_count > 0. */
        sigwinch_block_count++;

	reset_info_window_sizes ();

        sigwinch_block_count--;
        /* Don't unblock the signal until after we've finished. */
	UNBLOCK_SIGNAL (sig);
      }
      break;
#endif /* SIGWINCH || SIGUSR1 */
    }
#if !defined (HAVE_SIGACTION)
  /* at this time it is safer to perform unblock after decrement */
  term_conf_busy--;
#if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
    {
      sigset_t nvar, ovar;
      sigemptyset (&nvar);
      mask_termsig (&nvar);
      sigprocmask (SIG_UNBLOCK, &nvar, &ovar);
    }
#endif /* HAVE_SIGPROCMASK || HAVE_SIGSETMASK */
#endif /* !HAVE_SIGACTION */
}

/* vim: set sw=2 cino={1s>2sn-s^-se-s: */


code:
/* signals.h -- header to include system dependent signal definitions.
   $Id$

   Copyright 1993, 1994, 1995, 1997, 2002, 2004, 2007, 2013, 2014
   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
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

   Originally written by Brian Fox. */

#ifndef INFO_SIGNALS_H
#define INFO_SIGNALS_H

#include <sys/types.h>
#include <signal.h>

void signal_block_winch (void);
void signal_unblock_winch (void);

/* For sysV68 --phdm@info.ucl.ac.be.  */
#if !defined (SIGCHLD) && defined (SIGCLD)
#define SIGCHLD SIGCLD
#endif

#if !defined (HAVE_SIGPROCMASK) && !defined (sigmask)
#  define sigmask(x) (1 << ((x)-1))
#endif /* !HAVE_SIGPROCMASK && !sigmask */

/* Without SA_NOCLDSTOP, sigset_t might end up being undefined even
   though we have sigprocmask, on older systems, according to Nelson
   Beebe.  The test is from coreutils/sort.c, via Paul Eggert.  */
#if !defined (HAVE_SIGPROCMASK) || !defined (SA_NOCLDSTOP)
#  if !defined (SIG_BLOCK)
#    define SIG_UNBLOCK 1
#    define SIG_BLOCK   2
#    define SIG_SETMASK 3
#  endif /* SIG_BLOCK */

/* Type of a signal set. */
#  define sigset_t int

/* Make SET have no signals in it. */
#  define sigemptyset(set) (*(set) = (sigset_t)0x0)

/* Make SET have the full range of signal specifications possible. */
#  define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)

/* Add SIG to the contents of SET. */
#  define sigaddset(set, sig) *(set) |= sigmask (sig)

/* Delete SIG from the contents of SET. */
#  define sigdelset(set, sig) *(set) &= ~(sigmask (sig))

/* Tell if SET contains SIG. */
#  define sigismember(set, sig) (*(set) & (sigmask (sig)))

/* Suspend the process until the reception of one of the signals
   not present in SET. */
#  define sigsuspend(set) sigpause (*(set))
#endif /* !HAVE_SIGPROCMASK */

#if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
/* These definitions are used both in POSIX and non-POSIX implementations. */

#define BLOCK_SIGNAL(sig) \
  do { \
    sigset_t nvar, ovar; \
    sigemptyset (&nvar); \
    sigemptyset (&ovar); \
    sigaddset (&nvar, sig); \
    sigprocmask (SIG_BLOCK, &nvar, &ovar); \
  } while (0)

#define UNBLOCK_SIGNAL(sig) \
  do { \
    sigset_t nvar, ovar; \
    sigemptyset (&ovar); \
    sigemptyset (&nvar); \
    sigaddset (&nvar, sig); \
    sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
  } while (0)

#else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
#  define BLOCK_SIGNAL(sig)
#  define UNBLOCK_SIGNAL(sig)
#endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */

#endif /* not INFO_SIGNALS_H */


code:
#info
?	xxx-not-recognized # Check that unknown actions don't break.
!	menu-digit	# menu-digit can't be rebound
D	print-node	# Dump node to file
#echo-area
#var
infopath-no-defaults=On
automatic-footnotes=On
key-time=0
nodeline=print

path: info/t/Infokey-config


code:
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Initialize test of interactive operation
# This file is to be sourced, not run directly

# Skip test if pseudotty wasn't built
test -x pseudotty || exit 77

#  we may look up whether a couple of utilities exist.

path_sep=":"

# findprog PROG - Return true if PROG is somewhere in PATH, else false.
findprog ()
{
  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
}

#
# Avoid ginfo complaining that terminal is too dumb
TERM=vt100; export TERM

FINISHEDFIFO=t/`basename $0.finished`

# See cleanup in Init-test.inc.
findprog stty && { STTY=stty ; reset_required=yes ; }
test $reset_required=yes && { $STTY | grep [-]echo ; } && reset_required=no

# Create named pipes to communicate with pseudotty program, or quit.
rm -f $PIPEIN $PTY_TYPE # must already be defined
if findprog mkfifo; then
  mkfifo $PIPEIN
  mkfifo $PTY_TYPE
  #
  if test ! -r $PIPEIN || test ! -r $PTY_TYPE; then
    echo "$0: could not mkfifo pipes" >&2
    exit 77
  fi
  # ok, we'll proceed with the test.
else
  echo "$0: mkfifo program not found - cannot make named pipes" >&2
  exit 77
fi

# We can feed input bytes into $PTY_TYPE to be passed onto ginfo, as
# if they were typed by a user in an interactive session.
# We redirect to the FIFO within a subshell, because under NetBSD 6.1.4
# it hangs otherwise.
(exec ./pseudotty "$PTY_TYPE" >$PIPEIN) &
PTY_PID=$!
# Get name of pseudo-terminal slave device
read PTS_DEVICE <$PIPEIN

# Keeping the FIFO open for writing prevents the select call in
# pseudotty returning EOF after a single "printf something >$PTY_TYPE".
exec 7>$PTY_TYPE

# glibc can kill a running process if it detects a condition like a
# double free.  This specifies that the message it prints when it does
# this should be sent to stderr so it can be recorded in the test *.log
# files.
LIBC_FATAL_STDERR_=1; export LIBC_FATAL_STDERR

run_ginfo ()
{
  rm -f $FINISHEDFIFO
  mkfifo $FINISHEDFIFO
  { # Close fd opened to control FIFO in subshell so pseudotty can exit
    # for an EOF.  This prevents lingering processes if a test is
    # interrupted.
    exec 7>&- ;
    exec 8>$FINISHEDFIFO ;
    $GINFO $GINFO_OPTIONS "$@" ;
    test $? -eq 0 || echo failure >$FINISHEDFIFO ;
    echo finished >$FINISHEDFIFO ; } 0<>$PTS_DEVICE 1<&0 &
  SUBSHELL=$!
  exec 8<$FINISHEDFIFO

  # Although we don't write to the FIFO in this process, we still need
  # to open it for writing, because if the above subshell exits before
  # we read from it, we won't be able to open it - even though
  # "finished" is buffered.
  exec 9>$FINISHEDFIFO

  # 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=

    # 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`

      # This use of pgrep is likely not portable (works on procps).
      # Check if it is likely to have worked.

      # Exit status was anything other than 0 or 1
      test $? -eq 99 && { GINFO_PID=unknown; break; }

      # More than one line in output
      echo $GINFO_PID | wc -l | grep '^0$\|^1$' >/dev/null \
	|| { GINFO_PID=unknown; break; }

      # Non-numeral characters present
      echo $GINFO_PID | grep -v '^[0-9]*$' >/dev/null
      test $? -eq 0 && { GINFO_PID=unknown; break; }

      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
}


code:
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Set up standalone info test environment
# This file is to be sourced, not to be run directly

# write each expanded command to the *.log file for the test.
set -x

# Allow running with "make check" and individual tests at the command-line
srcdir=${srcdir:-.}

# Use the second line to run the program under valgrind.
GINFO="./ginfo --init-file $srcdir/t/Infokey-config"
#GINFO="valgrind --log-file=$0.val.log --leak-check=full ./ginfo --init-file $srcdir/t/Infokey-config"

# Set this to the name of the process
GINFO_NAME=ginfo
#GINFO_NAME=memcheck-x86-li

# Only look for Info files in our test directory
infodir=$srcdir/t/infodir; export infodir
INFOPATH=$infodir; export INFOPATH

t=$srcdir/t; export t

GINFO_OUTPUT=t/`basename $0.out`

# These are only used for interactive tests
PIPEIN=t/`basename $0.pipein`
PTY_TYPE=t/`basename $0.pipeout`

# Remove left over file from previous tests
rm -f $GINFO_OUTPUT

# File to dump nodes to with M-x print-node
INFO_PRINT_COMMAND=">$GINFO_OUTPUT"; export INFO_PRINT_COMMAND

# Not an interactive test
PTY_PID=0
SUBSHELL=0

# Get error messages in English
LC_ALL=C; export LC_ALL

# Make sure that non-interactive operation works even if terminal is dumb
TERM=dumb; export TERM

# For interactive tests, we try to set this in Init-inter.inc
STTY=true
reset_required=no

# Clean up if the test is interrupted, for example if the user types
# C-c, to avoid lingering child processes.  Signal 2 is SIGINT.
trap cleanup 2

# Cleanup and exit
cleanup ()
{
  # Delete created files and kill spawned processes if any.
  test $PTY_PID -ne 0 && kill $PTY_PID
  test $SUBSHELL -ne 0 && kill $SUBSHELL

  rm -f $GINFO_OUTPUT
  rm -f $PIPEIN $PTY_TYPE
  rm -f $FINISHEDFIFO

  # We do this because some versions of ksh93 (including that in
  # Solaris 11) have a bug where a timed-out "read -t" can mess up
  # the terminal settings, leading to characters not being echoed.
  # This is only done if we don't start with "-echo" at the beginning.
  test $reset_required = yes && { $STTY | grep '[-]echo' ; } && $STTY sane

  if test -n "$TIMED_OUT"; then
    exit 1
  fi

  #killall `basename $0`  # see below
  exit $RETVAL
}

# Uncomment this line and "killall" above if previous test runs were not
# cleaned up properly, and rerun "make check".

#cleanup


code:
This directory contains shell scripts used as tests for Info.  They are
listed in "info/Makefile.am" and will usually be run with "make check".
It should be possible to run a test on its own by running it at the
command line and checking the return value, e.g.

bash $t/goto-quoted.sh
bash $echo $?
1

shows a test failure.

The tests fall into two categories: tests of non-interactive and
interactive operation.

New tests can be created by copying existing ones.  Each test should
start with the lines

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

to allow running at the command line, or with either an in-source or
out-of-source build with "make check".  Tests of interactive operation
should follow with the line.

. $t/Init-inter.inc

Any interactive test should also finish with

. $t/Cleanup.inc

to cleanup temporary files and spawned processes.  This shell snippet
will exit with whatever the value of RETVAL is, so you can set the
exit status of the script indicating success or failure.

Tests of interactive operation
------------------------------

These use the "pseudotty" program in the info subdirectory, which
creates a pseudo-terminal for the input and output of the program.
This allows the program to happily enter interactive operation (its standard
file descriptors pass the isatty library function) and avoids affecting
the output of the terminal the test was invoked from.  pseudotty reads and
discards all input on its stdin, and passes through any bytes read on
its control channel into the pseudo-terminal.  It prints the name of the
pseudoterminal slave device on standard output.

(test script)
 ^  |
 |  `-control----> pseudotty (master) <---> (slave) stdin/stdout ginfo
 `-name of slave-----'

pseudotty will stop running either when killed, or when it exits after
its control channel is closed.

Since ginfo is reading to and writing from the pseudoterminal slave
device, if pseudotty exits before ginfo does, ginfo will exit with an
I/O error.

Many of the tests of interactive operation try to position the cursor
on a cross-reference by various means, follow the reference, and dump the node
reached to a file.  (It can be compared with a target file in
info/t/node-target, to check that we ended up where we thought we would.)

path: info/t/README


code:
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Shell script snippet.  Wait for program to finish.

# Not timed out yet
TIMED_OUT=

# Attempt to test if "read -t" works.  Under Solaris 10, read -t below
# should exit the subshell with an error exit status.  Under some other
# shells the subshell will not exit but the "read -t" will have an exit
# status of 2, representing a syntax error.
status=0
(read -t 0 ; test $? != 2 ; exit $?)
if test $? != 0; then
  # skip test below
  status=2
fi

# If that succeeded, now check that "read -t 0" has no output, which could
# be an error message.
if test $status != 2; then
  (read -t 0 2>&1 ) | grep .
  test $? = 0 && status=2
fi
# This last test was needed under OpenBSD 5.5, where
# "read -t 0" has an exit status of 1, not 2

if test $status != 2; then
  read -t 3 FINISHED <$FINISHEDFIFO
  status=$?
fi

RETVAL=0
if test $status = 1; then
  echo 'read -t failed - probably end-of-file' >&2
  RETVAL=1

elif test $status != 0 -a $status -le 128 ; then
  # Exit status of 'read' should be 0 on a successful read, or
  # greater than 128 if it timed out.
  rm -f $FINISHEDFIFO
  echo 'read -t not supported - test skipped' >&2
  RETVAL=77
  cleanup
elif test "$FINISHED" = failure; then
  echo 'Program exited unsuccessfully' >&2
  RETVAL=1

elif test "$FINISHED" != finished; then
  # Kill ginfo if we have its PID.  Failing this, it will probably exit
  # with an I/O error when pseudotty is killed in Cleanup.inc.
  test "$GINFO_PID" != unknown && kill $GINFO_PID

  echo 'Program timed out after 3 seconds' >&2
  TIMED_OUT=1
fi

# Subshell is gone, so avoid trying to kill it in cleanup
SUBSHELL=0

rm -f $FINISHEDFIFO


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

LC_ALL=en_US.ISO8859-1; export LC_ALL
# "ISO8859-1" is what it's known as on NetBSD 5.1 (and not "iso-8859-1"
# or any other variation), although this test is actually skipped on
# that OS

run_ginfo -f anchors

# Go to anchor in a UTF-8 encoded file when the current character encoding is
# supposed to be ISO-8859-1
printf 'ganchor-2\r\002\002\002\002\002\002' >$PTY_TYPE
printf '\002\002\002\002\002\002\002\002\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Try to stop a "man" command finding a man page called "intera"
MANPATH=.; export MANPATH

# Check that if there is only one file found with --all, we go straight
# to that file without loading a menu of matching files.  This relies
# on there being no "intera" entry in "dir".
run_ginfo --all intera
printf 'Dq' >$PTY_TYPE
. $t/Timeout-test.inc

grep '^File: intera.info,  Node: Top' $GINFO_OUTPUT
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Open a UTF-8 file with anchors in various positions.  Check that character
# encoding conversion doesn't cause the program to freeze.
LANG=en_US.iso8859-1; export LANG
run_ginfo -f anchor-positions
printf q >$PTY_TYPE

. $t/Timeout-test.inc
cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f body-start
# Check that node headers aren't included in searches
printf 'sPotential match\r\rDq' >$PTY_TYPE &

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Set screen geometry so that scrolling down by screens goes to
# predictable places.  5 lines of the node should be visible at once, 1
# status line and 1 line for the echo area.
# This relies on the TIOCGWINSZ ioctl either failing for the pseudotty,
# or returning non-positive values.
# (See terminal_get_screen_size in terminal.c, and the use of
# TIOCSWINSZ in pseudotty.c.)
LINES=7; export LINES
COLUMNS=80; export COLUMNS

run_ginfo -f intera -n 'Scroll four lines'

# C-u M-x scroll-forward should scroll four lines, not four screens
printf '\025\033xscroll-forward\r' >$PTY_TYPE
printf '\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

# Return non-zero (test failure) if files differ
diff $GINFO_OUTPUT $t/node-target
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Check whether we can reach a node in a file with a tag table which is
# after a node with some "CR-LF" line endings.
# The occasional presence of these causes later nodes in the "GNU COBOL
# Programmer's Guide" (23NOV2013 build of GNU COBOL 2.1),
# "gnucobpg.info", to be inaccessible when the error has built up to be
# more than the 1000 bytes of tolerance.
$GINFO --strict-node-location --file cr-tag-table.info \
      --node Second >$GINFO_OUTPUT

grep 'Node: Second' $GINFO_OUTPUT
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow several menus in a file to get to desired node
$GINFO --output - file-menu 'First entry' 'Node 2' 'Node 3' \
  | grep 'Arrived at Node 3.'


code:
#!/bin/sh
# Copyright (C) 2014, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Try to load a dir entry referring to a non-existing file
$GINFO non-existent 2>&1 | grep 'No menu item'
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Follow a dir entry to a file in a subdirectory of infodir
run_ginfo subdir
printf 'Dq' >$PTY_TYPE
. $t/Timeout-test.inc

cat $GINFO_OUTPUT
grep '^File: file-in-subdir.info' $GINFO_OUTPUT
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow an index entry in a file found through dir
$GINFO --output - split 'entry text' \
  | grep 'Node: Target node'


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow a menu in a file
$GINFO --output - file-menu 'First entry' | grep 'Arrived at Node 1.'


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Try to select a non-existent menu item
$GINFO --output - file-menu 'Not an entry' 2>&1 | grep 'No menu item'


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a node in loaded file using --node, without using --file to
# specify the desired file.

$GINFO --output - file-menu --node Unreachable \
  | grep 'not linked to elsewhere'


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow an reference to "file-menu" in dir without matching label exactly
$GINFO --output - FiLe-M | grep "^File: file-menu,"


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow a reference to file1 in dir
$GINFO --output - file1


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow several menus in a file inexactly to get to desired node
$GINFO --output - file-menu first nod nod \
  | grep 'Arrived at Node 3.'


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

INFOPATH=$INFOPATH:$t/infodir/subdir

# Follow a reference to file in merged dir
run_ginfo -v hide-note-references=On file-in-subdir

printf q >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Look for a non-existent entry in dir

# Note that the behaviour is different running non-interatively
# (with --output) and interactively.  The latter loads and displays
# the dir node, but the former does not output the dir node, just an
# error message.

$GINFO --output - not-a-file 2>&1 | grep 'No menu item'


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a file despite it not being listed in dir.
$GINFO --output - sample | grep "This is a simple Info file."


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load top-level dir node
$GINFO --output -


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $srcdir/t/Init-inter.inc

# Check that an empty search path doesn't break.  There are no search
# directories here because infopath-no-defaults=On in
# info/t/Infokey-config.
INFOPATH=
export INFOPATH
run_ginfo
printf q >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Open an empty file, and check we don't crash.  Note that the file is
# created in $builddir.
rm -f empty.info
touch empty.info
INFOPATH=. $GINFO --output - empty
rm -f empty.info


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera
# Check that typing C-e on an empty line doesn't go to previous line
printf '\x0e\x0e\x0e\x0e\x0e\x05\x0e\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow a menu in a file where the filename contains a full stop.
$GINFO --output - -f file-menu Target | grep 'File: file1'


code:
#!/bin/sh
# Copyright (C) 2017 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow an index entry with a colon in it
$GINFO --output - --file index-search 'aaa::bbb' \
  | grep 'Node: Node 2'


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Follow an index entry in a file specified with --file
$GINFO --output - --file split 'entry text' \
  | grep 'Node: Target node'


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a node with a full stop in its name in loaded file using --node.

$GINFO --output - --file file-menu --node Has.dot \
  | grep 'Node: Has.dot'


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a node in loaded file using --node.

$GINFO --output - --file file-menu --node Unreachable \
  | grep 'not linked to elsewhere'


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load more than one node in loaded file using --node.

$GINFO --output $GINFO_OUTPUT --file file-menu --node 'Node 1' --node 'Node 2'

RETVAL=0
grep 'Arrived at Node 1' $GINFO_OUTPUT || RETVAL=1
grep 'Arrived at Node 2' $GINFO_OUTPUT || RETVAL=1

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a file given relative to the current directory using --file.
$GINFO --output - --file $t/infodir/sample.info | grep "^File: sample.info,"


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Check that we can reach a file with --file
$GINFO --file file-menu >$GINFO_OUTPUT

# Check that the entire file was dumped, and not just the Top node
grep 'Node: Top' $GINFO_OUTPUT \
  && grep 'Node: Node 1' $GINFO_OUTPUT \
  && grep 'Node: Node 2' $GINFO_OUTPUT \
  && grep 'Node: Node 3' $GINFO_OUTPUT \
  && grep 'Node: Has\.dot' $GINFO_OUTPUT
# Don't look for node "Unreachable" which is not in any menus and not dumped

RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f split
# Cause the garbage collector to run in a split file by cancelling an
# incremental search.  Refresh the screen afterwards to increase the
# chances of trying to access freed file contents.
printf '\023aa\033[B\014q' >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera -n 'Goal column'

printf '/^Goal column test\r\016' >$PTY_TYPE
printf '\005\016\016\006\006' >$PTY_TYPE
printf '\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

diff $GINFO_OUTPUT $t/node-target
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Go to a node with colons and commas in its name with "g"
printf 'g\tColo\t\r\t\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Test --help flag
$GINFO --help | grep 'strict-node-location'


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Test going back to an earlier node in an incremental search using
# backspace, when going to later node caused CR-LF line endings to be
# stripped from the file.  This is the case for the test file because
# the tag table entry is incorrect for the second node.
run_ginfo -f inc-sea-bs-after-strip-cr
printf '\023xxy\010\r' >$PTY_TYPE
printf q >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f search

# Turn off regular expressions, and search for "match" with incremental
# search.  Test deleting characters from search string with backspace.  Go
# forward to match in next node.  Test we end up at the end of the match
# string by trying to wrap to the next line with C-f.
printf 'R\023matchxy\010\010' >$PTY_TYPE
printf '\023\023\023\r\006\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

# Return non-zero (test failure) if files differ
diff $GINFO_OUTPUT $t/node-target
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f search

# Search for "match" with incremental search.  Test deleting characters from
# search string with backspace.  Go forward to match in next node.  Test
# we end up at the end of the match string by trying to wrap to the next line
# with C-f.
printf '\023matchxy\010\010' >$PTY_TYPE
printf '\023\023\023\r\006\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

# Return non-zero (test failure) if files differ
diff $GINFO_OUTPUT $t/node-target
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f inc-sea-history

# Check that we go back to the right node after an incremental search
printf '\02301234\b4\b\b34\b\bqwerty\b\b\b\b\b\b34' >$PTY_TYPE
printf '\rD' >$PTY_TYPE

# Check we reached node with "01234" in it
sleep 1
grep 'Node: Four' $GINFO_OUTPUT
RETVAL=$?

printf 'lDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test $RETVAL = 0; then
  grep 'Node: Top' $GINFO_OUTPUT
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera -n 'Incremental search case-insensitive'

# Search for "match" with incremental search, adding an upper-case character
# to make the search case-sensitive.  Delete it and check the search goes back
# to being case insensitive by checking that a "Match" is included.
printf '\023matchX\010' >$PTY_TYPE
printf '\023\023\r\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

# Return non-zero (test failure) if files differ
diff $GINFO_OUTPUT $t/node-target
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo

# Type "M-x index-apropos", look for "link" in indices, select first
# result. Then type "i" followed by <TAB> to check the indices in the
# file are still there.

printf '\033xindex-apropos\rlink\r\t\ri\txxxx\rqq' >$PTY_TYPE
# We exited the "i" prompt with "xxx\r" instead of "\007" because
# C-g leads typeahead to be discarded so it would not be reliable.

. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f index-search
# Check that pressing tab to complete works for index search
printf 'i\t\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

grep '^Node: Node 2' $GINFO_OUTPUT
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f split
# Follow an menu item from the index node to a node where physical lines
# don't match logical lines.
printf 'gIndex\r\t\t\r\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera
# Search in indices with 'virtual-index' command.  Go down to index
# entry and select it.
printf 'Ibc\r\016\016\016\016\016\016\016\016\016\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

# Return non-zero (test failure) if files differ
diff $GINFO_OUTPUT $t/node-target

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera
# Follow an index entry
printf 'iabc\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
File: anchor-positions.info,  Node: Top

* Menu:

* First entry::

*note cross-reference::

Local Variables:
coding: utf-8
End:

Tag Table:
Node: Top0
Ref: 4242
Ref: 4343
Ref: 4444
Ref: 5050
Ref: 5151
Ref: 5252
Ref: 5353
Ref: 5454
Ref: 6666
Ref: 6767
Ref: 6868
Ref: 6969
Ref: 7070
Ref: 7171

End Tag Table


code:
File: utf8.info,  Node: Top, Up: (DIR), Next: Node 2,

This is UTF-8 text.
x
‘Text in quotes’. In ISO-8859-1, these should appear as straight
quotes, because open and closed quotes are not represented.

Symbols without replacements -
好 - Chinese character "hao3"
∀ - Mathematical symbol "for all"

“Text in double quotes”.

Sample characters representable in UTF-8 and ISO-8859-1:
Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Û Ü Ý Þ ß à á

*Note target:(intera)Node 1.

.
.
.
.
.
.
x
.
.
.
.
.
.
.
.

Other symbols with ASCII replacements -
Double closing angular brackets »
Right arrow →
Copyright symbol ©

Tag Table:
Node: Top0
Ref: anchor-177
Ref: anchor-2534

End Tag Table

Local Variables:
coding: UTF-8
End:


code:
File: body-start.info,  Node: Top,  Up: Potential match

Potential match. *Note Target link:(intera)Node 1.


code:
File: cr-tag-table.info, Node: Top

Line ends in 'carriage-return linefeed'.
Another line.
Removal of these makes the tag table inaccurate.

File: cr-tag-table.info, Node: Second

Second node.

Tag Table:
Node: Top0
Node: Second147

End Tag Table


code:
This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir,	Node: Top	This is the top of the INFO tree

  Test Directory node.

  This (the Directory node) gives a menu of major topics.
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,

* Menu:

Test Info files
* file1: (file1).
* file-menu: (file-menu).

* split: (split).

* non-existent: (non-existent).  Dir reference to non-existent file.

* subdir:(subdir/file-in-subdir).          File in a subdir.
* subdir-split:(subdir/split-in-subdir).   Split file in a subdir.

path: info/t/infodir/dir


code:
File: file-menu,   Node: Top

This is file whose Top node contains a menu.

* Menu:

* First entry:Node 1.
* Has.dot::
* Target:(file1.info) Top.

File: file-menu,   Node: Node 1

Arrived at Node 1.

* Menu:

* Node 2::

File: file-menu,   Node: Node 2

Arrived at Node 2.

* Menu:

* Node 3::

File: file-menu,   Node: Node 3

Arrived at Node 3.

File: file-menu,   Node: Unreachable

This node is not linked to elsewhere.

File: file-menu,   Node: Has.dot

This node is not linked to elsewhere.


code:
File: file1,	Node: Top	This is the top of the INFO tree

This is file1.


code:
Node: Top

xx

* Menu:

* Second::

Node: Second

xxyy

Tag Table:
Node: Top0
Node: Second100

End Tag Table


code:
Node: Top
0

Node: One
01

Node: Two
012

Node: Three
0123

Node: Four
01234


code:
Node: Top,  Next: Second

First node

Node: Second,  Prev: Top

* Menu:

* Third::

Node: Third,  Up: Second

Last node


code:
Node: Top

This file contains no cross-references or menus.


code:
File: quoting.info,  Node: Top,  Next: Colon::in, name,

*Note Colon::in, name::
*Note Labelled reference:Colon::in, name
*Note Quoted label...:Colon::in, name
*Note File in target:(quoting)Colon::in, name
*Note (quoting)Colon::in, name::

File: quoting.info, Node: Colon::in, name

*Note (intera)Node 1::

Tag Table:
Node: Top0
Node: Colon::in, name256

End Tag Table


code:
File: sample.info,  Node: Top,  Up: (DIR)

This is a simple Info file.


code:
File: search.info, Node: Top

File used for testing search commands.

* Menu:

* Node 2::

match

File: search.info, Node: Node 2
matchmatch match
*Note destination:(intera)Node 1.
match  match  match
match


code:
Indirect:
split.info-1: 0
split.info-2: 111

Tag Table:
(Indirect)
Node: Top0
Node: Second111
Node: Target node214
Node: Index320
Node: Long nodeline567
Ref: Anchor570

End Tag Table


code:
File: split.info,  Node: Top,  Next: Second

This is the Top node of split.info, contained in 'split.info-1.

* Menu:

* Second::	Node contained in 'split.info-2'


code:
This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir,	Node: Top	This is the top of the INFO tree

  Test Directory node.

  This (the Directory node) gives a menu of major topics.
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,

* Menu:

Test Info files
* file: (file-in-subdir).

path: info/t/infodir/subdir/dir


code:
File: file-in-subdir.info	Node: Top

This file is located within a subdirectory of the filesystem directory
containing the directory Info file, dir.


code:
Node: Top

* Menu:
* First::
* Second::

Node: First, Up: Top, Next: Second

No xref in this node

Node: Second, Up: Top, Prev: First

*Note xxx::


code:
Node: Top

*note anchor::

x
*note (intera)Node 1::

aaaaaaaaaa

Tag Table:
Node: Top0
Ref: anchor32

End Tag Table


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera

# Try to go back in history when there is no earlier node
printf lq >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f last-node-not-top-level -v scroll-last-node=Top

# Wrap round to top node when last node does not have Top as Up
printf ']]]Dq' >$PTY_TYPE
. $t/Timeout-test.inc

grep 'Node: Top' $GINFO_OUTPUT
RETVAL=$?

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera
# M-x menu-sequence
printf '\033xmenu-sequence\rfile-menu,first,no,nod\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  grep 'Arrived at Node 3.' $GINFO_OUTPUT
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Go to a node with colons and commas in its name with "n"
printf 'n\t\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Look for a non-existent entry in INFOPATH.

$GINFO --output - --file not-a-file 2>&1 | grep 'No such file or directory'


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f sample
# Try to search in the indices when there aren't any
printf 'ia\rq' >$PTY_TYPE
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2016 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Ask for a node without saying which file it's in
$GINFO --output - --node nodename \
  2>&1 | grep 'Cannot find node'


code:
File: intera.info,  Node: Node 1

Arrived at Node 1.

path: info/t/node-target


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting

# Follow a cross-reference with both the label and destination quoted.
printf '\t\t\t\r\t\rDq' >$PTY_TYPE &
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Follow a cross-reference to a node with colons and commas in its name
printf '\t\r\t\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Follow a cross-reference with a manual and quoted nodename in the label.
printf '\t\t\t\t\t\r\t\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Follow a cross-reference with a manual and quoted nodename in the target,
# after the colon.
printf '\t\t\t\t\r\t\rDq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f quoting
# Follow a cross-reference to a node with colons and commas in its name
printf '\t\t\r\t\r\Dq' >$PTY_TYPE
. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc

# Load a file given relative to the current directory without using
# --file.
$GINFO --output - $t/infodir/sample.info | grep "^File: sample.info,"


code:
#!/bin/sh
# Copyright (C) 2014 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Split window with C-x 2, follow menu entry with a slash in the filename.
# Close window (so destination file will be forgotten), and do it again with
# the other window.
run_ginfo -f file-menu
printf '\0302\t\t\t\r' >$PTY_TYPE
printf '\030o\0301\t\t\t\rq' >$PTY_TYPE

. $t/Timeout-test.inc
cleanup


code:
#!/bin/sh
# Copyright (C) 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Test of replacing a file while it is being viewed

rm -f t/replace-viewed.info
cp $t/infodir/sample.info t/replace-viewed.info
# We copied from srcdir to builddir here.

run_ginfo -f t/replace-viewed.info

# Make sure ginfo is up and running.  Skip test if no process could be found,
# because it may not have started properly.
if test $GINFO_PID = unknown ; then
  RETVAL=77 # skip test
  cleanup
fi
printf 'D' >$PTY_TYPE
while test ! -f $GINFO_OUTPUT ; do sleep 1 ; done
cat $GINFO_OUTPUT

# Now replace the file while it is being viewed.
rm -f t/replace-viewed.info
cp $t/infodir/sample.info t/replace-viewed.info

# Do a search.  This triggers ginfo's internal garbage collection.
printf '/what\r' >$PTY_TYPE
printf q >$PTY_TYPE

rm -f t/replace-viewed.info
. $t/Timeout-test.inc

cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

# Indicate a window resize while showing a completions window

run_ginfo -f file-menu
if test $GINFO_PID = unknown; then
  printf 'q' >$PTY_TYPE
  echo 'test skipped - do not have PID of ginfo process' >&2
  RETVAL=77 # automake code for skipped test
else
  printf 'g\t' >$PTY_TYPE
  sleep 1 # Give ginfo time to process above keystrokes
  kill -s WINCH $GINFO_PID
  sleep 1 # Give ginfo time to process signal
  # C-g to exit completions, q to quit
  printf '\007q' >$PTY_TYPE
fi

. $t/Timeout-test.inc
cleanup


code:
#!/bin/sh
# Copyright (C) 2014, 2015 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

srcdir=${srcdir:-.}
. $srcdir/t/Init-test.inc
. $t/Init-inter.inc

run_ginfo -f intera -n Searching
# Search for text in a node that appears after an Info tag
printf '/match\r\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\rDq' >$PTY_TYPE

. $t/Timeout-test.inc

if test ! -f $GINFO_OUTPUT; then
  RETVAL=1
else
  # Return non-zero (test failure) if files differ
  diff $GINFO_OUTPUT $t/node-target
  RETVAL=$?
fi

cleanup