Bug 214475

Summary: [webkitcorepy] Add mocks.Time
Product: WebKit Reporter: Jonathan Bedard <jbedard>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, dean_johnson, dewei_zhu, slewis, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=214378
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Description Jonathan Bedard 2020-07-17 07:34:39 PDT
Add a class which allows timeouts and time.sleep to function during unit testing without actually waiting.
Comment 1 Jonathan Bedard 2020-07-17 07:44:35 PDT
Created attachment 404560 [details]
Patch
Comment 2 Jonathan Bedard 2020-07-22 12:17:28 PDT
Created attachment 404946 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2020-07-24 07:35:17 PDT
<rdar://problem/66052539>
Comment 4 Jonathan Bedard 2020-07-30 09:17:45 PDT
Created attachment 405578 [details]
Patch
Comment 5 Jonathan Bedard 2020-07-30 21:18:31 PDT
Created attachment 405663 [details]
Patch
Comment 6 Jonathan Bedard 2020-08-04 12:56:48 PDT
Created attachment 405937 [details]
Patch
Comment 7 Jonathan Bedard 2020-08-04 22:23:14 PDT
Created attachment 405986 [details]
Patch
Comment 8 Jonathan Bedard 2020-08-07 08:15:53 PDT
Created attachment 406176 [details]
Patch
Comment 9 dewei_zhu 2020-08-07 11:12:37 PDT
Comment on attachment 406176 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406176&action=review

> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/time_.py:53
> +        self.patches.append([

Interesting, I thought patches is a list of patch, but it's actually a list of patch list. Correct?
Comment 10 Jonathan Bedard 2020-08-07 11:24:12 PDT
Comment on attachment 406176 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406176&action=review

>> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/time_.py:53
>> +        self.patches.append([
> 
> Interesting, I thought patches is a list of patch, but it's actually a list of patch list. Correct?

Yes! That lets us stack this context, so something like this:

with mocks.Time:
    with mocks.Time:
         pass

Not something generally want to do, but a caller may not know what it's callees are doing.
Comment 11 Jonathan Bedard 2020-08-07 11:56:23 PDT
Created attachment 406196 [details]
Patch for landing
Comment 12 EWS 2020-08-07 12:24:31 PDT
Committed r265386: <https://trac.webkit.org/changeset/265386>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 406196 [details].