diff options
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py')
-rw-r--r-- | WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py index 6fe99d6..a716cec 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py @@ -1,5 +1,6 @@ #!/usr/bin/python # Copyright (C) 2010 Google Inc. All rights reserved. +# Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Szeged # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -33,6 +34,7 @@ import codecs import logging import os import Queue +import shutil import sys import tempfile import thread @@ -70,7 +72,7 @@ def passing_run(args=[], port_obj=None, record_results=False, # We use the glob to test that globbing works. new_args.extend(['passes', 'http/tests', - 'websocket/tests', + 'http/tests/websocket/tests', 'failures/expected/*']) options, parsed_args = run_webkit_tests.parse_args(new_args) if port_obj is None: @@ -88,7 +90,7 @@ def logging_run(args=[], tests_included=False): if not tests_included: new_args.extend(['passes', 'http/tests', - 'websocket/tests', + 'http/tests/websocket/tests', 'failures/expected/*']) options, parsed_args = run_webkit_tests.parse_args(new_args) user = MockUser() @@ -232,10 +234,37 @@ class MainTest(unittest.TestCase): self.assertFalse(err.empty()) self.assertEqual(user.url, '/tmp/layout-test-results/results.html') + def test_results_directory_absolute(self): + # We run a configuration that should fail, to generate output, then + # look for what the output results url was. + + tmpdir = tempfile.mkdtemp() + res, out, err, user = logging_run(['--results-directory=' + tmpdir], + tests_included=True) + self.assertEqual(user.url, os.path.join(tmpdir, 'results.html')) + shutil.rmtree(tmpdir, ignore_errors=True) + + def test_results_directory_default(self): + # We run a configuration that should fail, to generate output, then + # look for what the output results url was. + + # This is the default location. + res, out, err, user = logging_run(tests_included=True) + self.assertEqual(user.url, '/tmp/layout-test-results/results.html') + + def test_results_directory_relative(self): + # We run a configuration that should fail, to generate output, then + # look for what the output results url was. + + res, out, err, user = logging_run(['--results-directory=foo'], + tests_included=True) + self.assertEqual(user.url, '/tmp/foo/results.html') + + def _mocked_open(original_open, file_list): def _wrapper(name, mode, encoding): - if name.find("-expected.") != -1 and mode == "w": + if name.find("-expected.") != -1 and mode.find("w") != -1: # we don't want to actually write new baselines, so stub these out name.replace('\\', '/') file_list.append(name) @@ -251,7 +280,10 @@ class RebaselineTest(unittest.TestCase): baseline = file + "-expected" + ext self.assertTrue(any(f.find(baseline) != -1 for f in file_list)) - def test_reset_results(self): + # FIXME: This test is failing on the bots. Also, this test touches the + # file system. Unit tests should not read or write the file system. + # https://bugs.webkit.org/show_bug.cgi?id=47879 + def disabled_test_reset_results(self): file_list = [] original_open = codecs.open try: @@ -294,6 +326,11 @@ class RebaselineTest(unittest.TestCase): codecs.open = original_open +class TestRunnerWrapper(run_webkit_tests.TestRunner): + def _get_test_info_for_file(self, test_file): + return test_file + + class TestRunnerTest(unittest.TestCase): def test_results_html(self): mock_port = Mock() @@ -314,6 +351,52 @@ class TestRunnerTest(unittest.TestCase): html = runner._results_html(["test_path"], {}, "Title", override_time="time") self.assertEqual(html, expected_html) + def queue_to_list(self, queue): + queue_list = [] + while(True): + try: + queue_list.append(queue.get_nowait()) + except Queue.Empty: + break + return queue_list + + def test_get_test_file_queue(self): + # Test that _get_test_file_queue in run_webkit_tests.TestRunner really + # put the http tests first in the queue. + runner = TestRunnerWrapper(port=Mock(), options=Mock(), printer=Mock()) + runner._options.experimental_fully_parallel = False + + test_list = [ + "LayoutTests/websocket/tests/unicode.htm", + "LayoutTests/animations/keyframes.html", + "LayoutTests/http/tests/security/view-source-no-refresh.html", + "LayoutTests/websocket/tests/websocket-protocol-ignored.html", + "LayoutTests/fast/css/display-none-inline-style-change-crash.html", + "LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html", + "LayoutTests/dom/html/level2/html/HTMLAnchorElement03.html", + "LayoutTests/ietestcenter/Javascript/11.1.5_4-4-c-1.html", + "LayoutTests/dom/html/level2/html/HTMLAnchorElement06.html", + ] + + expected_tests_to_http_lock = set([ + 'LayoutTests/websocket/tests/unicode.htm', + 'LayoutTests/http/tests/security/view-source-no-refresh.html', + 'LayoutTests/websocket/tests/websocket-protocol-ignored.html', + 'LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html', + ]) + + runner._options.child_processes = 1 + test_queue_for_single_thread = runner._get_test_file_queue(test_list) + runner._options.child_processes = 2 + test_queue_for_multi_thread = runner._get_test_file_queue(test_list) + + single_thread_results = self.queue_to_list(test_queue_for_single_thread) + multi_thread_results = self.queue_to_list(test_queue_for_multi_thread) + + self.assertEqual("tests_to_http_lock", single_thread_results[0][0]) + self.assertEqual(expected_tests_to_http_lock, set(single_thread_results[0][1])) + self.assertEqual("tests_to_http_lock", multi_thread_results[0][0]) + self.assertEqual(expected_tests_to_http_lock, set(multi_thread_results[0][1])) class DryrunTest(unittest.TestCase): # FIXME: it's hard to know which platforms are safe to test; the |