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

tests: avoid require in non-initial go routines #977

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Jan 3, 2024

https://pkg.go.dev/testing#T.FailNow

FailNow must be called from the goroutine running the test or benchmark function,
not from other goroutines created during the test

This would cause workflow to hang if it was waiting on goroutine, so introduce helper functions which:

  1. Check assertion
  2. Log failure & mark test failed
  3. Cancel workflow
  4. Abort goroutine

A followup PR will fix calls to compareTableContents

docs:
> FailNow must be called from the goroutine running the test or benchmark function,
> not from other goroutines created during the test

This would cause workflow to hang if it was waiting on goroutine,
so introduce helper functions which:
1. Check assertion
2. Log failure & mark test failed
3. Cancel workflow
4. Abort goroutine

A followup PR will fix calls to compareTableContents after #967 merges too
@serprex serprex force-pushed the no-require-in-goroutine branch from 78543e6 to 7b26d90 Compare January 3, 2024 18:58
@serprex serprex merged commit 7f2862e into main Jan 3, 2024
6 of 7 checks passed
serprex added a commit that referenced this pull request Jan 3, 2024
Split the two use cases into two functions,
e2e.RequireEqualTables & e2e.EnvEqualTables

Which uses interfaces to share code between

Followup for #977
@serprex serprex deleted the no-require-in-goroutine branch January 4, 2024 00:11
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