Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle unexpected exits in condition polling#1819

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ubunatic wants to merge5 commits intostretchr:master
base:master
Choose a base branch
Loading
fromubunatic:condition-polling-capture-unexpected-exit

Conversation

@ubunatic
Copy link
Contributor

@ubunaticubunatic commentedOct 26, 2025
edited
Loading

Summary

FailEventually,Never, andEventuallyWithT with"Condition exited unexpectedly"
when the condition goroutine exits unexpectedly throughruntime.Goexit.

Changes

  • Do not hangEventually when condition does not return normally and fail fast instead.
  • Do not hangNever when condition does not return normally to fail fast and prevent false positives.
  • FailEventuallyWithT whenruntime.Goexit was not called throughcollect.FailNow.

Motivation

  • Never currently stops polling, when the condition exits. This can lead to false positives.
  • Eventually currently stop polling, when the condition exits. This prevents fast failures.
  • EventuallyWithT does not fail when the outert fails.

Related issues

This PR is a concise rewrite of#1809 and should fix Issue#1810.

Changed Behavior

Eventually

condition:=func()bool {require.Fail(t,"fail fast on outer 't'")}// before: assert.Eventually would hang until timeout// after:  assert.Eventually fails earlyassert.Eventually(t,condition,time.Second,time.Millisecond*10))// 't' would still fail in both cases

EventuallyWithT

condition:=func(collect*assert.CollectT) {require.Fail(t,"fail fast on outer 't'")}// before: assert.EventuallyWithT would return true// after:  assert.EventuallyWithT returns falseok:=assert.EventuallyWithT(t,condition,time.Second,time.Millisecond*10))// 't' would still fail in both cases

Never

getValue:=func() (int,error) {return1,errors.New("some error")}condition:=func()bool {v,err:=getValue()require.NoError(t,err)returnv==1}// before: assert.Never would hang and then report success// after:  assert.Never fails earlyok:=assert.Never(t,condition,time.Second,time.Millisecond*10)// 't' would still fail in both cases

@ubunaticubunaticforce-pushed thecondition-polling-capture-unexpected-exit branch from3888c76 toa55e775CompareOctober 26, 2025 17:00
@ubunaticubunaticforce-pushed thecondition-polling-capture-unexpected-exit branch froma55e775 to5e8ff6eCompareOctober 26, 2025 17:15
@ubunaticubunatic marked this pull request as ready for reviewOctober 26, 2025 17:31
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@ubunatic

[8]ページ先頭

©2009-2025 Movatter.jp