Remove extraneous close().
[make.git] / tests / scripts / features / escape
blob8c2b8ceab4d24440d6e8c0edef620d5c0440cad1
1 #                                                                    -*-perl-*-
2 $description = "Test various types of escaping in makefiles.";
4 $details = "\
5 Make sure that escaping of ':' works in target names.
6 Make sure escaping of whitespace works in target names.
7 Make sure that escaping of '#' works.
8 Make sure that backslash before non-special characters are kept.";
11 # TEST 1
13 run_make_test('
14 $(path)foo : ; @echo "touch ($@)"
16 foo\ bar: ; @echo "touch ($@)"
18 sharp: foo\#bar.ext
19 foo\#bar.ext: ; @echo "foo#bar.ext = ($@)"',
20               '',
21               'touch (foo)');
23 # TEST 2: This one should fail, since the ":" is unquoted.
25 run_make_test(undef,
26               'path=pre:',
27               "#MAKEFILE#:2: *** target pattern contains no '%'.  Stop.",
28               512);
30 # TEST 3: This one should work, since we escape the ":".
32 run_make_test(undef,
33               "'path=pre\\:'",
34               'touch (pre:foo)');
36 # TEST 4: This one should fail, since the escape char is escaped.
38 run_make_test(undef,
39               "'path=pre\\\\:'",
40               "#MAKEFILE#:2: *** target pattern contains no '%'.  Stop.",
41               512);
43 # TEST 5: This one should work
45 run_make_test(undef,
46               "'foo bar'",
47               'touch (foo bar)');
49 # TEST 6: Test escaped comments
51 run_make_test(undef,
52               'sharp',
53               'foo#bar.ext = (foo#bar.ext)');
55 # Test escaped colons in prerequisites
56 # Quoting of backslashes in q!! is kind of messy.
57 run_make_test(q!
58 foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar
59 foo foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar: ; @echo '$@'
61               '', "foo:bar\nfoo\\:bar\nfoo\\\\:bar\nfoo\n");
63 # Test backslash before non-special chars: should be kept as-is
65 run_make_test(q!
66 all: ..\foo
67 .DEFAULT: ; @echo '$@'
69               '', '..\foo');
71 # This tells the test driver that the perl test script executed properly.