Ejemplo n.º 1
0
    def _test_check_test_expectations(self, filename):
        options = MockOptions()
        options.git_commit = ""
        options.non_interactive = True

        tool = MockTool()
        tool.user = None  # Will cause any access of tool.user to raise an exception.
        step = Commit(tool, options)
        state = {
            "changed_files": [filename + "XXX"],
        }

        tool.executive = MockExecutive(should_log=True, should_throw_when_run=False)
        with OutputCapture(level=logging.INFO) as captured:
            step.run(state)
        self.assertEqual(captured.root.log.getvalue(), 'Committed r49824: <https://commits.webkit.org/r49824>\n')

        state = {
            "changed_files": ["platform/chromium/" + filename],
        }
        with OutputCapture(level=logging.INFO) as captured:
            step.run(state)
        self.assertEqual(
            captured.root.log.getvalue(),
            '''MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/{}'], cwd=/mock-checkout
Committed r49824: <https://commits.webkit.org/r49824>
'''.format(filename),
        )

        tool.executive = MockExecutive(should_log=True, should_throw_when_run={"platform/chromium/" + filename})
        with self.assertRaises(ScriptError), OutputCapture():
            step.run(state)
Ejemplo n.º 2
0
    def test_paths(self):
        self.fs.chdir('/foo/bar')
        self.check_names(['baz_unittest.py'], ['bar.baz_unittest'])
        self.check_names(['./baz_unittest.py'], ['bar.baz_unittest'])
        self.check_names(['/foo/bar/baz_unittest.py'], ['bar.baz_unittest'])
        self.check_names(['.'], ['bar.baz_unittest'])
        self.check_names(['../../foo2/bar2'], ['bar2.baz2_integrationtest'])

        self.fs.chdir('/')
        self.check_names(['bar'], ['bar.baz_unittest'])
        self.check_names(['/foo/bar/'], ['bar.baz_unittest'])

        # This works 'by accident' since it maps onto a package.
        self.check_names(['bar/'], ['bar.baz_unittest'])

        # This should log an error, since it's outside the trees.
        with OutputCapture(level=logging.ERROR) as captured:
            self.check_names(['/tmp/another_unittest.py'], [])
        self.assertIn('another_unittest.py', captured.root.log.getvalue())

        # Paths that don't exist are errors.
        with OutputCapture(level=logging.INFO) as captured:
            self.check_names(['/foo/bar/notexist_unittest.py'], [])
        self.assertIn('notexist_unittest.py', captured.root.log.getvalue())

        # Names that don't exist are caught later, at load time.
        self.check_names(['bar.notexist_unittest'], ['bar.notexist_unittest'])
Ejemplo n.º 3
0
    def test_linter_duplicate_line(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/test.html [ Failure ]\ncss1/test.html [ Failure ]\n'
        }
        host = self._generate_testing_host(files)

        with OutputCapture(level=logging.ERROR) as captured:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(captured.stdout.getvalue(), '')
        self.assertEqual(captured.stderr.getvalue(), '')
        self.assertEqual(captured.root.log.getvalue(), '')

        with OutputCapture(level=logging.ERROR) as captured:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.process_file(
                '/mock-checkout/LayoutTests/TestExpectations',
                line_numbers=[1, 2, 3])
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(captured.stdout.getvalue(), '')
        self.assertEqual(captured.stderr.getvalue(), '')
        self.assertEqual(
            captured.root.log.getvalue(),
            '/mock-checkout/LayoutTests/TestExpectations:3:  Duplicate or ambiguous entry lines LayoutTests/TestExpectations:2 and LayoutTests/TestExpectations:3.  [test/expectations] [5]\n',
        )
Ejemplo n.º 4
0
 def test_basic(self):
     capture = OutputCapture()
     step = SuggestReviewers(
         MockTool(), MockOptions(suggest_reviewers=True, git_commit=None))
     with OutputCapture(level=logging.INFO) as captured:
         step.run(dict(bug_id='123'))
     self.assertEqual(
         captured.stdout.getvalue(),
         'The following reviewers have recently modified files in your patch:\nFoo Bar\n'
     )
     self.assertEqual(captured.root.log.getvalue(),
                      'Would you like to CC them?\n')
Ejemplo n.º 5
0
    def test_build_driver(self):
        port = TestWebKitPort()
        # Delay setting _executive to avoid logging during construction
        port._executive = MockExecutive(should_log=True)
        port._options = MockOptions(
            configuration="Release"
        )  # This should not be necessary, but I think TestWebKitPort is actually reading from disk (and thus detects the current configuration).
        with OutputCapture(level=logging.INFO) as captured:
            self.assertTrue(port._build_driver())
        self.assertEqual(
            captured.root.log.getvalue(),
            "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'MOCK_ENVIRON_COPY': '1'}\n",
        )

        # Make sure WebKitTestRunner is used.
        port._options = MockOptions(webkit_test_runner=True,
                                    configuration="Release")
        with OutputCapture(level=logging.INFO) as captured:
            self.assertTrue(port._build_driver())
        self.assertEqual(
            captured.root.log.getvalue(),
            '''MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'MOCK_ENVIRON_COPY': '1'}
MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout, env={'MOCK_ENVIRON_COPY': '1'}
''',
        )

        # Make sure we show the build log when --verbose is passed, which we simulate by setting the logging level to DEBUG.
        port._options = MockOptions(configuration="Release")
        with OutputCapture(level=logging.DEBUG) as captured:
            self.assertTrue(port._build_driver())
        self.assertEqual(
            captured.root.log.getvalue(),
            '''MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'MOCK_ENVIRON_COPY': '1'}
Output of ['Tools/Scripts/build-dumprendertree', '--release']:
MOCK output of child process
''',
        )

        # Make sure that failure to build returns False.
        port._executive = MockExecutive(should_log=True, should_throw=True)
        with OutputCapture(level=logging.DEBUG) as captured:
            self.assertFalse(port._build_driver())
        # Because WK2 currently has to build both webkittestrunner and DRT, if DRT fails, that's the only one it tries.
        self.assertEqual(
            captured.root.log.getvalue(),
            '''MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'MOCK_ENVIRON_COPY': '1'}
MOCK ScriptError

MOCK output of child process
''',
        )
Ejemplo n.º 6
0
 def test_submit_to_ews(self):
     with OutputCapture():
         mock_browser = MockBrowser()
         ews_server = EWSServer(browser=mock_browser)
         self.assertTrue(ews_server.use_https)
         ews_server.submit_to_ews(10008)
         self.assertEqual(mock_browser['patch_id'], u'10008')
Ejemplo n.º 7
0
    def test_documentation(self):
        with OutputCapture():
            with mocks.Subprocess(
                    'ls',
                    completion=mocks.ProcessCompletion(
                        returncode=0, stdout='file1.txt\nfile2.txt\n'),
            ):
                result = run(['ls'], capture_output=True, encoding='utf-8')
                assert result.returncode == 0
                assert result.stdout == 'file1.txt\nfile2.txt\n'

            with mocks.Subprocess(
                    'ls',
                    completion=mocks.ProcessCompletion(
                        returncode=0, stdout='file1.txt\nfile2.txt\n'),
            ):
                assert subprocess.check_output(['ls'
                                                ]) == b'file1.txt\nfile2.txt\n'
                assert subprocess.check_call(['ls']) == 0

            with mocks.Subprocess(
                    mocks.Subprocess.CommandRoute(
                        'command-a',
                        'argument',
                        completion=mocks.ProcessCompletion(returncode=0)),
                    mocks.Subprocess.CommandRoute(
                        'command-b',
                        completion=mocks.ProcessCompletion(returncode=-1)),
            ):
                result = run(['command-a', 'argument'])
                assert result.returncode == 0

                result = run(['command-b'])
                assert result.returncode == -1
Ejemplo n.º 8
0
    def test_popen(self):
        with OutputCapture() as captured:
            with mocks.Subprocess(MockSubprocess.LS):
                result = subprocess.check_call(['ls'])
                self.assertEqual(result, 0)

        self.assertEqual(captured.stdout.getvalue(), 'file1.txt\nfile2.txt\n')
Ejemplo n.º 9
0
    def test_json(self):
        with OutputCapture() as captured, mocks.local.Git(
                self.path, git_svn=True), mocks.local.Svn(), MockTime:
            self.assertEqual(
                0,
                program.main(
                    args=('find', '3@main', '--json'),
                    path=self.path,
                ))

        decoded = json.loads(captured.stdout.getvalue())
        self.assertDictEqual(
            decoded,
            dict(
                identifier='3@main',
                hash='1abe25b443e985f93b90d830e4a7e3731336af4d',
                revision=4,
                author=dict(
                    name='Jonathan Bedard',
                    emails=['*****@*****.**'],
                ),
                timestamp=1601663000,
                order=0,
                branch='main',
                message=
                '4th commit\nsvn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
            ))
Ejemplo n.º 10
0
    def test_parse_output_with_ignored_stderr(self):
        output = DriverOutput(":Time -> [1080, 1120, 1095, 1101, 1104] ms",
                              image=None,
                              image_hash=None,
                              audio=None,
                              error="""
Jan 22 14:09:24  WebKitTestRunner[1296] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 22 14:09:24  WebKitTestRunner[1296] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 22 14:09:24  WebKitTestRunner[1296] <Error>: CGContextGetCompositeOperation: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 22 14:09:24  WebKitTestRunner[1296] <Error>: CGContextSetCompositeOperation: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 22 14:09:24  WebKitTestRunner[1296] <Error>: CGContextFillRects: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
""")

        class MockPortWithSierraName(MockPort):
            def name(self):
                return "mac-sierra"

        with OutputCapture(level=logging.INFO) as captured:
            test = PerfTest(MockPortWithSierraName(), 'some-test',
                            '/path/some-dir/some-test')
            self._assert_results_are_correct(test, output)

        self.assertEqual(captured.stdout.getvalue(), '')
        self.assertEqual(captured.stderr.getvalue(), '')
        self.assertEqual(
            captured.root.log.getvalue(), """RESULT some-test: Time= 1100.0 ms
median= 1101.0 ms, stdev= 13.3140211016 ms, min= 1080.0 ms, max= 1120.0 ms
""")
Ejemplo n.º 11
0
    def test_non_cannonical_identifiers(self):
        with mocks.local.Svn(self.path), OutputCapture():
            self.assertEqual('2@trunk', str(local.Svn(self.path).commit(identifier='0@branch-a')))
            self.assertEqual('1@trunk', str(local.Svn(self.path).commit(identifier='-1@branch-a')))

            self.assertEqual('2@trunk', str(local.Svn(self.path).commit(identifier='0@branch-b')))
            self.assertEqual('1@trunk', str(local.Svn(self.path).commit(identifier='-1@branch-b')))
Ejemplo n.º 12
0
 def test_httpd_returns_error_code(self):
     port = self.make_port(executive=MockExecutive2(exit_code=1))
     port._path_to_apache = lambda: '/usr/sbin/httpd'
     with OutputCapture() as captured:
         self.assertFalse(port.check_httpd())
     self.assertEqual('httpd seems broken. Cannot run http tests.\n',
                      captured.root.log.getvalue())
    def _test_run_with_json_output(self, runner, filesystem, upload_succeeds=False, results_shown=True, expected_exit_code=0, repeat=1, compare_logs=True):
        filesystem.write_text_file(runner._base_path + '/Parser/some-parser.html', 'some content')
        filesystem.write_text_file(runner._base_path + '/Bindings/event-target-wrapper.html', 'some content')

        uploaded = [False]

        def mock_upload_json(hostname, json_path, host_path=None):
            # FIXME: Get rid of the hard-coded perf.webkit.org once we've completed the transition.
            self.assertIn(hostname, ['some.host'])
            self.assertIn(json_path, ['/mock-checkout/output.json'])
            self.assertIn(host_path, [None, '/api/report'])
            uploaded[0] = upload_succeeds
            return upload_succeeds

        runner._upload_json = mock_upload_json
        runner._timestamp = 123456789
        runner._utc_timestamp = datetime.datetime(2013, 2, 8, 15, 19, 37, 460000)
        with OutputCapture(level=logging.INFO) as capturer:
            self.assertEqual(runner.run(), expected_exit_code)

        if not expected_exit_code and compare_logs:
            expected_logs = ''
            for i in range(repeat):
                runs = ' (Run %d of %d)' % (i + 1, repeat) if repeat > 1 else ''
                expected_logs += 'Running 2 tests%s\n' % runs + EventTargetWrapperTestData.output + SomeParserTestData.output
            if results_shown:
                expected_logs += 'MOCK: user.open_url: file://...\n'
            self.assertEqual(self._normalize_output(capturer.root.log.getvalue()), expected_logs)

        self.assertEqual(uploaded[0], upload_succeeds)

        return capturer.root.log.getvalue()
Ejemplo n.º 14
0
    def test_number(self):
        with OutputCapture() as captured, mocks.local.Git(
                self.path) as mock, mocks.local.Svn(), MockTime:
            contirbutors = Contributor.Mapping()
            contirbutors.create('Jonathan Bedard', '*****@*****.**')

            self.assertEqual(
                0,
                program.main(
                    args=('canonicalize', '--number', '3'),
                    path=self.path,
                    contributors=contirbutors,
                ))

            self.assertEqual(
                local.Git(self.path).commit(identifier='5@main').message,
                'Patch Series\nIdentifier: 5@main')
            self.assertEqual(
                local.Git(self.path).commit(identifier='4@main').message,
                '8th commit\nIdentifier: 4@main')
            self.assertEqual(
                local.Git(self.path).commit(identifier='3@main').message,
                '4th commit\nIdentifier: 3@main')

        self.assertEqual(
            captured.stdout.getvalue(),
            'Rewrite 1abe25b443e985f93b90d830e4a7e3731336af4d (1/3) (--- seconds passed, remaining --- predicted)\n'
            'Rewrite bae5d1e90999d4f916a8a15810ccfa43f37a2fd6 (2/3) (--- seconds passed, remaining --- predicted)\n'
            'Rewrite d8bce26fa65c6fc8f39c17927abb77f69fab82fc (3/3) (--- seconds passed, remaining --- predicted)\n'
            '3 commits successfully canonicalized!\n',
        )
Ejemplo n.º 15
0
    def test_convert_for_webkit_nothing_to_convert(self):
        """ Tests convert_for_webkit() using a basic test that has nothing to convert """

        test_html = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR"
href="mailto:EMAIL OR http://CONTACT_PAGE"/>
<link rel="help" href="RELEVANT_SPEC_SECTION"/>
<meta name="assert" content="TEST ASSERTION"/>
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
        converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None)

        with OutputCapture():
            converter.feed(test_html)
            converter.close()
            converted = converter.output()

        self.verify_no_conversion_happened(converted, test_html)
Ejemplo n.º 16
0
    def test_convert_attributes_if_needed(self):
        """ Tests convert_attributes_if_needed() using a reference file that has some relative src paths """

        test_html = """<html>
<head>
<link href="../support/base-style.css">
<video src="resources/video.mkv"></video>
<script src="../../some-script.js"></script>
<style src="../../../some-style.css"></style>
</head>
<body>
<img src="../../../../some-image.jpg">
</body>
</html>
"""
        test_reference_support_info = {'reference_relpath': '../', 'files': ['../../some-script.js', '../../../some-style.css', '../../../../some-image.jpg', '../support/base-style.css', 'resources/video.mkv'],
                                       'elements': ['script', 'style', 'img', 'link', 'video']}
        converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference_support_info)

        with OutputCapture():
            converter.feed(test_html)
            converter.close()
            converted = converter.output()

        self.verify_conversion_happened(converted)
        self.verify_reference_relative_paths(converted, test_reference_support_info)
Ejemplo n.º 17
0
    def test_convert_for_webkit_harness_and_properties(self):
        """ Tests convert_for_webkit() using a basic JS test that uses testharness.js and testharness.css and has 4 prefixed properties: 3 in a style block + 1 inline style """

        test_html = """<html>
<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
<style type="text/css">

#block1 { @test0@: @propvalue0@; }
#block2 { @test1@: @propvalue1@; }
#block3 { @test2@: @propvalue2@; }

</style>
</head>
<body>
<div id="elem1" style="@test3@: @propvalue3@;"></div>
</body>
</html>
"""
        fake_dir_path = self.fake_dir_path('harnessandprops')
        converter = _W3CTestConverter(fake_dir_path, DUMMY_FILENAME, None)

        with OutputCapture():
            test_content = self.generate_test_content_properties_and_values(converter.prefixed_properties, converter.prefixed_property_values, 2, test_html)
            converter.feed(test_content[2])
            converter.close()
            converted = converter.output()

        self.verify_conversion_happened(converted)
        self.verify_test_harness_paths(converter, converted[2], fake_dir_path, 1, 1)
        self.verify_prefixed_properties(converted, test_content[0])
        self.verify_prefixed_property_values(converted, test_content[1])
Ejemplo n.º 18
0
    def test_create_bug_for_flaky_test(self):
        reporter = FlakyTestReporter(MockTool(), 'dummy-queue')

        with OutputCapture(level=logging.INFO) as captured:
            reporter._create_bug_for_flaky_test('foo/bar.html',
                                                ['*****@*****.**'],
                                                'FLAKE_MESSAGE')
        self.assertEqual(
            captured.root.log.getvalue(),
            """MOCK create_bug
bug_title: Flaky Test: foo/bar.html
bug_description: This is an automatically generated bug from the dummy-queue.
foo/bar.html has been flaky on the dummy-queue.

foo/bar.html was authored by [email protected].
https://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html

FLAKE_MESSAGE

The bots will update this with information from each new failure.

If you believe this bug to be fixed or invalid, feel free to close.  The bots will re-open if the flake re-occurs.

If you would like to track this test fix with another bug, please close this bug as a duplicate.  The bots will follow the duplicate chain when making future comments.

component: Tools / Tests
cc: [email protected]
blocked: 50856
""",
        )
Ejemplo n.º 19
0
    def test_start_cmd(self):
        # Fails on win - see https://bugs.webkit.org/show_bug.cgi?id=84726
        if sys.platform.startswith('win') or sys.platform == 'cygwin':
            return

        def fake_pid(_):
            host.filesystem.write_text_file('/tmp/WebKit/httpd.pid', '42')
            return True

        host = MockHost()
        host.executive = MockExecutive(should_log=True)
        test_port = test.TestPort(host)
        host.filesystem.write_text_file(test_port._path_to_apache_config_file(), '')
        host.filesystem.write_text_file(
            "/mock-checkout/Tools/Scripts/webkitpy/layout_tests/servers/aliases.json", '[["/js-test-resources", "resources"], ["/media-resources", "media"], ["/test/test.file", "resources/testfile"]]')

        server = LayoutTestApacheHttpd(test_port, "/mock/output_dir")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        server._wait_for_action = fake_pid

        self.assertEqual(server.ports_to_forward(), [8000, 8080, 8443])

        with OutputCapture():
            server.start()
            server.stop()

        self.assertTrue(host.filesystem.exists("/mock/output_dir/httpd.conf"))
Ejemplo n.º 20
0
    def assert_execute_outputs(self,
                               command,
                               args=[],
                               expected_stdout="",
                               expected_stderr="",
                               expected_exception=None,
                               expected_logs=None,
                               options=MockOptions(),
                               tool=MockTool()):
        options.blocks = None
        if getattr(options, "cc", None) == None:
            options.cc = 'MOCK cc'
        if getattr(options, "cc_radar", None) == None:
            options.cc_radar = False
        options.component = 'MOCK component'
        options.confirm = True
        options.email = 'MOCK email'
        options.git_commit = 'MOCK git commit'
        options.obsolete_patches = True
        options.open_bug = True
        options.port = 'MOCK port'
        options.update_changelogs = False
        options.quiet = True
        options.reviewer = 'MOCK reviewer'
        command.bind_to_tool(tool)

        with OutputCapture(level=logging.INFO) as captured:
            command.execute(options, args, tool)
        self.assertEqual(captured.stdout.getvalue(), expected_stdout or '')
        self.assertEqual(captured.stderr.getvalue(), expected_stderr or '')
        self.assertEqual(captured.root.log.getvalue(), expected_logs or '')
Ejemplo n.º 21
0
    def test_cc_rule_with_complex_logic(self):
        watch_list = (
            '{'
            '    "DEFINITIONS": {'
            '        "WatchList1": {'
            '            "filename": r".*MyFileName\\.cpp",'
            '        },'
            '        "WatchList2": {'
            '            "filename": r".*MyFileName\\.h",'
            '        },'
            '        "WatchList3": {'
            '            "filename": r".*MyFileName\\.o",'
            '        },'
            '     },'
            '    "CC_RULES": {'
            '        "!WatchList1&!WatchList2|!WatchList3&!WatchListUndefined": ["*****@*****.**"]'
            '     },'
            '    "MESSAGE_RULES": {'
            '        "!WatchList1|WatchList2&!WatchList3|!WatchListUndefined": ["*****@*****.**"]'
            '     },'
            '}')

        with OutputCapture(level=logging.INFO) as captured:
            self._watch_list_parser.parse(watch_list)
        self.assertEqual(
            captured.root.log.getvalue(),
            '''In section "CC_RULES", the following definitions are not used and should be removed: WatchListUndefined

Perhaps it should be WatchList3 or WatchList2 or WatchList1.
In section "MESSAGE_RULES", the following definitions are not used and should be removed: WatchListUndefined

Perhaps it should be WatchList3 or WatchList2 or WatchList1.
''',
        )
Ejemplo n.º 22
0
    def test_analyze_test_reftest_match_and_mismatch(self):
        test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="mismatch" href="orange-box-notref.xht" />
</head>
"""
        with OutputCapture(level=logging.INFO) as captured:
            test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
            parser = TestParser(options,
                                os.path.join(test_path, 'somefile.html'))
            test_info = parser.analyze_test(test_contents=test_html)

        self.assertNotEqual(test_info, None, 'did not find a test')
        self.assertTrue('test' in test_info.keys(), 'did not find a test file')
        self.assertTrue('reference' in test_info.keys(),
                        'did not find a reference file')
        self.assertTrue(test_info['reference'].startswith(test_path),
                        'reference path is not correct')
        self.assertFalse('refsupport' in test_info.keys(),
                         'there should be no refsupport files for this test')
        self.assertFalse('jstest' in test_info.keys(),
                         'test should not have been analyzed as a jstest')

        self.assertEqual(
            captured.root.log.getvalue(),
            'Multiple references are not supported. Importing the first ref defined in somefile.html\n',
        )
Ejemplo n.º 23
0
    def test_changelog_contains_oops(self):
        tool = MockTool()
        tool._checkout.is_path_to_changelog = lambda path: True
        step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=True, check_oops=True))
        diff_file = Mock()
        diff_file.filename = "mock/ChangeLog"
        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS! bar"), (3, 3, "foo")]

        with OutputCapture(level=logging.INFO) as captured:
            self.assertTrue(step._changelog_contains_oops(diff_file))
        self.assertEqual(captured.root.log.getvalue(), '')

        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS bar"), (3, 3, "foo")]
        with OutputCapture(level=logging.INFO) as captured:
            self.assertFalse(step._changelog_contains_oops(diff_file))
        self.assertEqual(captured.root.log.getvalue(), '')
Ejemplo n.º 24
0
    def test_count_total_bytes_and_unique_leaks(self):
        detector = self._make_detector()

        def mock_run_script(name, args, include_configuration_arguments=False):
            print("MOCK _run_script: %s %s" % (name, args))
            return """1 calls for 16 bytes: -[NSURLRequest mutableCopyWithZone:] | +[NSObject(NSObject) allocWithZone:] | _internal_class_createInstanceFromZone | calloc | malloc_zone_calloc

147 calls for 9,408 bytes: _CFRuntimeCreateInstance | _ZN3WTF24StringWrapperCFAllocatorL8allocateElmPv StringImplCF.cpp:67 | WTF::fastMalloc(unsigned long) FastMalloc.cpp:268 | malloc | malloc_zone_malloc 

total: 5,888 bytes (0 bytes excluded)."""

        detector._port._run_script = mock_run_script

        leak_files = [
            '/mock-results/DumpRenderTree-1234-leaks.txt',
            '/mock-results/DumpRenderTree-1235-leaks.txt'
        ]
        with OutputCapture() as captured:
            results_tuple = detector.count_total_bytes_and_unique_leaks(
                leak_files)
        self.assertEqual(
            captured.stdout.getvalue(),
            "MOCK _run_script: parse-malloc-history ['--merge-depth', 5, '/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-1235-leaks.txt']\n",
        )
        self.assertEqual(results_tuple, ("5,888 bytes", 2))
Ejemplo n.º 25
0
 def test_disabled(self):
     step = SuggestReviewers(MockTool(),
                             MockOptions(suggest_reviewers=False))
     with OutputCapture(level=logging.INFO) as captured:
         step.run({})
     self.assertEqual(captured.stdout.getvalue(), '')
     self.assertEqual(captured.root.log.getvalue(), '')
Ejemplo n.º 26
0
 def test_exception_no_fork(self):
     with OutputCapture(level=logging.INFO) as captured:
         with self.assertRaises(RuntimeError):
             with TaskPool(workers=1, force_fork=False) as pool:
                 pool.do(exception, 'Testing exception')
                 pool.wait()
     self.assertEqual(captured.webkitcorepy.log.getvalue(), '')
Ejemplo n.º 27
0
 def test_invalid(self):
     with OutputCapture(), mocks.local.Git(), mocks.local.Svn(
             self.path), MockTime:
         self.assertEqual(
             1, program.main(
                 args=('canonicalize', ),
                 path=self.path,
             ))
Ejemplo n.º 28
0
 def test_single_trigger(self):
     with mocks.Time, OutputCapture():
         with Timeout(1):
             with self.assertRaises(Timeout.Exception):
                 time.sleep(2)
             time.sleep(
                 2
             )  # The timeout has already been triggered, so it shouldn't be re-triggered.
Ejemplo n.º 29
0
    def test_commit_info(self):
        command = AbstractRevertPrepCommand()
        tool = MockTool()
        command.bind_to_tool(tool)

        with OutputCapture(level=logging.INFO) as captured:
            commit_info = command._commit_info(1234)
        self.assertEqual(captured.root.log.getvalue(), 'Preparing revert for bug 50000.\n')
        self.assertTrue(commit_info)

        mock_commit_info = Mock()
        mock_commit_info.bug_id = lambda: None
        tool._checkout.commit_info_for_revision = lambda revision: mock_commit_info
        with OutputCapture(level=logging.INFO) as captured:
            commit_info = command._commit_info(1234)
        self.assertEqual(captured.root.log.getvalue(), 'Unable to parse bug number from diff.\n')
        self.assertEqual(commit_info, mock_commit_info)
Ejemplo n.º 30
0
    def test_warn_if_application_is_xcode(self):
        user = User()
        with OutputCapture() as captured:
            user._warn_if_application_is_xcode('TextMate')
            user._warn_if_application_is_xcode('/Applications/TextMate.app')
            user._warn_if_application_is_xcode('XCode')
        self.assertEqual(captured.stdout.getvalue(), '')

        with OutputCapture() as captured:
            user._warn_if_application_is_xcode('Xcode')
            user._warn_if_application_is_xcode(
                '/Developer/Applications/Xcode.app')
        self.assertEqual(
            captured.stdout.getvalue(),
            'Instead of using Xcode.app, consider using EDITOR=\"xed --wait\".\n'
            * 2,
        )