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