wildcard 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # -*-perl-*-
  2. $description = "The following test creates a makefile to test wildcard\n"
  3. ."expansions and the ability to put a command on the same\n"
  4. ."line as the target name separated by a semi-colon.";
  5. $details = "This test creates 4 files by the names of 1.example, \n"
  6. ."two.example and 3.example. We execute three tests. The first\n"
  7. ."executes the print1 target which tests the '*' wildcard by \n"
  8. ."echoing all filenames by the name of '*.example'. The second\n"
  9. ."test echo's all files which match '?.example' and \n"
  10. ."[a-z0-9].example. Lastly we clean up all of the files using\n"
  11. ."the '*' wildcard as in the first test";
  12. if ($vos)
  13. {
  14. $delete_command = "delete_file -no_ask";
  15. }
  16. else
  17. {
  18. $delete_command = "rm";
  19. }
  20. open(MAKEFILE,"> $makefile");
  21. # The Contents of the MAKEFILE ...
  22. print MAKEFILE <<EOM;
  23. print1: ;\@echo \$(wildcard example.*)
  24. print2:
  25. \t\@echo \$(wildcard example.?)
  26. \t\@echo \$(wildcard example.[a-z0-9])
  27. \t\@echo \$(wildcard example.[!A-Za-z_\\!])
  28. clean:
  29. \t$delete_command \$(wildcard example.*)
  30. EOM
  31. # END of Contents of MAKEFILE
  32. close(MAKEFILE);
  33. &touch("example.1");
  34. &touch("example.two");
  35. &touch("example.3");
  36. &touch("example.for");
  37. &touch("example._");
  38. # TEST #1
  39. # -------
  40. $answer = "example.1 example.3 example._ example.for example.two\n";
  41. &run_make_with_options($makefile,"print1",&get_logfile);
  42. &compare_output($answer,&get_logfile(1));
  43. # TEST #2
  44. # -------
  45. $answer = "example.1 example.3 example._\n"
  46. ."example.1 example.3\n"
  47. ."example.1 example.3\n";
  48. &run_make_with_options($makefile,"print2",&get_logfile);
  49. &compare_output($answer,&get_logfile(1));
  50. # TEST #3
  51. # -------
  52. $answer = "$delete_command example.1 example.3 example._ example.for example.two";
  53. if ($vos)
  54. {
  55. $answer .= " \n";
  56. }
  57. else
  58. {
  59. $answer .= "\n";
  60. }
  61. &run_make_with_options($makefile,"clean",&get_logfile);
  62. &compare_output($answer,&get_logfile(1));
  63. if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for"))
  64. {
  65. $test_passed = 0;
  66. }
  67. 1;