Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check all events in logged_in_checkpoint #218

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

9999years
Copy link
Member

In the test harness, we use methods like assert_logged_in_checkpoint and assert_logged_or_wait to find events in a checkpoint. These methods error when no matching event is found and when the matcher errors.

Matcher errors are important -- the NegativeMatcher will error if its contained matcher matches an event, so we need to:

  1. Check every event in the checkpoint when using these methods, even if we find a matching event early.
  2. Have a separate method that only errors if the matcher errors (to distinguish between "matching failed" and "no matching event was found") — this lets assert_logged_or_wait distinguish between a matcher error (which should be propagated) and a missing event (so that it can wait for an event to be logged).

@9999years 9999years requested a review from Gabriella439 April 11, 2024 16:25
@9999years 9999years force-pushed the rebeccat/logged-in-checkpoint-all-events branch from e7c567c to 830c796 Compare April 11, 2024 17:13
@9999years 9999years enabled auto-merge (squash) April 11, 2024 17:57
In the test harness, we use methods like `assert_logged_in_checkpoint`
and `assert_logged_or_wait` to find events in a checkpoint. These
methods error when no matching event is found and when the matcher
errors.

Matcher errors are important -- the `NegativeMatcher` will error if its
contained matcher matches an event, so we need to:

1. Check every event in the checkpoint when using these methods, even if
   we find a matching event early.
2. Have a separate method that only errors if the matcher errors (to
   distinguish between "matching failed" and "no matching event was
   found") -- this lets `assert_logged_or_wait` distinguish between a
   matcher error (which should be propagated) and a missing event (so
   that it can wait for an event to be logged).
@9999years 9999years force-pushed the rebeccat/logged-in-checkpoint-all-events branch from 830c796 to 6c8805a Compare April 11, 2024 19:29
Comment on lines +413 to +414
if matcher.matches(event)? && ret.is_none() {
ret = Some(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick, but I think this is equivalent:

Suggested change
if matcher.matches(event)? && ret.is_none() {
ret = Some(event)
if matcher.matches(event)? {
return Ok(Some(event))

Copy link
Member Author

Choose a reason for hiding this comment

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

That short-circuits and doesn't give the matcher a chance to error on later events.

@9999years 9999years merged commit 00ddf09 into main Apr 11, 2024
28 checks passed
@9999years 9999years deleted the rebeccat/logged-in-checkpoint-all-events branch April 11, 2024 22:01
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