Example #1
0
 def test_skip_if_true(self):
     klass = skip_if(self.create_fixture_class(), True, "Should see this message.", logger=self.logger)
     klass(self.foo_callback).test_foo()
     self.assertEqual(
         self.log_stream.getvalue(),
         "Skipping webkitpy.test.skip_unittest.TestSkipFixture: Should see this message.\n",
     )
     self.assertFalse(self.foo_was_called)
    def test_worker_model__inline(self):
        self.assertTrue(passing_run(['--worker-model', 'inline']))

    def test_worker_model__threads(self):
        self.assertTrue(passing_run(['--worker-model', 'threads']))

    def test_worker_model__processes(self):
        self.assertRaises(ValueError, logging_run,
                          ['--worker-model', 'processes'])

    def test_worker_model__unknown(self):
        self.assertRaises(ValueError, logging_run,
                          ['--worker-model', 'unknown'])

MainTest = skip_if(MainTest, sys.platform == 'cygwin' and compare_version(sys, '2.6')[0] < 0, 'new-run-webkit-tests tests hang on Cygwin Python 2.5.2')



def _mocked_open(original_open, file_list):
    def _wrapper(name, mode, encoding):
        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)
            return original_open(os.devnull, mode, encoding)
        return original_open(name, mode, encoding)
    return _wrapper


class RebaselineTest(unittest.TestCase):
Example #3
0
 def test_skip_if_false(self):
     klass = skip_if(self.create_fixture_class(), False, 'Should not see this message.', logger=self.logger)
     klass(self.foo_callback).test_foo()
     self.assertEqual(self.log_stream.getvalue(), '')
     self.assertTrue(self.foo_was_called)
Example #4
0
        return [test for test in tests if type in test]

    def test_no_http_tests(self):
        batch_tests_dryrun = get_tests_run(['LayoutTests/http', 'websocket/'], flatten_batches=True)
        self.assertTrue(MainTest.has_test_of_type(batch_tests_dryrun, 'http'))
        self.assertTrue(MainTest.has_test_of_type(batch_tests_dryrun, 'websocket'))

        batch_tests_run_no_http = get_tests_run(['--no-http', 'LayoutTests/http', 'websocket/'], flatten_batches=True)
        self.assertFalse(MainTest.has_test_of_type(batch_tests_run_no_http, 'http'))
        self.assertFalse(MainTest.has_test_of_type(batch_tests_run_no_http, 'websocket'))

        batch_tests_run_http = get_tests_run(['--http', 'LayoutTests/http', 'websocket/'], flatten_batches=True)
        self.assertTrue(MainTest.has_test_of_type(batch_tests_run_http, 'http'))
        self.assertTrue(MainTest.has_test_of_type(batch_tests_run_http, 'websocket'))

MainTest = skip_if(MainTest, sys.platform == 'cygwin' and sys.version < '2.6', 'new-run-webkit-tests tests hang on Cygwin Python 2.5.2')


class EndToEndTest(unittest.TestCase):
    def parse_full_results(self, full_results_text):
        json_to_eval = full_results_text.replace("ADD_RESULTS(", "").replace(");", "")
        compressed_results = json.loads(json_to_eval)
        return compressed_results

    def test_end_to_end(self):
        host = MockHost()
        res, out, err, user = logging_run(record_results=True, tests_included=True, host=host)

        self.assertEquals(res, unexpected_tests_count)
        results = self.parse_full_results(host.filesystem.read_text_file('/tmp/layout-test-results/full_results.json'))
        batch_tests_dryrun = get_tests_run(["LayoutTests/http", "websocket/"], flatten_batches=True)
        self.assertTrue(MainTest.has_test_of_type(batch_tests_dryrun, "http"))
        self.assertTrue(MainTest.has_test_of_type(batch_tests_dryrun, "websocket"))

        batch_tests_run_no_http = get_tests_run(["--no-http", "LayoutTests/http", "websocket/"], flatten_batches=True)
        self.assertFalse(MainTest.has_test_of_type(batch_tests_run_no_http, "http"))
        self.assertFalse(MainTest.has_test_of_type(batch_tests_run_no_http, "websocket"))

        batch_tests_run_http = get_tests_run(["--http", "LayoutTests/http", "websocket/"], flatten_batches=True)
        self.assertTrue(MainTest.has_test_of_type(batch_tests_run_http, "http"))
        self.assertTrue(MainTest.has_test_of_type(batch_tests_run_http, "websocket"))


MainTest = skip_if(
    MainTest,
    sys.platform == "cygwin" and compare_version(sys, "2.6")[0] < 0,
    "new-run-webkit-tests tests hang on Cygwin Python 2.5.2",
)


class EndToEndTest(unittest.TestCase):
    def parse_full_results(self, full_results_text):
        json_to_eval = full_results_text.replace("ADD_RESULTS(", "").replace(");", "")
        compressed_results = json.loads(json_to_eval)
        return compressed_results

    def test_end_to_end(self):
        fs = unit_test_filesystem()
        res, out, err, user = logging_run(record_results=True, tests_included=True, filesystem=fs)

        self.assertEquals(res, unexpected_tests_count)
 def test_skip_if_false(self):
     klass = skip_if(self.create_fixture_class(), False, 'Should not see this message.', logger=self.logger)
     klass(self.foo_callback).test_foo()
     self.assertEqual(self.log_stream.getvalue(), '')
     self.assertTrue(self.foo_was_called)
Example #7
0
            flatten_batches=True)
        self.assertFalse(
            MainTest.has_test_of_type(batch_tests_run_no_http, 'http'))
        self.assertFalse(
            MainTest.has_test_of_type(batch_tests_run_no_http, 'websocket'))

        batch_tests_run_http = get_tests_run(
            ['--http', 'LayoutTests/http', 'websocket/'], flatten_batches=True)
        self.assertTrue(MainTest.has_test_of_type(batch_tests_run_http,
                                                  'http'))
        self.assertTrue(
            MainTest.has_test_of_type(batch_tests_run_http, 'websocket'))


MainTest = skip_if(
    MainTest, sys.platform == 'cygwin' and compare_version(sys, '2.6')[0] < 0,
    'new-run-webkit-tests tests hang on Cygwin Python 2.5.2')


class RebaselineTest(unittest.TestCase):
    def assertBaselines(self, file_list, file, extensions, err):
        "assert that the file_list contains the baselines." ""
        for ext in extensions:
            baseline = file + "-expected" + ext
            baseline_msg = 'Writing new expected result "%s"\n' % baseline[1:]
            self.assertTrue(any(f.find(baseline) != -1 for f in file_list))
            self.assertTrue(baseline_msg in err.get())

    # FIXME: Add tests to ensure that we're *not* writing baselines when we're not
    # supposed to be.