3 # Copyright (C) 2011 Igalia S.L.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Library General Public License for more details.
15 # You should have received a copy of the GNU Library General Public License
16 # along with this library; see the file COPYING.LIB. If not, write to
17 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 # Boston, MA 02110-1301, USA.
20 from webkitpy.common.system.executive import Executive
26 TEST_DIRS = [ "unittests", "WebKit2APITests" ]
27 SKIPPED = [ "unittests/testdownload" ]
30 self._executive = Executive()
32 # FIXME: webkit-build-directory --configuration always returns
33 # Release because we never call set-webkit-configuration.
34 #build_directory_script = os.path.join(os.path.dirname(__file__), "webkit-build-directory")
35 #build_directory = self._executive.run_command([build_directory_script, "--configuration"]).rstrip()
37 def is_valid_build_directory(build_dir):
38 return os.path.exists(os.path.join(build_dir, ".libs"))
40 script_dir = os.path.dirname(__file__)
41 top_level = os.path.normpath(os.path.join(script_dir, "..", ".."))
42 build_directory = os.path.join(top_level, 'WebKitBuild', 'Release')
43 if not is_valid_build_directory(build_directory):
44 build_directory = os.path.join(top_level, 'WebKitBuild', 'Debug')
46 self._programs_path = os.path.join(build_directory, "Programs")
48 for test_dir in self.TEST_DIRS:
49 for test_file in os.listdir(os.path.join(self._programs_path, test_dir)):
50 test_relative_path = os.path.join(test_dir, test_file)
51 if test_relative_path in self.SKIPPED:
52 sys.stdout.write("Skipping test %s\n" % (test_relative_path))
56 test_path = os.path.join(self._programs_path, test_relative_path)
57 if os.path.isfile(test_path) and os.access(test_path, os.X_OK):
58 self._tests.append(test_path)
62 sys.stderr.write("ERROR: tests not found in %s.\n" % (self._programs_path))
67 test_env["DISPLAY"] = ":31"
70 def _error_handler(error):
71 exit_status[0] = error.exit_code
73 for test in self._tests:
74 out = self._executive.run_command(['gtester', test], env=test_env,
75 error_handler=_error_handler)
80 sys.stdout.write("Tests failed\n")
85 if __name__ == "__main__":
87 xvfb = Executive().popen(["Xvfb", ":31", "-screen", "0", "800x600x24", "-nolisten", "tcp"],
88 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
90 sys.stderr.write("Failed to run Xvfb\n")
95 sys.exit(TestRunner().run())