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