Title: [284791] trunk/Tools
Revision
284791
Author
jbed...@apple.com
Date
2021-10-25 10:40:11 -0700 (Mon, 25 Oct 2021)

Log Message

[webkitscmpy] Log based tests fail in different timezones
https://bugs.webkit.org/show_bug.cgi?id=232197
<rdar://problem/84615646>

Reviewed by Dewei Zhu.

Tests based on `git log` need to be timezone aware.

* Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
* Scripts/libraries/webkitscmpy/webkitscmpy/test/log_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (284790 => 284791)


--- trunk/Tools/ChangeLog	2021-10-25 17:39:00 UTC (rev 284790)
+++ trunk/Tools/ChangeLog	2021-10-25 17:40:11 UTC (rev 284791)
@@ -1,3 +1,16 @@
+2021-10-25  Jonathan Bedard  <jbed...@apple.com>
+
+        [webkitscmpy] Log based tests fail in different timezones
+        https://bugs.webkit.org/show_bug.cgi?id=232197
+        <rdar://problem/84615646>
+
+        Reviewed by Dewei Zhu.
+
+        Tests based on `git log` need to be timezone aware.
+
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/log_unittest.py:
+
 2021-10-25  Wenson Hsieh  <wenson_hs...@apple.com>
 
         REGRESSION (r284079): Audio continues playing on hulu.com in private browsing mode after closing the tab

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (284790 => 284791)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2021-10-25 17:39:00 UTC (rev 284790)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2021-10-25 17:40:11 UTC (rev 284791)
@@ -21,6 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import time
 
 from datetime import datetime
 from webkitcorepy import run, testing, LoggerCapture, OutputCapture
@@ -317,9 +318,9 @@
                 ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
                 '''commit d8bce26fa65c6fc8f39c17927abb77f69fab82fc
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+AuthorDate: {time_a}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 03:46:40 2020 +0000
+CommitDate: {time_a}
 
     Patch Series
     git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -326,9 +327,9 @@
 
 commit bae5d1e90999d4f916a8a15810ccfa43f37a2fd6
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+AuthorDate: {time_a}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 03:46:40 2020 +0000
+CommitDate: {time_a}
 
     8th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -335,14 +336,16 @@
 
 commit 1abe25b443e985f93b90d830e4a7e3731336af4d
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 02:23:20 2020 +0000
+AuthorDate: {time_b}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 02:23:20 2020 +0000
+CommitDate: {time_b}
 
     4th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc
-'''
-            )
+'''.format(
+                time_a=datetime.utcfromtimestamp(1601668000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
+                time_b=datetime.utcfromtimestamp(1601663000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
+            ))
 
     def test_branch_log(self):
         with mocks.local.Git(self.path, git_svn=True):
@@ -352,9 +355,9 @@
                 ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
                 '''commit 790725a6d79e28db2ecdde29548d2262c0bd059d
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 03:30:00 2020 +0000
+AuthorDate: {time_a}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 03:30:00 2020 +0000
+CommitDate: {time_a}
 
     7th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@7 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -361,9 +364,9 @@
 
 commit 3cd32e352410565bb543821fbf856a6d3caad1c4
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 02:40:00 2020 +0000
+AuthorDate: {time_b}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 02:40:00 2020 +0000
+CommitDate: {time_b}
 
     5th commit
         Cherry pick
@@ -372,14 +375,17 @@
 
 commit a30ce8494bf1ac2807a69844f726be4a9843ca55
 Author:     Jonathan Bedard <jbed...@apple.com>
-AuthorDate: Sat Oct 03 02:06:40 2020 +0000
+AuthorDate: {time_c}
 Commit:     Jonathan Bedard <jbed...@apple.com>
-CommitDate: Sat Oct 03 02:06:40 2020 +0000
+CommitDate: {time_c}
 
     3rd commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@3 268f45cc-cd09-0410-ab3c-d52691b4dbfc
-'''
-            )
+'''.format(
+                time_a=datetime.utcfromtimestamp(1601667000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
+                time_b=datetime.utcfromtimestamp(1601664000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
+                time_c=datetime.utcfromtimestamp(1601662000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
+            ))
 
     def test_cache(self):
         for mock in [mocks.local.Git(self.path), mocks.local.Git(self.path, git_svn=True)]:

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/log_unittest.py (284790 => 284791)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/log_unittest.py	2021-10-25 17:39:00 UTC (rev 284790)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/log_unittest.py	2021-10-25 17:40:11 UTC (rev 284791)
@@ -21,8 +21,11 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import time
 import sys
 
+from datetime import datetime
+
 from webkitcorepy import OutputCapture, Terminal, testing
 from webkitcorepy.mocks import Time as MockTime
 from webkitscmpy import program, mocks
@@ -47,34 +50,37 @@
             captured.stdout.getvalue(),
             '''commit 5@main (d8bce26fa65c6fc8f39c17927abb77f69fab82fc)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     Patch Series
 
 commit 4@main (bae5d1e90999d4f916a8a15810ccfa43f37a2fd6)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     8th commit
 
 commit 3@main (1abe25b443e985f93b90d830e4a7e3731336af4d)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 02:23:20 2020 +0000
+Date:   {}
 
     4th commit
 
 commit 2@main (fff83bb2d9171b4d9196e977eb0508fd57e7a08d)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:50:00 2020 +0000
+Date:   {}
 
     2nd commit
 
 commit 1@main (9b8311f25a77ba14923d9d5a6532103f54abefcb)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:33:20 2020 +0000
+Date:   {}
 
     1st commit
-''',
+'''.format(*reversed([
+                datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000')
+                for commit in mocks.local.Git(self.path).commits['main']
+            ])),
         )
 
     def test_git_svn(self):
@@ -88,7 +94,7 @@
                 captured.stdout.getvalue(),
                 '''commit 5@main (d8bce26fa65c6fc8f39c17927abb77f69fab82fc, r9)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     Patch Series
     git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -95,7 +101,7 @@
 
 commit 4@main (bae5d1e90999d4f916a8a15810ccfa43f37a2fd6, r8)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     8th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -102,7 +108,7 @@
 
 commit 3@main (1abe25b443e985f93b90d830e4a7e3731336af4d, r4)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 02:23:20 2020 +0000
+Date:   {}
 
     4th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -109,7 +115,7 @@
 
 commit 2@main (fff83bb2d9171b4d9196e977eb0508fd57e7a08d, r2)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:50:00 2020 +0000
+Date:   {}
 
     2nd commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@2 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -116,11 +122,14 @@
 
 commit 1@main (9b8311f25a77ba14923d9d5a6532103f54abefcb, r1)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:33:20 2020 +0000
+Date:   {}
 
     1st commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@1 268f45cc-cd09-0410-ab3c-d52691b4dbfc
-''',
+'''.format(*reversed([
+                    datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000')
+                    for commit in mocks.local.Git(self.path).commits['main']
+                ])),
             )
 
     def test_git_svn_revision(self):
@@ -130,12 +139,11 @@
                 path=self.path,
             ))
 
-            self.maxDiff = None
             self.assertEqual(
                 captured.stdout.getvalue(),
                 '''commit r9 (d8bce26fa65c6fc8f39c17927abb77f69fab82fc, 5@main)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     Patch Series
     git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -142,7 +150,7 @@
 
 commit r8 (bae5d1e90999d4f916a8a15810ccfa43f37a2fd6, 4@main)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 03:46:40 2020 +0000
+Date:   {}
 
     8th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -149,7 +157,7 @@
 
 commit r4 (1abe25b443e985f93b90d830e4a7e3731336af4d, 3@main)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 02:23:20 2020 +0000
+Date:   {}
 
     4th commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -156,7 +164,7 @@
 
 commit r2 (fff83bb2d9171b4d9196e977eb0508fd57e7a08d, 2@main)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:50:00 2020 +0000
+Date:   {}
 
     2nd commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@2 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@@ -163,11 +171,14 @@
 
 commit r1 (9b8311f25a77ba14923d9d5a6532103f54abefcb, 1@main)
 Author: Jonathan Bedard <jbed...@apple.com>
-Date:   Sat Oct 03 01:33:20 2020 +0000
+Date:   {}
 
     1st commit
     git-svn-id: https://svn.example.org/repository/repository/trunk@1 268f45cc-cd09-0410-ab3c-d52691b4dbfc
-''',
+'''.format(*reversed([
+                    datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000')
+                    for commit in mocks.local.Git(self.path).commits['main']
+                ])),
             )
 
     def test_svn(self):
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to