-
Notifications
You must be signed in to change notification settings - Fork 378
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
test: don't skip acceptance tests when targeted with -run
#1630
Conversation
aeab4f1
to
7a4d385
Compare
7a4d385
to
edf623e
Compare
func isThisTestRunTarget(t *testing.T) bool { | ||
t.Helper() | ||
|
||
runOnly := flag.Lookup("test.run").Value.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the flag is run
or test.run
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test.run
, as that's actually what is used under the hood I believe because really things are being compiled into a binary, so this prefix helps avoid clashes with tests & binaries that include flags.
Each of these flags is also recognized with an optional 'test.' prefix,
as in -test.v. When invoking the generated test binary (the result of
'go test -c') directly, however, the prefix is mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Hopefully this means I can debug an acceptance test in vscode without having to comment out the "skip if not acceptance test" function now.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1630 +/- ##
==========================================
- Coverage 68.77% 68.75% -0.03%
==========================================
Files 199 199
Lines 18949 18956 +7
==========================================
+ Hits 13032 13033 +1
- Misses 5221 5227 +6
Partials 696 696 ☔ View full report in Codecov by Sentry. |
This is a neat little trick I thought of while cleaning up the snapshots - all its saving us from is having to stick
TEST_ACCEPTANCE=true
in front of ourgo test
calls, but I think it's nice to have the test suite not require that when you're running a specific acceptance test.Credit to
go-snaps
for proving it must be possible, since this is what it does to determine if a snapshot is obsolete or that the tests have just not been run.I've gone with the slightly awkward name
isThisTestRunTarget
as I felt it was less ambiguous thanisThisTestRunning
and similar, since yes the test must be running if the function is being called... 😅