Home | History | Annotate | Download | only in misc
      1 #                                                                    -*-perl-*-
      2 
      3 $description = "\
      4 This tests random features of the parser that need to be supported, and
      5 which have either broken at some point in the past or seem likely to
      6 break.";
      7 
      8 run_make_test("
      9 # We want to allow both empty commands _and_ commands that resolve to empty.
     10 EMPTY =
     11 
     12 .PHONY: all a1 a2 a3 a4
     13 all: a1 a2 a3 a4
     14 
     15 a1:;
     16 a2:
     17 \t
     18 a3:;\$(EMPTY)
     19 a4:
     20 \t\$(EMPTY)
     21 
     22 \# Non-empty lines that expand to nothing should also be ignored.
     23 STR =     \# Some spaces
     24 TAB =   \t  \# A TAB and some spaces
     25 
     26 \$(STR)
     27 
     28 \$(STR) \$(TAB)",
     29               '', "#MAKE#: Nothing to be done for `all'.");
     30 
     31 # TEST 2
     32 
     33 # Make sure files without trailing newlines are handled properly.
     34 # Have to use the old style invocation to test this.
     35 
     36 $makefile2 = &get_tmpfile;
     37 
     38 open(MAKEFILE, "> $makefile2");
     39 print MAKEFILE "all:;\@echo FOO = \$(FOO)\nFOO = foo";
     40 close(MAKEFILE);
     41 
     42 &run_make_with_options($makefile2,"",&get_logfile);
     43 $answer = "FOO = foo\n";
     44 &compare_output($answer,&get_logfile(1));
     45 
     46 # TEST 3
     47 
     48 # Check semicolons in variable references
     49 
     50 run_make_test('
     51 $(if true,$(info true; true))
     52 all: ; @:
     53 ',
     54               '', 'true; true');
     55 
     56 # TEST 4
     57 
     58 # Check that backslashes in command scripts are handled according to POSIX.
     59 # Checks Savannah bug # 1332.
     60 
     61 # Test the fastpath / no quotes
     62 run_make_test('
     63 all:
     64 	@echo foo\
     65 bar
     66 	@echo foo\
     67 	bar
     68 	@echo foo\
     69     bar
     70 	@echo foo\
     71 	    bar
     72 	@echo foo \
     73 bar
     74 	@echo foo \
     75 	bar
     76 	@echo foo \
     77     bar
     78 	@echo foo \
     79 	    bar
     80 ',
     81               '', 'foobar
     82 foobar
     83 foo bar
     84 foo bar
     85 foo bar
     86 foo bar
     87 foo bar
     88 foo bar');
     89 
     90 # Test the fastpath / single quotes
     91 run_make_test("
     92 all:
     93 	\@echo 'foo\\
     94 bar'
     95 	\@echo 'foo\\
     96 	bar'
     97 	\@echo 'foo\\
     98     bar'
     99 	\@echo 'foo\\
    100 	    bar'
    101 	\@echo 'foo \\
    102 bar'
    103 	\@echo 'foo \\
    104 	bar'
    105 	\@echo 'foo \\
    106     bar'
    107 	\@echo 'foo \\
    108 	    bar'
    109 ",
    110               '', 'foo\
    111 bar
    112 foo\
    113 bar
    114 foo\
    115     bar
    116 foo\
    117     bar
    118 foo \
    119 bar
    120 foo \
    121 bar
    122 foo \
    123     bar
    124 foo \
    125     bar');
    126 
    127 # Test the fastpath / double quotes
    128 run_make_test('
    129 all:
    130 	@echo "foo\
    131 bar"
    132 	@echo "foo\
    133 	bar"
    134 	@echo "foo\
    135     bar"
    136 	@echo "foo\
    137 	    bar"
    138 	@echo "foo \
    139 bar"
    140 	@echo "foo \
    141 	bar"
    142 	@echo "foo \
    143     bar"
    144 	@echo "foo \
    145 	    bar"
    146 ',
    147               '', 'foobar
    148 foobar
    149 foo    bar
    150 foo    bar
    151 foo bar
    152 foo bar
    153 foo     bar
    154 foo     bar');
    155 
    156 # Test the slow path / no quotes
    157 run_make_test('
    158 all:
    159 	@echo hi; echo foo\
    160 bar
    161 	@echo hi; echo foo\
    162 	bar
    163 	@echo hi; echo foo\
    164  bar
    165 	@echo hi; echo foo\
    166 	 bar
    167 	@echo hi; echo foo \
    168 bar
    169 	@echo hi; echo foo \
    170 	bar
    171 	@echo hi; echo foo \
    172  bar
    173 	@echo hi; echo foo \
    174 	 bar
    175 ',
    176               '', 'hi
    177 foobar
    178 hi
    179 foobar
    180 hi
    181 foo bar
    182 hi
    183 foo bar
    184 hi
    185 foo bar
    186 hi
    187 foo bar
    188 hi
    189 foo bar
    190 hi
    191 foo bar');
    192 
    193 # Test the slow path / no quotes.  This time we put the slow path
    194 # determination _after_ the backslash-newline handling.
    195 run_make_test('
    196 all:
    197 	@echo foo\
    198 bar; echo hi
    199 	@echo foo\
    200 	bar; echo hi
    201 	@echo foo\
    202  bar; echo hi
    203 	@echo foo\
    204 	 bar; echo hi
    205 	@echo foo \
    206 bar; echo hi
    207 	@echo foo \
    208 	bar; echo hi
    209 	@echo foo \
    210  bar; echo hi
    211 	@echo foo \
    212 	 bar; echo hi
    213 ',
    214               '', 'foobar
    215 hi
    216 foobar
    217 hi
    218 foo bar
    219 hi
    220 foo bar
    221 hi
    222 foo bar
    223 hi
    224 foo bar
    225 hi
    226 foo bar
    227 hi
    228 foo bar
    229 hi');
    230 
    231 # Test the slow path / single quotes
    232 run_make_test("
    233 all:
    234 	\@echo hi; echo 'foo\\
    235 bar'
    236 	\@echo hi; echo 'foo\\
    237 	bar'
    238 	\@echo hi; echo 'foo\\
    239     bar'
    240 	\@echo hi; echo 'foo\\
    241 	    bar'
    242 	\@echo hi; echo 'foo \\
    243 bar'
    244 	\@echo hi; echo 'foo \\
    245 	bar'
    246 	\@echo hi; echo 'foo \\
    247     bar'
    248 	\@echo hi; echo 'foo \\
    249 	    bar'
    250 ",
    251               '', 'hi
    252 foo\
    253 bar
    254 hi
    255 foo\
    256 bar
    257 hi
    258 foo\
    259     bar
    260 hi
    261 foo\
    262     bar
    263 hi
    264 foo \
    265 bar
    266 hi
    267 foo \
    268 bar
    269 hi
    270 foo \
    271     bar
    272 hi
    273 foo \
    274     bar');
    275 
    276 # Test the slow path / double quotes
    277 run_make_test('
    278 all:
    279 	@echo hi; echo "foo\
    280 bar"
    281 	@echo hi; echo "foo\
    282 	bar"
    283 	@echo hi; echo "foo\
    284     bar"
    285 	@echo hi; echo "foo\
    286 	    bar"
    287 	@echo hi; echo "foo \
    288 bar"
    289 	@echo hi; echo "foo \
    290 	bar"
    291 	@echo hi; echo "foo \
    292     bar"
    293 	@echo hi; echo "foo \
    294 	    bar"
    295 ',
    296               '', 'hi
    297 foobar
    298 hi
    299 foobar
    300 hi
    301 foo    bar
    302 hi
    303 foo    bar
    304 hi
    305 foo bar
    306 hi
    307 foo bar
    308 hi
    309 foo     bar
    310 hi
    311 foo     bar');
    312 
    313 1;
    314