Changeset 213562 in webkit


Ignore:
Timestamp:
Mar 7, 2017 7:46:19 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Perf and layout test results should report using correct scm revision.
https://bugs.webkit.org/show_bug.cgi?id=169171

Patch by Kocsen Chung <Kocsen Chung> on 2017-03-07
Reviewed by Ryosuke Niwa.

For accurate record keeping, perf test and layout test results should
report using the native scm revision as an identifier.
To do so we introduce a new scm functions:

native_revision() and timestamp_of_native_revision().

The former is responsible for returning a git hash if scm.git or an
svn revision if scm.svn. The latter is responsible for retrieving the correct timestamp.
We also add the corresponding tests and a helper function _most_recent_log_for_revision.

  • Scripts/webkitpy/common/checkout/scm/scm.py:

(SCM.run):
Drive-by indentation fix to adhere to WebKit style conventions.
(SCM.svn_revision):
Remove superfluous comment.
(SCM.native_revision):
Add new abstract function native_revision and make it a _subclass_must_implement()
as we want to closely mimic svn_revision() function due to their similar behavior.
(SCM.timestamp_of_native_revision):
Add new abstract function timestamp_of_native_revision to closely mimic timestamp_of_revision.

  • Scripts/webkitpy/common/checkout/scm/git.py:

(Git._most_recent_log_for_revision):
New helper function similar to _most_recent_log_matching that is git hash friendly.
(Git.native_revision):
Implement new function native_revision(). Get the native_revision by running:

git log -1 --pretty=format:%H

and thus returning the latest git hash (in long format).
(Git.timestamp_of_native_revision):
Since perftestrunner and layout_test.controllers.manager use the new native_revision
function, we create a new native_revision timestamp retriever.
You will notice this uses a far more simplified way to retrieve UTC strict-ISO timestamp
than its non-native counterpart: timestamp_of_revision().

  • Scripts/webkitpy/common/checkout/scm/svn.py:

(SVN.native_revision):
Implement native_revision for SVN: simply return self.svn_revision()
(SVN.timestamp_of_native_revision):
Implement timestamp_of_native_revision for SVN: simply return self.timestamp_of_revision()

  • Scripts/webkitpy/common/checkout/scm/scm_unittest.py:

(test_native_revision):
[SVN] Confirm that svn_revision == native_revision. And that native_revision returns 5.
Use '.' as the path parameter instead of svn_checkout_path to avoid violating pylint/E1101
and since we are guaranteed by test setUp to be in the correct SVN dir.
(GitTest.test_native_revision):
[Git] Confirm that git rev-parse HEAD is equal to newly implemented native_revision().
(GitSVNTest.test_native_revision):
[Git] Confirm that git rev-parse HEAD is equal to newly implemented native_revision().
(test_timestamp_of_native_revision):
Test new function timestamp_of_native_revision. Very similar fashion to
test_timestamp_of_revision.

  • Scripts/webkitpy/common/checkout/scm/scm_mock.py:

(MockSCM.native_revision):
Add MockSCM.native_revision to behave like svn.py (default).
(MockSCM.test_native_revision):
Add MockSCM.test_native_revision to behave like its non-native counterpart.

  • Scripts/webkitpy/layout_tests/controllers/manager.py:

(Manager.upload_results):
When iterating through a list of projects, make sure we use the project's new native revision.

  • Scripts/webkitpy/performance_tests/perftestsrunner.py:

(_generate_results_dict):
As per the FIXME in manager.py, we have duplicate code in perftestsrunner.py.
So make the same exact change here.

Location:
trunk/Tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r213555 r213562  
     12017-03-07  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Perf and layout test results should report using correct scm revision.
     4        https://bugs.webkit.org/show_bug.cgi?id=169171
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        For accurate record keeping, perf test and layout test results should
     9        report using the native scm revision as an identifier.
     10        To do so we introduce a new scm functions:
     11            `native_revision()` and `timestamp_of_native_revision()`.
     12        The former is responsible for returning a git hash if scm.git or an
     13        svn revision if scm.svn. The latter is responsible for retrieving the correct timestamp.
     14        We also add the corresponding tests and a helper function `_most_recent_log_for_revision`.
     15
     16        * Scripts/webkitpy/common/checkout/scm/scm.py:
     17        (SCM.run):
     18        Drive-by indentation fix to adhere to WebKit style conventions.
     19        (SCM.svn_revision):
     20        Remove superfluous comment.
     21        (SCM.native_revision):
     22        Add new abstract function `native_revision` and make it a `_subclass_must_implement()`
     23        as we want to closely mimic `svn_revision()` function due to their similar behavior.
     24        (SCM.timestamp_of_native_revision):
     25        Add new abstract function `timestamp_of_native_revision` to closely mimic `timestamp_of_revision`.
     26
     27        * Scripts/webkitpy/common/checkout/scm/git.py:
     28        (Git._most_recent_log_for_revision):
     29        New helper function similar to `_most_recent_log_matching` that is git hash friendly.
     30        (Git.native_revision):
     31        Implement new function `native_revision()`. Get the native_revision by running:
     32
     33            `git log -1 --pretty=format:%H`
     34
     35        and thus returning the latest git hash (in long format).
     36        (Git.timestamp_of_native_revision):
     37        Since perftestrunner and layout_test.controllers.manager use the new native_revision
     38        function, we create a new native_revision timestamp retriever.
     39        You will notice this uses a far more simplified way to retrieve UTC strict-ISO timestamp
     40        than its non-native counterpart: `timestamp_of_revision()`.
     41        * Scripts/webkitpy/common/checkout/scm/svn.py:
     42        (SVN.native_revision):
     43        Implement native_revision for SVN: simply return self.svn_revision()
     44        (SVN.timestamp_of_native_revision):
     45        Implement timestamp_of_native_revision for SVN: simply return self.timestamp_of_revision()
     46
     47        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
     48        (test_native_revision):
     49        [SVN] Confirm that svn_revision == native_revision. And that native_revision returns 5.
     50        Use '.' as the path parameter instead of svn_checkout_path to avoid violating pylint/E1101
     51        and since we are guaranteed by test setUp to be in the correct SVN dir.
     52        (GitTest.test_native_revision):
     53        [Git] Confirm that `git rev-parse HEAD` is equal to newly implemented native_revision().
     54        (GitSVNTest.test_native_revision):
     55        [Git] Confirm that `git rev-parse HEAD` is equal to newly implemented native_revision().
     56        (test_timestamp_of_native_revision):
     57        Test new function `timestamp_of_native_revision`. Very similar fashion to
     58        `test_timestamp_of_revision`.
     59
     60        * Scripts/webkitpy/common/checkout/scm/scm_mock.py:
     61        (MockSCM.native_revision):
     62        Add MockSCM.native_revision to behave like svn.py (default).
     63        (MockSCM.test_native_revision):
     64        Add MockSCM.test_native_revision to behave like its non-native counterpart.
     65
     66        * Scripts/webkitpy/layout_tests/controllers/manager.py:
     67        (Manager.upload_results):
     68        When iterating through a list of projects, make sure we use the project's new native revision.
     69        * Scripts/webkitpy/performance_tests/perftestsrunner.py:
     70        (_generate_results_dict):
     71        As per the FIXME in manager.py, we have duplicate code in perftestsrunner.py.
     72        So make the same exact change here.
     73
    1742017-03-07  Tim Horton  <timothy_horton@apple.com>
    275
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py

    r203832 r213562  
    271271        return self._run_git(['log', '-1', '--grep=' + grep_str, '--date=iso', self.find_checkout_root(path)])
    272272
     273    def _most_recent_log_for_revision(self, revision, path):
     274        return self._run_git(['log', '-1', revision, '--date=iso', self.find_checkout_root(path)])
     275
    273276    def svn_revision(self, path):
    274277        git_log = self._most_recent_log_matching('git-svn-id:', path)
     
    277280            return ""
    278281        return str(match.group('svn_revision'))
     282
     283    def native_revision(self, path):
     284        return self._run_git(['log', '-1', '--pretty=format:%H', self.find_checkout_root(path)])
    279285
    280286    def svn_url(self):
     
    300306        time_without_timezone = time_with_timezone - datetime.timedelta(hours=sign * int(match.group(8)), minutes=int(match.group(9)))
    301307        return time_without_timezone.strftime('%Y-%m-%dT%H:%M:%SZ')
     308
     309    def timestamp_of_native_revision(self, path, sha):
     310        unix_timestamp = self._run_git(['log', '-1', sha, '--pretty="format:%ct"', self.find_checkout_root(path)]).rstrip()
     311        commit_timestamp = datetime.datetime.utcfromtimestamp(float(unix_timestamp))
     312        return commit_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')
    302313
    303314    def prepend_svn_revision(self, diff):
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py

    r202362 r213562  
    7070        # FIXME: We should set cwd appropriately.
    7171        return self._executive.run_command(args,
    72                            cwd=cwd,
    73                            input=input,
    74                            error_handler=error_handler,
    75                            return_exit_code=return_exit_code,
    76                            return_stderr=return_stderr,
    77                            decode_output=decode_output)
     72            cwd=cwd,
     73            input=input,
     74            error_handler=error_handler,
     75            return_exit_code=return_exit_code,
     76            return_stderr=return_stderr,
     77            decode_output=decode_output)
    7878
    7979    # SCM always returns repository relative path, but sometimes we need
     
    159159
    160160    def svn_revision(self, path):
    161         """Returns the latest svn revision found in the checkout."""
     161        self._subclass_must_implement()
     162
     163    def native_revision(self, path):
    162164        self._subclass_must_implement()
    163165
    164166    def timestamp_of_revision(self, path, revision):
     167        self._subclass_must_implement()
     168
     169    def timestamp_of_native_revision(self, path, revision):
    165170        self._subclass_must_implement()
    166171
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py

    r212579 r213562  
    8585        return '5678'
    8686
     87    def native_revision(self, path):
     88        return self.svn_revision(path)
     89
    8790    def timestamp_of_revision(self, path, revision):
     91        return '2013-02-01 08:48:05 +0000'
     92
     93    def timestamp_of_native_revision(self, path, revision):
    8894        return '2013-02-01 08:48:05 +0000'
    8995
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py

    r208498 r213562  
    903903        self._shared_test_head_svn_revision()
    904904
     905    def test_native_revision(self):
     906        self.assertEqual(self.scm.head_svn_revision(), self.scm.native_revision('.'))
     907        self.assertEqual(self.scm.native_revision('.'), '5')
     908
    905909    def test_propset_propget(self):
    906910        filepath = os.path.join(self.svn_checkout_path, "test_file")
     
    10811085        self.assertEqual(scm.head_svn_revision(), '')
    10821086
     1087    def test_native_revision(self):
     1088        scm = self.tracking_scm
     1089        command = ['git', '-C', scm.checkout_root, 'rev-parse', 'HEAD']
     1090        self.assertEqual(scm.native_revision(scm.checkout_root), run_command(command).strip())
     1091
    10831092    def test_rename_files(self):
    10841093        scm = self.tracking_scm
     
    15921601        self._shared_test_head_svn_revision()
    15931602
     1603    def test_native_revision(self):
     1604        command = ['git', '-C', self.git_checkout_path, 'rev-parse', 'HEAD']
     1605        self.assertEqual(self.scm.native_revision(self.git_checkout_path), run_command(command).strip())
     1606
    15941607    def test_to_object_name(self):
    15951608        relpath = 'test_file_commit1'
     
    16731686        scm._run_git = lambda args: 'Date: 2013-02-08 01:55:21 -0800'
    16741687        self.assertEqual(scm.timestamp_of_revision('some-path', '12345'), '2013-02-08T09:55:21Z')
     1688
     1689    def test_timestamp_of_native_revision(self):
     1690        scm = self.make_scm()
     1691        scm.find_checkout_root = lambda path: ''
     1692        scm._run_git = lambda args: '1360310749'
     1693        self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-08T08:05:49Z')
     1694
     1695        scm._run_git = lambda args: '1360279923'
     1696        self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-07T23:32:03Z')
     1697
     1698        scm._run_git = lambda args: '1360317321'
     1699        self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-08T09:55:21Z')
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py

    r203832 r213562  
    269269        return self.value_from_svn_info(path, 'Revision')
    270270
     271    def native_revision(self, path):
     272        return self.svn_revision(path)
     273
    271274    def timestamp_of_revision(self, path, revision):
    272275        # We use --xml to get timestamps like 2013-02-08T08:18:04.964409Z
     
    275278        match = re.search(r"^<date>(?P<value>.+)</date>\r?$", info_output, re.MULTILINE)
    276279        return match.group('value')
     280
     281    def timestamp_of_native_revision(self, path, revision):
     282        return self.timestamp_of_revision(path, revision)
    277283
    278284    # FIXME: This method should be on Checkout.
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py

    r209798 r213562  
    472472        for (name, path) in self._port.repository_paths():
    473473            scm = SCMDetector(self._port.host.filesystem, self._port.host.executive).detect_scm_system(path) or self._port.host.scm()
    474             revision = scm.svn_revision(path)
    475             revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_revision(path, revision)}
     474            revision = scm.native_revision(path)
     475            revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_native_revision(path, revision)}
    476476
    477477        _log.info("Uploading JSON files for master: %s builder: %s build: %s slave: %s to %s", master_name, builder_name, build_number, build_slave, hostname)
  • trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py

    r212182 r213562  
    271271        for (name, path) in self._port.repository_paths():
    272272            scm = SCMDetector(self._host.filesystem, self._host.executive).detect_scm_system(path) or self._host.scm()
    273             revision = scm.svn_revision(path)
    274             revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_revision(path, revision)}
     273            revision = scm.native_revision(path)
     274            revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_native_revision(path, revision)}
    275275
    276276        meta_info = {
Note: See TracChangeset for help on using the changeset viewer.