示例#1
0
    def test_check_virtual_test_suites(self):
        host = MockHost()
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        orig_get = host.port_factory.get
        host.port_factory.get = lambda options: orig_get('test',
                                                         options=options)

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.check_virtual_test_suites(
                host, options)
            self.assertTrue(res)

            options = optparse.Values({
                'platform': 'test',
                'debug_rwt_logging': False
            })
            host.filesystem.exists = lambda path: True
            res = lint_test_expectations.check_virtual_test_suites(
                host, options)
            self.assertFalse(res)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)
    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())
示例#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())
示例#4
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)
    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_check_virtual_test_suites(self):
        host = MockHost()
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        orig_get = host.port_factory.get
        host.port_factory.get = lambda options: orig_get('test', options=options)

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.check_virtual_test_suites(host, options)
            self.assertTrue(res)

            host.filesystem.exists = lambda path: True
            res = lint_test_expectations.check_virtual_test_suites(host, options)
            self.assertFalse(res)
        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, [])
        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()
        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())
示例#13
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())