def test_lint_test_files__errors(self):
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {
            'foo': '-- syntax error1',
            'bar': '-- syntax error2'
        }

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, -1)
        self.assertIn('Lint failed', logging_stream.getvalue())
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
Example #2
0
    def test_lint_test_files_errors(self):
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {
            'foo': '-- syntax error1',
            'bar': '-- syntax error2'
        }

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
Example #3
0
    def test_lint_flag_specific_expectation_errors(self):
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {
            'flag-specific': 'does/not/exist',
            'noproblem': ''
        }

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('flag-specific:1 Path does not exist. does/not/exist',
                      logging_stream.getvalue())
        self.assertNotIn('noproblem', logging_stream.getvalue())
Example #4
0
def main(argv, stdout, stderr):
    options, args = parse_args(argv)

    if options.platform and 'test' in options.platform:
        # It's a bit lame to import mocks into real code, but this allows the user
        # to run tests against the test platform interactively, which is useful for
        # debugging test failures.
        from webkitpy.common.host_mock import MockHost
        host = MockHost()
    else:
        host = Host()

    if options.lint_test_files:
        from webkitpy.layout_tests.lint_test_expectations import lint
        return lint(host, options, stderr)

    try:
        port = host.port_factory.get(options.platform, options)
    except NotImplementedError as e:
        # FIXME: is this the best way to handle unsupported port names?
        print(str(e), file=stderr)
        return EXCEPTIONAL_EXIT_STATUS

    stack_trace_path = host.filesystem.join(port.results_directory(),
                                            'python_stack_trace.txt')
    log_stack_trace_on_ctrl_c(output_file=stack_trace_path)
    log_stack_trace_on_term(output_file=stack_trace_path)

    if options.print_expectations:
        return _print_expectations(port, options, args, stderr)

    try:
        # Force all tests to use a smaller stack so that stack overflow tests can run faster.
        stackSizeInBytes = int(1.5 * 1024 * 1024)
        options.additional_env_var.append('JSC_maxPerThreadStackUsage=' +
                                          str(stackSizeInBytes))
        options.additional_env_var.append('__XPC_JSC_maxPerThreadStackUsage=' +
                                          str(stackSizeInBytes))
        options.additional_env_var.append('JSC_useSharedArrayBuffer=1')
        options.additional_env_var.append('__XPC_JSC_useSharedArrayBuffer=1')
        run_details = run(port, options, args, stderr)
        if run_details.exit_code != -1 and run_details.skipped_all_tests:
            return run_details.exit_code
        if run_details.exit_code != -1 and not run_details.initial_results.keyboard_interrupted:
            bot_printer = buildbot_results.BuildBotPrinter(
                stdout, options.debug_rwt_logging)
            bot_printer.print_results(run_details)

        return run_details.exit_code
    # We still need to handle KeyboardInterrupt, at least for webkitpy unittest cases.
    except KeyboardInterrupt:
        return INTERRUPTED_EXIT_STATUS
    except BaseException as e:
        if isinstance(e, Exception):
            print('\n%s raised: %s' % (e.__class__.__name__, str(e)),
                  file=stderr)
            traceback.print_exc(file=stderr)
        return EXCEPTIONAL_EXIT_STATUS
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
                                               FakePort(host, 'b', 'path-to-b'),
                                               FakePort(host, 'b-win', 'path-to-b')))

        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': None})
        res = lint_test_expectations.lint(host, options, logging_stream)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
Example #6
0
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
                                               FakePort(host, 'b', 'path-to-b'),
                                               FakePort(host, 'b-win', 'path-to-b')))

        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': None})
        res = lint_test_expectations.lint(host, options, logging_stream)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
    def test_lint_test_files(self):
        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': 'test-mac-leopard'})
        host = MockHost()

        # pylint appears to complain incorrectly about the method overrides pylint: disable=E0202,C0322
        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        host.port_factory.all_port_names = lambda platform=None: [platform]

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, 0)
        self.assertIn('Lint succeeded', logging_stream.getvalue())
    def test_lint_test_files(self):
        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': 'test-mac-leopard'})
        host = MockHost()

        # pylint appears to complain incorrectly about the method overrides pylint: disable=E0202,C0322
        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        host.port_factory.all_port_names = lambda platform=None: [platform]

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, 0)
        self.assertIn('Lint succeeded', logging_stream.getvalue())
Example #9
0
    def test_lint_test_files(self):
        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': 'test-mac-mac10.10'})
        host = MockHost()

        host.port_factory.all_port_names = lambda platform=None: [platform]

        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
            self.assertEqual(res, [])
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
Example #10
0
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(
            host,
            (FakePort(host, "a", "path-to-a"), FakePort(host, "b", "path-to-b"), FakePort(host, "b-win", "path-to-b")),
        )

        logging_stream = StringIO.StringIO()
        options = optparse.Values({"platform": None})
        res = lint_test_expectations.lint(host, options, logging_stream)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ["a", "b", "b-win"])
    def test_lint_test_files(self):
        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': 'test-mac-leopard'})
        host = MockHost()

        # pylint appears to complain incorrectly about the method overrides pylint: disable=E0202,C0322
        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        host.port_factory.all_port_names = lambda platform=None: [platform]

        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
            self.assertEqual(res, 0)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
    def test_lint_test_files(self):
        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': 'test-mac-leopard'})
        host = MockHost()

        # pylint appears to complain incorrectly about the method overrides pylint: disable=E0202,C0322
        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        host.port_factory.all_port_names = lambda platform=None: [platform]

        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
            self.assertEqual(res, 0)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
                                               FakePort(host, 'b', 'path-to-b'),
                                               FakePort(host, 'b-win', 'path-to-b')))

        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': None})
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
                                               FakePort(host, 'b', 'path-to-b'),
                                               FakePort(host, 'b-win', 'path-to-b')))

        logging_stream = StringIO.StringIO()
        options = optparse.Values({'platform': None})
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(
            host,
            (FakePort(host, "a", "path-to-a"), FakePort(host, "b", "path-to-b"), FakePort(host, "b-win", "path-to-b")),
        )

        logging_stream = StringIO.StringIO()
        options = optparse.Values({"platform": None})
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
        self.assertEqual(res, [])
        self.assertEqual(host.ports_parsed, ["a", "b", "b-win"])
    def test_lint_test_files__errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '-- syntax error2'}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, -1)
        self.assertIn('Lint failed', logging_stream.getvalue())
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
Example #17
0
    def test_lint_test_files__errors(self):
        options = optparse.Values({"platform": "test", "debug_rwt_logging": False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {"foo": "-- syntax error1", "bar": "-- syntax error2"}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, -1)
        self.assertTrue("Lint failed" in logging_stream.getvalue())
        self.assertTrue("foo:1" in logging_stream.getvalue())
        self.assertTrue("bar:1" in logging_stream.getvalue())
    def test_lint_test_files__errors(self):
        options = optparse.Values({"platform": "test", "debug_rwt_logging": False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {"foo": "-- syntax error1", "bar": "-- syntax error2"}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn("foo:1", logging_stream.getvalue())
        self.assertIn("bar:1", logging_stream.getvalue())
    def test_lint_flag_specific_expectation_errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'flag-specific': 'does/not/exist', 'noproblem': ''}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('flag-specific:1 Path does not exist. does/not/exist', logging_stream.getvalue())
        self.assertNotIn('noproblem', logging_stream.getvalue())
Example #20
0
def main(argv, stdout, stderr):
    options, args = parse_args(argv)

    if options.platform and 'test' in options.platform:
        # It's a bit lame to import mocks into real code, but this allows the user
        # to run tests against the test platform interactively, which is useful for
        # debugging test failures.
        from webkitpy.common.host_mock import MockHost
        host = MockHost()
    else:
        host = Host()

    if options.lint_test_files:
        from webkitpy.layout_tests.lint_test_expectations import lint
        return lint(host, options, stderr)

    try:
        port = host.port_factory.get(options.platform, options)
    except NotImplementedError, e:
        # FIXME: is this the best way to handle unsupported port names?
        print >> stderr, str(e)
        return EXCEPTIONAL_EXIT_STATUS
Example #21
0
    def test_extra_files_errors(self):
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]
        host.filesystem.write_text_file(
            '/test.checkout/LayoutTests/LeakExpectations', '-- syntax error')

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('LeakExpectations:1', logging_stream.getvalue())