3 # Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
4 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 # its contributors may be used to endorse or promote products derived
17 # from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # Script to run the Web Kit Open Source Project JavaScriptCore tests (adapted from Mozilla).
34 use Getopt::Long qw(:config pass_through);
35 use lib $FindBin::Bin;
39 my $coverageSupport = 0;
40 GetOptions('coverage!' => \$coverageSupport);
42 my @coverageSupportOption = ();
43 if ($coverageSupport) {
44 push @coverageSupportOption, "GCC_GENERATE_TEST_COVERAGE_FILES=YES";
45 push @coverageSupportOption, "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES";
46 push @coverageSupportOption, "EXTRA_LINK= -ftest-coverage -fprofile-arcs";
47 push @coverageSupportOption, "OTHER_CFLAGS= -MD";
48 push @coverageSupportOption, "OTHER_LDFLAGS= -ftest-coverage -fprofile-arcs -framework AppKit";
51 # determine configuration
54 $configuration = configuration();
60 # pre-evaluate arguments. jsDriver args have - preceding, xcode args do not.
62 # --root=<path to webkit root> use pre-built root
64 foreach my $arg(@ARGV) {
66 if( $arg =~ /root=(.*)/ ){
68 } elsif( $arg =~ /^--gtk$/i || $arg =~ /^--qt$/i ){
69 } elsif( $arg =~ /^-/ or !($arg =~/=/)){
70 push( @jsArgs, $arg );
72 push( @xcodeArgs, $arg );
76 setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
81 push(@args, "--" . $configuration);
83 # FIXME: These should be stored per-config and ignored here
84 push(@xcodeArgs, "--qt") if isQt();
85 push(@xcodeArgs, "--gtk") if isGtk();
87 my $buildResult = system "WebKitTools/Scripts/build-testkjs", @xcodeArgs;
89 print STDERR "Compiling testkjs failed!\n";
90 exit WEXITSTATUS($buildResult);
94 # Find JavaScriptCore directory
96 chdir("JavaScriptCore");
98 my $productDir = productDir();
99 chdir "tests/mozilla" or die;
101 $productDir .= "/JavaScriptCore" if (isQt() or isGtk());
102 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
103 setPathForRunningWebKitApp(\%ENV) if isCygwin();
107 my ($productDir) = @_;
108 my $testkjsName = "testkjs";
109 $testkjsName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
110 return "$productDir/$testkjsName";
113 my $result = system "perl", "jsDriver.pl", "-e", "kjs", "-s", testKJSPath($productDir), "-f", "actual.html", @jsArgs;
114 exit WEXITSTATUS($result) if $result;
118 open EXPECTED, "expected.html" or die;
120 last if /failures reported\.$/;
130 open ACTUAL, "actual.html" or die;
132 last if /failures reported\.$/;
137 delete $failures{$_};
139 $newFailures{$_} = 1;
144 my $numNewFailures = keys %newFailures;
145 if ($numNewFailures) {
146 print "\n** Danger, Will Robinson! Danger! The following failures have been introduced:\n";
147 foreach my $failure (sort keys %newFailures) {
148 print "\t$failure\n";
152 my $numOldFailures = keys %failures;
153 if ($numOldFailures) {
154 print "\nYou fixed the following test";
155 print "s" if $numOldFailures != 1;
157 foreach my $failure (sort keys %failures) {
158 print "\t$failure\n";
164 print "$numNewFailures regression";
165 print "s" if $numNewFailures != 1;
168 print "$numOldFailures test";
169 print "s" if $numOldFailures != 1;
172 print "OK.\n" if $numNewFailures == 0;