#!/bin/sh

# Test for a bug in makeinfo where it seems to ignore the
# -I flag for @image

fail()
{
  echo FAILED
  exit 1
}

pass()
{
  rm -rf $tmpdir    
  echo PASS
  exit 0
}

tmpdir=`mktemp -d -p /tmp`


# Create a texinfo file
cat << HERE > $tmpdir/pic.texinfo
\input texinfo 
@setchapternewpage odd

This file shows a picture.

@image{mynicepic}

Do you like it?

@bye
HERE
if test $? -ne 0 ; then fail ; fi

# Create a DIR to hold the image files
mkdir $tmpdir/DIR
if test $? -ne 0 ; then fail ; fi

# Create a .txt file as the subject of the image 
touch $tmpdir/DIR/mynicepic.txt
if test $? -ne 0 ; then fail ; fi

# Run makeinfo, passing it the DIR in -I
makeinfo --docbook -I $tmpdir/DIR $tmpdir/pic.texinfo 2>&1 | grep warning
if test $? -eq 0 ; then fail ; fi

pass
