#!/bin/sh
# ---------------------------------------------------------------------------
# TEST-REM
#
# This file runs an acceptance test for Remind.  To use it, type:
#      sh test-rem  OR make test
# in the build directory.
#
# This file is part of REMIND.
# Copyright (C) 1992-2023 Dianne Skoll
# SPDX-License-Identifier: GPL-2.0-only
# ---------------------------------------------------------------------------

DIR=`dirname $0`
cd $DIR
if test $? != 0 ; then
    echo ""
    echo "Unable to cd $DIR" >&2
    echo ""
    exit 1
fi

if test `id -u` = 0 ; then
    echo ""
    echo "*** Please do not run the test suite as root; it will fail."
    echo ""
    exit 1
fi

# If we're already in a utf-8 locale, do
# nothing; otherwise, set LC_ALL
OK=0
if echo $LC_ALL | grep -i utf-8 > /dev/null 2>&1 ; then
    OK=1
fi

if test -z "$LC_ALL" ; then
    if echo $LANG | grep -i utf-8 > /dev/null 2>&1 ; then
        export LC_ALL="$LANG"
        OK=1
    fi
fi

if test "$OK" = 0 ; then
    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8
fi

chmod 000 include_dir/04cantread.rem
TEST_GETENV="foo bar baz" ; export TEST_GETENV
echo "Test 1" > ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -e -dxte ../tests/test.rem 16 feb 1991 12:13 >> ../tests/test.out 2>&1
echo "" >> ../tests/test.out
echo "Test 2" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -p -l ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
echo "" >> ../tests/test.out
echo "Test 3" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -s ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
echo "" >> ../tests/test.out
echo "Test 4" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -sa ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
echo "Test 5" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -p -l -b0 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1
echo "Test 6" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -p -l -b1 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1
echo "Test 7" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -p -l -b2 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1

echo "Test 8" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -df -p -l -b2 ../tests/include_dir 1 aug 2007 >> ../tests/test.out 2>&1

echo "Test 9" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -df -p -l -b2 ../tests/nonexistent_include_dir 1 aug 2007 >> ../tests/test.out 2>&1
../src/remind -df -p -l -b2 ../tests/include_dir_no_rems 1 aug 2007 >> ../tests/test.out 2>&1
../src/remind -df -p -l -b2 ../tests/include_test.rem 1 aug 2007 >> ../tests/test.out 2>&1

chmod 644 include_dir/04cantread.rem

# Feb 29 bug
echo "Feb 29 Bug Test" >> ../tests/test.out
echo 'REM Sun 29 Feb MSG [$T]' | ../src/remind -dt - 1 feb 2021 >> ../tests/test.out 2>&1

# Day Weekday Year out-of-year bug
echo "Mon 31 Dec Bug Test" >> ../tests/test.out
echo 'REM Mon 31 2021 MSG [$T]' | ../src/remind -dt - 31 dec 2021 >> ../tests/test.out 2>&1

echo "Color Test" >> ../tests/test.out
../src/remind -ccl ../tests/colors.rem 1 aug 2007 >> ../tests/test.out 2>&1

echo "ANSI Color Test" >> ../tests/test.out
../src/remind ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0,0 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1,0 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,0 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0,,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1,,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0,0,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1,0,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,0,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@0,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@1,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1

echo '$AddBlankLines test' >> ../tests/test.out
../src/remind ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind '-i$AddBlankLines=1' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind '-i$AddBlankLines=0' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1

echo "MON WKDAY DAY across year test" >> ../tests/test.out
echo 'REM Mon 29 Dec MSG x' | ../src/remind -dt - 1 Jan 2000 >> ../tests/test.out 2>&1

echo "Sort Test" >> ../tests/test.out
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -q -gaaa - 1 Jan 2000 >> ../tests/test.out 2>&1
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -q -gaaad - 1 Jan 2000 >> ../tests/test.out 2>&1

echo "Purge Test" >> ../tests/test.out
../src/remind -j999 ../tests/purge_dir/f1.rem 3 Feb 2012 >> ../tests/test.out 2>&1
echo "F1" >> ../tests/test.out
cat ../tests/purge_dir/f1.rem.purged >> ../tests/test.out
echo "F2" >> ../tests/test.out
cat ../tests/purge_dir/f2.rem.purged >> ../tests/test.out
echo "F3" >> ../tests/test.out
cat ../tests/purge_dir/f3.rem.purged >> ../tests/test.out

rm -f ../tests/purge_dir/*.rem.purged >> ../tests/test.out 2>&1
../src/remind ../tests/runtest.rem >> ../tests/test.out 2>&1

../src/remind -p ../tests/shade.rem 1 August 2009 | ../src/rem2ps -e -l -c3 >> ../tests/test.out 2>&1
../src/remind -pp ../tests/shade.rem 1 August 2009 | ../src/rem2ps -e -l -c3 >> ../tests/test.out 2>&1

# The sun tests can fail due to math roundoff error changing the times
# by a minute...
# ../src/remind -p12 ../tests/sun.rem 1 Jan 2011 >> ../tests/test.out 2>&1

# Test -a vs -aa
../src/remind -q -a - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
REM 1 Jan 2012 AT 8:00 MSG 8am: Should not show up
REM 1 Jan 2012 AT 9:00 MSG 9am: Should not show up
REM 1 Jan 2012 AT 10:00 MSG 10am: Should not show up
MSG [$DontTrigAts]
EOF

../src/remind -q -a -a - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
REM 1 Jan 2012 AT 8:00 MSG 8am: Should not show up
REM 1 Jan 2012 AT 9:00 MSG 9am: Should show up
REM 1 Jan 2012 AT 10:00 MSG 10am: Should show up
MSG [$DontTrigAts]
EOF

# An OMITFUNC should indicate nonconst_expr
../src/remind -pp - 1 jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
REM Mon OMITFUNC foo MSG bar
EOF

# Test default color
../src/remind -pppq - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
REM 2 MSG Normal
SET $DefaultColor "255 0 0"
REM 3 MSG %"Red%" on the calendar!
SET $DefaultColor "-1 -1 -1"
REM 4 MSG Normal
# Should give an error
SET $DefaultColor "256 0 0"
EOF

# Test stdout
../src/remind - 1 jan 2012 <<'EOF' >> ../tests/test.out 2>&1
BANNER %
MSG STDOUT is a: [stdout()]%
EOF

../src/remind - 1 jan 2012 <<'EOF' 2>&1 | cat >> ../tests/test.out
BANNER %
MSG STDOUT is a: [stdout()]%
EOF

# Test -@ option
../src/remind -w,0,0 -@0,,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@0
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@0,0,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@0,0
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@0,1,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@0,1
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@1,,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@1
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@1,0,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@1,0
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@1,1,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@1,1
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@2,,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@2
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@2,0,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@2,0
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF
../src/remind -w,0,0 -@2,1,1 -c - 1 Jan 2020 <<'EOF' >> ../tests/test.out 2>&1
rem 1 SPECIAL COLOR 0   0   0 BLACK
rem 2 SPECIAL COLOR 0   0  65 BLUE
rem 3 SPECIAL COLOR 0  65   0 GREEN
rem 4 SPECIAL COLOR 0  65  65 CYAN
rem 5 msg -@2,1
rem 6 SPECIAL SHADE 255 255 0
rem 7 SPECIAL SHADE 255 0 255
rem 8 SPECIAL SHADE 0 255 255
rem 15 SPECIAL COLOR 65  0   0 RED
rem 16 SPECIAL COLOR 65  0  65 MAGENTA
rem 17 SPECIAL COLOR 65 65   0 YELLOW
rem 18 SPECIAL COLOR 65 65  65 WHITE
rem 8 SPECIAL COLOR 0   0   0 BLACK
rem 9 SPECIAL COLOR 0   0  200 BRIGHT BLUE
rem 10 SPECIAL COLOR 0  200   0 BRIGHT GREEN
rem 11 SPECIAL COLOR 0  200  200 BRIGHT CYAN
rem 22 SPECIAL COLOR 200  0   0 BRIGHT RED
rem 23 SPECIAL COLOR 200  0  200 BRIGHT MAGENTA
rem 24 SPECIAL COLOR 200 200   0 BRIGHT YELLOW
rem 25 SPECIAL COLOR 200 200  200 BRIGHT WHITE
EOF

../src/remind -w128 -c ../tests/utf-8.rem 1 Nov 2019 >> ../tests/test.out
../src/remind -c ../tests/test-addomit.rem 1 Sep 2021 >> ../tests/test.out

../src/remind -cu ../tests/utf-8.rem 1 Nov 2019 >> ../tests/test.out
../src/remind -cu '-i$SuppressLRM=1' ../tests/utf-8.rem 1 Nov 2019 >> ../tests/test.out

TZ=America/Toronto ../src/remind -dxe ../tests/tz.rem >> ../tests/test.out 2>&1
TZ=Europe/Berlin ../src/remind -dxe ../tests/tz.rem >> ../tests/test.out 2>&1

../src/remind ../tests/soleq.rem 1 April 2044 >> ../tests/test.out 2>&1

# Test that banner is printed on every iteration
echo "MSG Should be three banners." | ../src/remind - 2022-10-20 '*3' >> ../tests/test.out 2>&1

# World-writable file
rm -rf include_dir/ww
touch include_dir/ww
chmod 0666 include_dir/ww
../src/remind include_dir/ww >> ../tests/test.out 2>&1
rm -rf include_dir/ww

# World-writable directory
mkdir -p include_dir/ww
touch include_dir/ww/0.rem
chmod 0777 include_dir/ww
../src/remind include_dir/ww >> ../tests/test.out 2>&1
rm -rf include_dir/ww

# Remove references to SysInclude, which is build-specific
grep -F -v '$SysInclude' < ../tests/test.out > ../tests/test.out.1 && mv -f ../tests/test.out.1 ../tests/test.out
cmp -s ../tests/test.out ../tests/test.cmp
if [ "$?" = "0" ]; then
   echo "Remind:  Acceptance test PASSED"
   exit 0
else
   echo "Remind:  Acceptance test FAILED"
   echo ""
   echo "Examine the file test.out to see where it differs from the"
   echo "reference file test.cmp."
   exit 1
fi

