escape 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*-perl-*-
  2. $description = "Test various types of escaping in makefiles.";
  3. $details = "\
  4. Make sure that escaping of `:' works in target names.
  5. Also make sure escaping of whitespace works in target names";
  6. open(MAKEFILE,"> $makefile");
  7. print MAKEFILE <<'EOF';
  8. $(path)foo : ; @echo cp $^ $@
  9. foo\ bar: ; @echo 'touch "$@"'
  10. EOF
  11. close(MAKEFILE);
  12. # TEST 1
  13. &run_make_with_options($makefile, "", &get_logfile);
  14. $answer = "cp foo\n";
  15. &compare_output($answer,&get_logfile(1));
  16. # TEST 2: This one should fail, since the ":" is unquoted.
  17. &run_make_with_options($makefile, "path=p:", &get_logfile, 512);
  18. $answer = "$makefile:1: *** target pattern contains no `%'. Stop.\n";
  19. &compare_output($answer,&get_logfile(1));
  20. # TEST 3: This one should work, since we escape the ":".
  21. &run_make_with_options($makefile, "'path=p\\:'", &get_logfile, 0);
  22. $answer = "cp p:foo\n";
  23. &compare_output($answer,&get_logfile(1));
  24. # TEST 4: This one should fail, since the escape char is escaped.
  25. &run_make_with_options($makefile, "'path=p\\\\:'", &get_logfile, 512);
  26. $answer = "$makefile:1: *** target pattern contains no `%'. Stop.\n";
  27. &compare_output($answer,&get_logfile(1));
  28. # TEST 5: This one should work
  29. &run_make_with_options($makefile, "'foo bar'", &get_logfile, 0);
  30. $answer = "touch \"foo bar\"\n";
  31. &compare_output($answer,&get_logfile(1));
  32. # This tells the test driver that the perl test script executed properly.
  33. 1;