tizen beta release
[framework/web/webkit-efl.git] / Tools / Scripts / run-webkit-tests
1 #!/usr/bin/perl
2 # Copyright (C) 2010 Google 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 are
6 # met:
7 #
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 #     * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 # This file is a temporary hack.
31 # It will be removed as soon as all platforms are are ready to move to
32 # new-run-webkit-tests and we can then update the buildbots to explicitly
33 # call old-run-webkit-tests for any platforms which will never support
34 # a Python run-webkit-tests.
35
36 # This is intentionally written in Perl to guarantee support on
37 # the same set of platforms as old-run-webkit-tests currently supports.
38 # The buildbot master.cfg also currently passes run-webkit-tests to
39 # perl directly instead of executing it in a shell.
40
41 use strict;
42 use warnings;
43
44 use File::Spec;
45 use FindBin;
46 use lib $FindBin::Bin;
47 use webkitdirs;
48
49 sub runningOnBuildBot()
50 {
51     # This is a hack to detect if we're running on the buildbot so we can
52     # pass --verbose to new-run-webkit-tests.  This will be removed when we
53     # update the buildbot config to call new-run-webkit-tests explicitly.
54     my %isBuildBotUser = ("apple" => 1, "buildbot" => 1, "webkitbuildbot" => 1, "slave" => 1);
55     return $isBuildBotUser{$ENV{"USER"}};
56 }
57
58 sub useNewRunWebKitTests()
59 {
60     # NRWT Windows support still needs work: https://bugs.webkit.org/show_bug.cgi?id=38756
61     return 0 if isWindows() or isCygwin();
62     # NRWT does not support qt-arm: https://bugs.webkit.org/show_bug.cgi?id=64086
63     return 0 if isQt() and isARM();
64     # All other platforms should use NRWT by default.
65     return 1;
66 }
67
68 sub platformIsReadyForParallelTesting()
69 {
70     # NRWT is able to run the tests in parallel, ORWT was not.
71     # When we run the tests in parallel, tests which (incorrectly)
72     # interact with each other can start failing.
73     # To reduce the failure burden during the transition individual
74     # platforms can opt-in to parallel test execution by default.
75
76     # Platforms interested in dog-fooding faster test runs on their bots
77     # should add themselves to this blacklist, e.g.:
78     # return isGtk() or isQt();
79     # This will likely require skipping tests or marking tests as flaky in test_expectations.txt
80     return 0;
81 }
82
83 my $harnessName = "old-run-webkit-tests";
84
85 if (useNewRunWebKitTests()) {
86     $harnessName = "new-run-webkit-tests";
87
88     if (!grep(/--child-processes/, @ARGV) and !platformIsReadyForParallelTesting()) {
89         push(@ARGV, "--child-processes=1");
90         print "Running new-run-webkit-tests with one child process.\n";
91         print "For more parallelism, run new-run-webkit-tests directly.\n";
92     }
93
94     if (runningOnBuildBot()) {
95         push(@ARGV, "--verbose");
96     }
97 }
98
99 # webkitdirs.pm strips --qt and --gtk from @ARGV when we call isQt/isGtk.
100 # We have to add back any --PORT arguments which may have been removed by isPort() checks above.
101 if (isQt()) {
102     my $isPlatformSet = 0;
103     for (@ARGV){
104         # Pass --qt if platform isn't passed explicitly (eg. qt-5.0, qt-wk2, ...)
105         if(/^--platform.*/){
106             $isPlatformSet = 1;
107         }
108     }
109     push(@ARGV, "--qt") if(!$isPlatformSet);
110 } elsif (isGtk()) {
111     push(@ARGV, "--gtk");
112     } elsif (isEfl()) {
113         push(@ARGV, "--efl");
114 }
115
116 my $harnessPath = File::Spec->catfile(relativeScriptsDir(), $harnessName);
117 exec $harnessPath ($harnessPath, @ARGV) or die "Failed to execute $harnessPath";