run-regexp-tests 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/usr/bin/perl -w
  2. # Copyright (C) 2011 Apple Computer, Inc. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. #
  8. # 1. Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  14. # its contributors may be used to endorse or promote products derived
  15. # from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  18. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  21. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. # Script to run the WebKit Open Source Project Regular Expression functional tests.
  28. use strict;
  29. use FindBin;
  30. use Getopt::Long qw(:config pass_through);
  31. use lib $FindBin::Bin;
  32. use webkitdirs;
  33. use POSIX;
  34. # determine configuration
  35. setConfiguration();
  36. my $configuration = configuration();
  37. my $defaultTestFile = "RegExpTest.data";
  38. # These variables are intentionally left undefined.
  39. my $root;
  40. my $testFile;
  41. my $showHelp;
  42. my $verbose;
  43. my $buildJSC = 1;
  44. my $programName = basename($0);
  45. my $buildJSCDefault = $buildJSC ? "will check" : "will not check";
  46. my $usage = <<EOF;
  47. Usage: $programName [options] [options to pass to build system]
  48. --help Show this help message
  49. --file= File to use instead of default ($defaultTestFile)
  50. --root= Path to pre-built root containing jsc
  51. --[no-]build Check (or don't check) to see if the jsc build is up-to-date (default: $buildJSCDefault)
  52. --verbose Increase test output on failures
  53. EOF
  54. GetOptions(
  55. 'verbose' => \$verbose,
  56. 'root=s' => \$root,
  57. 'file=s' => \$testFile,
  58. 'build!' => \$buildJSC,
  59. 'help' => \$showHelp
  60. );
  61. # Assume any arguments left over from GetOptions are assumed to be build arguments
  62. my @buildArgs = @ARGV;
  63. if ($showHelp) {
  64. print STDERR $usage;
  65. exit 1;
  66. }
  67. setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
  68. if (!defined($root) && $buildJSC) {
  69. chdirWebKit();
  70. push(@buildArgs, argumentsForConfiguration());
  71. print "Running: build-jsc " . join(" ", @buildArgs) . "\n";
  72. my $buildResult = system "perl", "Tools/Scripts/build-jsc", @buildArgs;
  73. if ($buildResult) {
  74. print STDERR "Compiling jsc failed!\n";
  75. exit exitStatus($buildResult);
  76. }
  77. }
  78. my $productDir = jscProductDir();
  79. $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
  80. setPathForRunningWebKitApp(\%ENV) if isCygwin();
  81. sub testapiPath($)
  82. {
  83. my ($productDir) = @_;
  84. my $jscName = "testapi";
  85. $jscName .= "_debug" if configurationForVisualStudio() eq "Debug_All";
  86. return "$productDir/$jscName";
  87. }
  88. # Find JavaScriptCore directory
  89. if (!defined($testFile)) {
  90. $testFile = $defaultTestFile;
  91. chdirWebKit();
  92. chdir("Source/JavaScriptCore");
  93. chdir "tests/regexp" or die;
  94. }
  95. my $command = $productDir . "/testRegExp";
  96. if (defined($verbose) && $verbose) {
  97. $command .= " --verbose";
  98. }
  99. $command .= " " . $testFile;
  100. printf "Running: " . $command . "\n";
  101. my $result = system $command;
  102. exit exitStatus($result) if $result;