"Fossies" - the Fresh Open Source Software Archive

Member "cook-2.34/test/01/t0161a.sh" (25 Sep 2010, 3222 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) 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 SHELL=/bin/sh
   28 export SHELL
   29 
   30 bin="$here/${1-.}/bin"
   31 PATH=${bin}:${PATH}
   32 export PATH
   33 
   34 pass()
   35 {
   36         set +x
   37         cd $here
   38         rm -rf $work
   39         exit 0
   40 }
   41 fail()
   42 {
   43         set +x
   44         echo 'FAILED test of the [interior_files] functionality' 1>&2
   45         cd $here
   46         rm -rf $work
   47         exit 1
   48 }
   49 no_result()
   50 {
   51         set +x
   52         echo 'NO RESULT for test of the [interior_files] functionality' 1>&2
   53         cd $here
   54         rm -rf $work
   55         exit 2
   56 }
   57 trap \"no_result\" 1 2 3 15
   58 
   59 mkdir $work $work/lib
   60 if test $? -ne 0 ; then no_result; fi
   61 cd $work
   62 if test $? -ne 0 ; then no_result; fi
   63 
   64 #
   65 # Use the default error messages.  There is no other way to get
   66 # predictable test behaviour on the unknown systems we will be tested on.
   67 #
   68 COOK_MESSAGE_LIBRARY=$work/no-such-dir
   69 export COOK_MESSAGE_LIBRARY
   70 unset LANG
   71 unset LANGUAGE
   72 
   73 #
   74 # test the [interior_files] functionality
   75 #
   76 cat > howto.cook << 'fubar'
   77 all: fred test;
   78 
   79 set time-adjust;
   80 
   81 src = [glob *.c] [fromto %.y %.c [glob *.y]];
   82 
   83 fred: [fromto %.c %.o [src]]
   84 {
   85         date > [target];
   86 }
   87 
   88 %.o: %.c
   89 {
   90         date > [target];
   91 }
   92 
   93 %.c %.h: %.y
   94 {
   95         date > %.c;
   96         date > %.h;
   97 }
   98 
   99 %.c.d: %.c
  100         set no-cascade
  101 {
  102         c_incl -ns -api -ali -nc
  103                 %.c
  104                 --interior-files [interior_files]
  105                 "--prefix='cascade-for %.c ='"
  106                 "--suffix=';'"
  107                 -o [target]
  108                 ;
  109 }
  110 
  111 cascade-for lex.c = parse.h;
  112 
  113 #include-cooked-nowarn [addsuffix ".d" [src]]
  114 
  115 test:
  116 {
  117         echo interior '=' [interior_files] > [target];
  118         echo leaf '=' [leaf_files] >> [target];
  119 }
  120 
  121 fubar
  122 if test $? -ne 0 ; then no_result; fi
  123 
  124 date > parse.y
  125 if test $? -ne 0 ; then no_result; fi
  126 date > main.c
  127 if test $? -ne 0 ; then no_result; fi
  128 cat > lex.c << 'fubar'
  129 #include "parse.h"
  130 yylex(){return 0;}
  131 yyerror(){}
  132 fubar
  133 
  134 if test $? -ne 0 ; then no_result; fi
  135 cat > test.ok << 'fubar'
  136 interior = all fred lex.o parse.c main.o parse.h parse.o test
  137 leaf = lex.c parse.y main.c
  138 fubar
  139 if test $? -ne 0 ; then no_result; fi
  140 
  141 cook -nl > LOG 2>&1
  142 if test $? -ne 0 ; then cat LOG; fail; fi
  143 
  144 diff test.ok test
  145 if test $? -ne 0 ; then fail; fi
  146 
  147 #
  148 # Only definite negatives are possible.
  149 # The functionality exercised by this test appears to work,
  150 # no other guarantees are made.
  151 #
  152 pass