Changeset 76642 in webkit


Ignore:
Timestamp:
Jan 25, 2011 2:52:17 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

2011-01-25 Dirk Pranke <dpranke@chromium.org>

Reviewed by Tony Chang.

Minor bug fixes and cleanup for filesystem wrappers, port/* test
classes, test_expectations.py. This change adds "test-win" and
"test-mac" variants to the test port so that we can better test
rebaselining, and adds a MockUser() object for reuse in testing.

https://bugs.webkit.org/show_bug.cgi?id=53036

  • Scripts/webkitpy/common/system/filesystem.py:
  • Scripts/webkitpy/common/system/filesystem_mock.py:
  • Scripts/webkitpy/layout_tests/layout_package/test_expectations.py:
  • Scripts/webkitpy/layout_tests/port/factory.py:
  • Scripts/webkitpy/layout_tests/port/base.py:
  • Scripts/webkitpy/layout_tests/port/test.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
  • Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
  • Scripts/webkitpy/tool/mocktool.py:
Location:
trunk/Tools
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r76620 r76642  
     12011-01-25  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        Minor bug fixes and cleanup for filesystem wrappers, port/* test
     6        classes, test_expectations.py. This change adds "test-win" and
     7        "test-mac" variants to the test port so that we can better test
     8        rebaselining, and adds a MockUser() object for reuse in testing.
     9
     10        https://bugs.webkit.org/show_bug.cgi?id=53036
     11
     12        * Scripts/webkitpy/common/system/filesystem.py:
     13        * Scripts/webkitpy/common/system/filesystem_mock.py:
     14        * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py:
     15        * Scripts/webkitpy/layout_tests/port/factory.py:
     16        * Scripts/webkitpy/layout_tests/port/base.py:
     17        * Scripts/webkitpy/layout_tests/port/test.py:
     18        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
     19        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
     20        * Scripts/webkitpy/tool/mocktool.py:
     21
    1222011-01-25  Tony Chang  <tony@chromium.org>
    223
  • trunk/Tools/Scripts/webkitpy/common/system/filesystem.py

    r76199 r76642  
    166166                raise
    167167
    168     def move(self, src, dest):
    169         shutil.move(src, dest)
     168    def move(self, source, destination):
     169        shutil.move(source, destination)
    170170
    171171    def mtime(self, path):
  • trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py

    r76184 r76642  
    7070
    7171        self.files[destination] = self.files[source]
     72        self.written_files[destination] = self.files[source]
    7273
    7374    def dirname(self, path):
     
    197198        pass
    198199
    199     def move(self, src, dst):
    200         if self.files[src] is None:
    201             self._raise_not_found(src)
    202         self.files[dst] = self.files[src]
    203         self.files[src] = None
     200    def move(self, source, destination):
     201        if self.files[source] is None:
     202            self._raise_not_found(source)
     203        self.files[destination] = self.files[source]
     204        self.written_files[destination] = self.files[destination]
     205        self.files[source] = None
     206        self.written_files[source] = None
    204207
    205208    def normpath(self, path):
    206209        return path
    207210
    208     def open_binary_tempfile(self, suffix):
     211    def open_binary_tempfile(self, suffix=''):
    209212        path = self._mktemp(suffix)
    210         return WritableFileObject(self, path), path
     213        return (WritableFileObject(self, path), path)
    211214
    212215    def open_text_file_for_writing(self, path, append=False):
     
    226229            self._raise_not_found(path)
    227230        self.files[path] = None
     231        self.written_files[path] = None
    228232
    229233    def rmtree(self, path):
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py

    r76288 r76642  
    9090        Args:
    9191            port: handle to object containing platform-specific functionality
    92             test: list of all of the test files
     92            tests: list of all of the test files
    9393            expectations: test expectations as a string
    9494            test_platform_name: name of the platform to match expectations
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r76200 r76642  
    583583        Basically this string should contain the equivalent of a
    584584        test_expectations file. See test_expectations.py for more details."""
    585         raise NotImplementedError('Port.test_expectations')
     585        return self._filesystem.read_text_file(self.path_to_test_expectations_file())
    586586
    587587    def test_expectations_overrides(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py

    r68063 r76642  
    7171                                  sys.platform)
    7272
    73     if port_to_use == 'test':
     73    if port_to_use.startswith('test'):
    7474        import test
    7575        maker = test.TestPort
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py

    r76184 r76642  
    3434
    3535from webkitpy.common.system import filesystem_mock
     36from webkitpy.tool import mocktool
    3637
    3738from webkitpy.layout_tests.layout_package import test_output
     
    193194    """Test implementation of the Port interface."""
    194195
    195     def __init__(self, **kwargs):
    196         # FIXME: what happens if we're not passed in the test filesystem
    197         # and the tests don't match what's in the filesystem?
    198         #
    199         # We'll leave as is for now to avoid unnecessary dependencies while
    200         # converting all of the unit tests over to using
    201         # unit_test_filesystem(). If things get out of sync the tests should
    202         # fail in fairly obvious ways. Eventually we want to just do:
    203         #
    204         # assert kwargs['filesystem']._tests
    205         # self._tests = kwargs['filesystem']._tests
    206 
    207         if 'filesystem' not in kwargs or kwargs['filesystem'] is None:
    208             kwargs['filesystem'] = unit_test_filesystem()
    209             self._tests = kwargs['filesystem']._tests
    210         else:
    211             self._tests = unit_test_list()
    212 
    213         kwargs.setdefault('port_name', 'test')
    214         base.Port.__init__(self, **kwargs)
     196    def __init__(self, port_name=None, user=None, filesystem=None, **kwargs):
     197        if not filesystem:
     198            filesystem = unit_test_filesystem()
     199
     200        assert filesystem._tests
     201        self._tests = filesystem._tests
     202
     203        if not user:
     204            user = mocktool.MockUser()
     205
     206        if not port_name or port_name == 'test':
     207            port_name = 'test-mac'
     208
     209        self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'
     210        base.Port.__init__(self, port_name=port_name, filesystem=filesystem, user=user,
     211                           **kwargs)
    215212
    216213    def baseline_path(self):
     
    265262        return ('mac', 'win')
    266263
    267     def test_expectations(self):
    268         return self._filesystem.read_text_file(LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt')
     264    def path_to_test_expectations_file(self):
     265        return self._expectations_path
    269266
    270267    def test_platform_name(self):
     268        if self._name == 'test-win':
     269            return 'win'
    271270        return 'mac'
    272271
     
    275274
    276275    def test_platform_name_to_name(self, test_platform_name):
    277         return test_platform_name
     276        name_map = {
     277            'mac': 'test-mac',
     278            'win': 'test-win',
     279        }
     280        return name_map[test_platform_name]
    278281
    279282    def version(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py

    r76059 r76642  
    3333
    3434from webkitpy.tool import mocktool
    35 from webkitpy.common.system import filesystem_mock
    3635from webkitpy.common.system.executive import Executive, ScriptError
    3736
     
    8988        options = mocktool.MockOptions(configuration=None,
    9089                                       html_directory=None)
    91         filesystem = filesystem_mock.MockFileSystem()
     90        filesystem = port.unit_test_filesystem()
    9291        host_port_obj = port.get('test', options, filesystem=filesystem)
    9392        target_options = options
    9493        target_port_obj = port.get('test', target_options, filesystem=filesystem)
    95         platform = 'test'
     94        platform = target_port_obj.test_platform_name()
    9695        return rebaseline_chromium_webkit_tests.Rebaseliner(
    9796            host_port_obj, target_port_obj, platform, options)
     
    132131    def make_generator(self, files, tests):
    133132        options = mocktool.MockOptions(configuration=None, html_directory='/tmp')
    134         host_port = port.get('test', options, filesystem=filesystem_mock.MockFileSystem(files))
     133        host_port = port.get('test', options, filesystem=port.unit_test_filesystem(files))
    135134        generator = rebaseline_chromium_webkit_tests.HtmlGenerator(
    136135            host_port,
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

    r76398 r76642  
    4646from webkitpy.common.system import outputcapture
    4747from webkitpy.common.system import filesystem_mock
    48 from webkitpy.common.system import user
     48from webkitpy.tool import mocktool
    4949from webkitpy.layout_tests import port
    5050from webkitpy.layout_tests import run_webkit_tests
     
    5555
    5656from webkitpy.thirdparty.mock import Mock
    57 
    58 
    59 class MockUser():
    60     def __init__(self):
    61         self.url = None
    62 
    63     def open_url(self, url):
    64         self.url = url
    6557
    6658
     
    9486    if not port_obj:
    9587        port_obj = port.get(port_name=options.platform, options=options,
    96                             user=MockUser(), filesystem=filesystem)
     88                            user=mocktool.MockUser(), filesystem=filesystem)
    9789    res = run_webkit_tests.run(port_obj, options, parsed_args)
    9890    return res == 0
     
    10496                                      tests_included=tests_included,
    10597                                      print_nothing=False)
    106     user = MockUser()
     98    user = mocktool.MockUser()
    10799    if not port_obj:
    108100        port_obj = port.get(port_name=options.platform, options=options,
     
    136128    options, parsed_args = parse_args(extra_args, tests_included=True)
    137129
    138     user = MockUser()
     130    user = mocktool.MockUser()
    139131
    140132    test_batches = []
     
    217209    def test_full_results_html(self):
    218210        # FIXME: verify html?
    219         self.assertTrue(passing_run(['--full-results-html']))
     211        res, out, err, user = logging_run(['--full-results-html'])
     212        self.assertEqual(res, 0)
    220213
    221214    def test_help_printing(self):
     
    257250    def test_lint_test_files__errors(self):
    258251        options, parsed_args = parse_args(['--lint-test-files'])
    259         user = MockUser()
     252        user = mocktool.MockUser()
    260253        port_obj = port.get(options.platform, options=options, user=user)
    261254        port_obj.test_expectations = lambda: "# syntax error"
     
    353346        self.assertFalse(out.empty())
    354347        self.assertFalse(err.empty())
    355         self.assertEqual(user.url, '/tmp/layout-test-results/results.html')
     348        self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html'])
    356349
    357350    def test_exit_after_n_failures(self):
     
    415408            res, out, err, user = logging_run(['--results-directory=' + str(tmpdir)],
    416409                                              tests_included=True, filesystem=fs)
    417             self.assertEqual(user.url, fs.join(tmpdir, 'results.html'))
     410            self.assertEqual(user.opened_urls, [fs.join(tmpdir, 'results.html')])
    418411
    419412    def test_results_directory_default(self):
     
    423416        # This is the default location.
    424417        res, out, err, user = logging_run(tests_included=True)
    425         self.assertEqual(user.url, '/tmp/layout-test-results/results.html')
     418        self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html'])
    426419
    427420    def test_results_directory_relative(self):
     
    431424        res, out, err, user = logging_run(['--results-directory=foo'],
    432425                                          tests_included=True)
    433         self.assertEqual(user.url, '/tmp/foo/results.html')
     426        self.assertEqual(user.opened_urls, ['/tmp/foo/results.html'])
    434427
    435428    def test_tolerance(self):
     
    442435        def get_port_for_run(args):
    443436            options, parsed_args = run_webkit_tests.parse_args(args)
    444             test_port = ImageDiffTestPort(options=options, user=MockUser())
     437            test_port = ImageDiffTestPort(options=options, user=mocktool.MockUser())
    445438            passing_run(args, port_obj=test_port, tests_included=True)
    446439            return test_port
     
    512505        self.assertEqual(len(file_list), 6)
    513506        self.assertBaselines(file_list,
    514             "/platform/test/passes/image")
     507            "/platform/test-mac/passes/image")
    515508        self.assertBaselines(file_list,
    516             "/platform/test/failures/expected/missing_image")
     509            "/platform/test-mac/failures/expected/missing_image")
    517510
    518511
  • trunk/Tools/Scripts/webkitpy/tool/mocktool.py

    r75787 r76642  
    549549        pass
    550550
     551    def __init__(self):
     552        self.opened_urls = []
     553
    551554    def edit(self, files):
    552555        pass
     
    566569
    567570    def open_url(self, url):
     571        self.opened_urls.append(url)
    568572        if url.startswith("file://"):
    569573            log("MOCK: user.open_url: file://...")
Note: See TracChangeset for help on using the changeset viewer.