blob: dc35ce98c0681dba0d3e171d0bd1e9d63473b3f1 [file] [log] [blame]
msaboff@apple.comd1844412011-09-03 00:41:32 +00001#!/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
31use strict;
32use FindBin;
33use Getopt::Long qw(:config pass_through);
34use lib $FindBin::Bin;
35use webkitdirs;
36use POSIX;
37
38# determine configuration
39setConfiguration();
40my $configuration = configuration();
41
42my $defaultTestFile = "RegExpTest.data";
43
44# These variables are intentionally left undefined.
45my $root;
46my $testFile;
47my $showHelp;
48my $verbose;
49
50my $buildJSC = 1;
51
52my $programName = basename($0);
53my $buildJSCDefault = $buildJSC ? "will check" : "will not check";
54my $usage = <<EOF;
55Usage: $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
61EOF
62
63GetOptions(
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
72my @buildArgs = @ARGV;
73
74
75if ($showHelp) {
76 print STDERR $usage;
77 exit 1;
78}
79
80setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
81
82if (!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
95my $productDir = jscProductDir();
96$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
97setPathForRunningWebKitApp(\%ENV) if isCygwin();
98
99sub 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
108if (!defined($testFile)) {
109 $testFile = $defaultTestFile;
110 chdirWebKit();
111 chdir("Source/JavaScriptCore");
112 chdir "tests/regexp" or die;
113}
114
115my $command = $productDir . "/testRegExp";
116
117if (defined($verbose) && $verbose) {
118 $command .= " --verbose";
119}
120
121$command .= " " . $testFile;
122
123printf "Running: " . $command . "\n";
124my $result = system $command;
125exit exitStatus($result) if $result;
126