xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/features/escape (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos$description = "Test various types of escaping in makefiles.";
3*69606e3fSchristos
4*69606e3fSchristos$details = "\
5*69606e3fSchristosMake sure that escaping of `:' works in target names.
6*69606e3fSchristosMake sure escaping of whitespace works in target names.
7*69606e3fSchristosMake sure that escaping of '#' works.";
8*69606e3fSchristos
9*69606e3fSchristos
10*69606e3fSchristosclose(MAKEFILE);
11*69606e3fSchristos
12*69606e3fSchristos
13*69606e3fSchristos# TEST 1
14*69606e3fSchristos
15*69606e3fSchristosrun_make_test('
16*69606e3fSchristos$(path)foo : ; @echo "touch ($@)"
17*69606e3fSchristos
18*69606e3fSchristosfoo\ bar: ; @echo "touch ($@)"
19*69606e3fSchristos
20*69606e3fSchristossharp: foo\#bar.ext
21*69606e3fSchristosfoo\#bar.ext: ; @echo "foo#bar.ext = ($@)"',
22*69606e3fSchristos	      '',
23*69606e3fSchristos	      'touch (foo)');
24*69606e3fSchristos
25*69606e3fSchristos# TEST 2: This one should fail, since the ":" is unquoted.
26*69606e3fSchristos
27*69606e3fSchristosrun_make_test(undef,
28*69606e3fSchristos	      'path=pre:',
29*69606e3fSchristos	      "#MAKEFILE#:2: *** target pattern contains no `%'.  Stop.",
30*69606e3fSchristos	      512);
31*69606e3fSchristos
32*69606e3fSchristos# TEST 3: This one should work, since we escape the ":".
33*69606e3fSchristos
34*69606e3fSchristosrun_make_test(undef,
35*69606e3fSchristos	      "'path=pre\\:'",
36*69606e3fSchristos	      'touch (pre:foo)');
37*69606e3fSchristos
38*69606e3fSchristos# TEST 4: This one should fail, since the escape char is escaped.
39*69606e3fSchristos
40*69606e3fSchristosrun_make_test(undef,
41*69606e3fSchristos	      "'path=pre\\\\:'",
42*69606e3fSchristos	      "#MAKEFILE#:2: *** target pattern contains no `%'.  Stop.",
43*69606e3fSchristos	      512);
44*69606e3fSchristos
45*69606e3fSchristos# TEST 5: This one should work
46*69606e3fSchristos
47*69606e3fSchristosrun_make_test(undef,
48*69606e3fSchristos	      "'foo bar'",
49*69606e3fSchristos	      'touch (foo bar)');
50*69606e3fSchristos
51*69606e3fSchristos# TEST 6: Test escaped comments
52*69606e3fSchristos
53*69606e3fSchristosrun_make_test(undef,
54*69606e3fSchristos	      'sharp',
55*69606e3fSchristos	      'foo#bar.ext = (foo#bar.ext)');
56*69606e3fSchristos
57*69606e3fSchristos# This tells the test driver that the perl test script executed properly.
58*69606e3fSchristos1;
59