| 1 | # -*-perl-*-
|
|---|
| 2 | $description = "Test various types of escaping in makefiles.";
|
|---|
| 3 |
|
|---|
| 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 |
|
|---|
| 9 | open(MAKEFILE,"> $makefile");
|
|---|
| 10 |
|
|---|
| 11 | print MAKEFILE <<'EOF';
|
|---|
| 12 | $(path)foo : ; @echo cp $^ $@
|
|---|
| 13 |
|
|---|
| 14 | foo\ bar: ; @echo 'touch "$@"'
|
|---|
| 15 |
|
|---|
| 16 | sharp: foo\#bar.ext
|
|---|
| 17 | foo\#bar.ext: ; @echo foo\#bar.ext = '$@'
|
|---|
| 18 | EOF
|
|---|
| 19 |
|
|---|
| 20 | close(MAKEFILE);
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | # TEST 1
|
|---|
| 24 |
|
|---|
| 25 | &run_make_with_options($makefile, "", &get_logfile);
|
|---|
| 26 | $answer = "cp foo\n";
|
|---|
| 27 | &compare_output($answer,&get_logfile(1));
|
|---|
| 28 |
|
|---|
| 29 | # TEST 2: This one should fail, since the ":" is unquoted.
|
|---|
| 30 |
|
|---|
| 31 | &run_make_with_options($makefile, "path=p:", &get_logfile, 512);
|
|---|
| 32 | $answer = "$makefile:1: *** target pattern contains no `%'. Stop.\n";
|
|---|
| 33 | &compare_output($answer,&get_logfile(1));
|
|---|
| 34 |
|
|---|
| 35 | # TEST 3: This one should work, since we escape the ":".
|
|---|
| 36 |
|
|---|
| 37 | &run_make_with_options($makefile, "'path=p\\:'", &get_logfile, 0);
|
|---|
| 38 | $answer = "cp p:foo\n";
|
|---|
| 39 | &compare_output($answer,&get_logfile(1));
|
|---|
| 40 |
|
|---|
| 41 | # TEST 4: This one should fail, since the escape char is escaped.
|
|---|
| 42 |
|
|---|
| 43 | &run_make_with_options($makefile, "'path=p\\\\:'", &get_logfile, 512);
|
|---|
| 44 | $answer = "$makefile:1: *** target pattern contains no `%'. Stop.\n";
|
|---|
| 45 | &compare_output($answer,&get_logfile(1));
|
|---|
| 46 |
|
|---|
| 47 | # TEST 5: This one should work
|
|---|
| 48 |
|
|---|
| 49 | &run_make_with_options($makefile, "'foo bar'", &get_logfile, 0);
|
|---|
| 50 | $answer = "touch \"foo bar\"\n";
|
|---|
| 51 | &compare_output($answer,&get_logfile(1));
|
|---|
| 52 |
|
|---|
| 53 | # TEST 6: Test escaped comments
|
|---|
| 54 |
|
|---|
| 55 | &run_make_with_options($makefile, "sharp", &get_logfile, 0);
|
|---|
| 56 | $answer = "foo#bar.ext = foo#bar.ext\n";
|
|---|
| 57 | &compare_output($answer,&get_logfile(1));
|
|---|
| 58 |
|
|---|
| 59 | # This tells the test driver that the perl test script executed properly.
|
|---|
| 60 | 1;
|
|---|