Skip to content

TimingUtil: improved tests by using Clock#2794

Merged
NachoSoto merged 2 commits into
mainfrom
timing-utils-tests-clock
Jul 12, 2023
Merged

TimingUtil: improved tests by using Clock#2794
NachoSoto merged 2 commits into
mainfrom
timing-utils-tests-clock

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

These tests will be a lot less flaky now since they won't depend on sleeping the current thread, so they won't be susceptible to slow running CI.
Additionally, we can use seconds instead of milliseconds which will remove imprecision errors when determining if the time was over the threshold.

@NachoSoto NachoSoto added the test label Jul 12, 2023
@NachoSoto NachoSoto requested a review from a team July 12, 2023 15:57
@NachoSoto NachoSoto force-pushed the timing-utils-tests-clock branch 2 times, most recently from 34b3603 to 982ec3a Compare July 12, 2023 15:59
These tests will be a lot less flaky now since they won't depend on sleeping the current thread, so they won't be susceptible to slow running CI.
Additionally, we can use `seconds` instead of `milliseconds` which will remove imprecision errors when determining if the time was over the threshold.
@NachoSoto NachoSoto force-pushed the timing-utils-tests-clock branch from 982ec3a to 65e30d3 Compare July 12, 2023 16:05

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question but looks good

)
}

private static func asyncMethod() async {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm is this used for something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply to verify that the calls to measure in those tests take an async closure. They do await Self.asyncMethod to verify that.

@NachoSoto NachoSoto enabled auto-merge (squash) July 12, 2023 17:18
@NachoSoto NachoSoto merged commit dbb1ac5 into main Jul 12, 2023
@NachoSoto NachoSoto deleted the timing-utils-tests-clock branch July 12, 2023 17:19
NachoSoto added a commit that referenced this pull request Jul 19, 2023
**This is an automatic release.**

### Dependency Updates
* Bump fastlane from 2.213.0 to 2.214.0 (#2824) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* `MainThreadMonitor`: don't crash if there is no test in progress
(#2838) via NachoSoto (@NachoSoto)
* `CI`: fixed Fastlane APITester lanes (#2836) via NachoSoto
(@NachoSoto)
* `Integration Tests`: workaround Swift runtime crash (#2826) via
NachoSoto (@NachoSoto)
* `@EnsureNonEmptyArrayDecodable` (#2831) via NachoSoto (@NachoSoto)
* `iOS 17`: added tests for simulating cancellations (#2597) via
NachoSoto (@NachoSoto)
* `CI`: make all `Codecov` jobs `informational` (#2828) via NachoSoto
(@NachoSoto)
* `MainThreadMonitor`: check deadlocks only ever N seconds (#2820) via
NachoSoto (@NachoSoto)
* New `@NonEmptyStringDecodable` (#2819) via NachoSoto (@NachoSoto)
* `MockDeviceCache`: avoid using real `UserDefaults` (#2814) via
NachoSoto (@NachoSoto)
* `throwAssertion`: fixed Xcode 15 compilation (#2813) via NachoSoto
(@NachoSoto)
* `CustomEntitlementsComputation`: fixed API testers (#2815) via
NachoSoto (@NachoSoto)
* `PackageTypeTests`: fixed iOS 12 (#2807) via NachoSoto (@NachoSoto)
* `Tests`: avoid race-condition in leak detection (#2806) via NachoSoto
(@NachoSoto)
* Revert "`Unit Tests`: removed leak detection" (#2805) via NachoSoto
(@NachoSoto)
* `PackageType: Codable` implementation (#2797) via NachoSoto
(@NachoSoto)
* `SystemInfo.init` no longer `throws` (#2803) via NachoSoto
(@NachoSoto)
* `Trusted Entitlements`: add support for signing `POST` body (#2753)
via NachoSoto (@NachoSoto)
* `Tests`: unified default timeouts (#2801) via NachoSoto (@NachoSoto)
* `Tests`: removed forced-unwrap (#2799) via NachoSoto (@NachoSoto)
* `Tests`: added missing `super.setUp()` (#2804) via NachoSoto
(@NachoSoto)
* Replaced `FatalErrorUtil` with `Nimble` (#2802) via NachoSoto
(@NachoSoto)
* `Tests`: fixed another flaky test (#2795) via NachoSoto (@NachoSoto)
* `TimingUtil`: improved tests by using `Clock` (#2794) via NachoSoto
(@NachoSoto)
* `IgnoreDecodeErrors`: log decoding error (#2778) via NachoSoto
(@NachoSoto)
* `TestLogHandler`: changed all tests to explicitly deinitialize it
(#2784) via NachoSoto (@NachoSoto)
* `LocalReceiptParserStoreKitTests`: fixed flaky test failure (#2785)
via NachoSoto (@NachoSoto)
* `Unit Tests`: removed leak detection (#2792) via NachoSoto
(@NachoSoto)
* `Tests`: fixed another flaky failure with asynchronous check (#2786)
via NachoSoto (@NachoSoto)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants