"Fossies" - the Fresh Open Source Software Archive

Member "cook-2.34/test/00/t0084a.sh" (25 Sep 2010, 2616 Bytes) of package /linux/misc/old/cook-2.34.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 #       cook - file construction tool
    4 #       Copyright (C) 1995, 1997, 1998, 2007, 2008 Peter Miller
    5 #
    6 #       This program is free software; you can redistribute it and/or modify
    7 #       it under the terms of the GNU General Public License as published by
    8 #       the Free Software Foundation; either version 3 of the License, or
    9 #       (at your option) any later version.
   10 #
   11 #       This program is distributed in the hope that it will be useful,
   12 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 #       GNU General Public License for more details.
   15 #
   16 #       You should have received a copy of the GNU General Public License
   17 #       along with this program. If not, see
   18 #       <http://www.gnu.org/licenses/>.
   19 #
   20 work=${COOK_TMP:-/tmp}/$$
   21 PAGER=cat
   22 export PAGER
   23 umask 022
   24 unset COOK
   25 here=`pwd`
   26 if test $? -ne 0 ; then exit 2; fi
   27 
   28 bin="$here/${1-.}/bin"
   29 
   30 pass()
   31 {
   32         set +x
   33         cd $here
   34         rm -rf $work
   35         exit 0
   36 }
   37 fail()
   38 {
   39         set +x
   40         echo 'FAILED test of the double colon functionality' 1>&2
   41         cd $here
   42         rm -rf $work
   43         exit 1
   44 }
   45 no_result()
   46 {
   47         set +x
   48         echo 'NO RESULT test of the double colon functionality' 1>&2
   49         cd $here
   50         rm -rf $work
   51         exit 2
   52 }
   53 trap \"no_result\" 1 2 3 15
   54 
   55 mkdir $work $work/lib
   56 if test $? -ne 0 ; then no_result; fi
   57 cd $work
   58 if test $? -ne 0 ; then no_result; fi
   59 
   60 #
   61 # Use the default error messages.  There is no other way to get
   62 # predictable test behaviour on the unknown systems we will be tested on.
   63 #
   64 COOK_MESSAGE_LIBRARY=$work/no-such-dir
   65 export COOK_MESSAGE_LIBRARY
   66 unset LANG
   67 
   68 #
   69 # test the double colon functionality
   70 #
   71 cat > howto.cook << 'fubar'
   72 test:: ::
   73 {
   74         touch test;
   75 }
   76 fubar
   77 if test $? -ne 0 ; then no_result; fi
   78 
   79 $bin/cook -nl > LOG 2>&1
   80 if test $? -ne 0 ; then car LOG; fail; fi
   81 
   82 cat > howto.cook << 'fubar'
   83 test: bar
   84 {
   85         touch test;
   86 }
   87 
   88 %0bar: : %0baz
   89 {
   90         cp [need] [target];
   91 }
   92 fubar
   93 if test $? -ne 0 ; then no_result; fi
   94 cat > test.ok << 'fubar'
   95 cook: baz: don't know how
   96 cook: howto.cook: 6: "bar" not derived due to errors deriving "baz"
   97 cook: howto.cook: 1: "test" not derived due to errors deriving "bar"
   98 fubar
   99 if test $? -ne 0 ; then no_result; fi
  100 
  101 echo hello > bar
  102 if test $? -ne 0 ; then no_result; fi
  103 
  104 $bin/cook -nl > test.out 2>&1
  105 if test $? -ne 1 ; then fail; fi
  106 
  107 diff test.ok test.out
  108 if test $? -ne 0 ; then fail; fi
  109 
  110 #
  111 # Only definite negatives are possible.
  112 # The functionality exercised by this test appears to work,
  113 # no other guarantees are made.
  114 #
  115 pass