Skip to content

add t.Output#90

Merged
flyingmutant merged 1 commit into
flyingmutant:masterfrom
conetcloud:m.gass/add-t-output-vvksmylopnrp
Mar 30, 2026
Merged

add t.Output#90
flyingmutant merged 1 commit into
flyingmutant:masterfrom
conetcloud:m.gass/add-t-output-vvksmylopnrp

Conversation

@mxey
Copy link
Copy Markdown
Contributor

@mxey mxey commented Jan 22, 2026

I tried creating a test but didn't really manage, especially accounting for the different Go versions. I'm not sure how important a test for this is.

for #84

@mxey mxey force-pushed the m.gass/add-t-output-vvksmylopnrp branch 2 times, most recently from b204bbf to 9dc8a2a Compare January 22, 2026 10:38
@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Jan 22, 2026

I added the test for the non-fallback behavior, because that was the easy one.

Actually this seems to pass with older Go versions, so I'm not sure what the other test was for. To be honest, it's been a while since I touched this code :D

@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Mar 27, 2026

@flyingmutant any chance to review this?

@flyingmutant
Copy link
Copy Markdown
Owner

Yep, thanks for the ping. Will take a look tomorrow.

@flyingmutant
Copy link
Copy Markdown
Owner

Looks good overall – but let's remove the fallback with tbWriter, it complicates the code and does not deliver on t.Output promise. Soon everybody will be on 1.25+ anyway :-)

@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Mar 29, 2026

@flyingmutant thanks for the review :)

just to clarify do you mean a) have t.Output be a noop on older Go, b) require Go 1.25, or c) only define t.Output on Go >= 1.25 using build tags? I think b) would make the most sense since with the release of 1.26, 1.25 is now the oldest supported minor release.

@flyingmutant
Copy link
Copy Markdown
Owner

I meant c) – with build tags (as was the case for testing/synctest support). I try to make sure rapid works on "unsupported" Go versions, too – they are quite common in the wild.

@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Mar 30, 2026

@flyingmutant Gotcha. Should I create additional files for t.Output, or rename the existing synctest files to be the catch-all Go 1.25 files? Since you went with panic for SyncTest, I suppose I'll do the same for Output, not just have the method not be there in older Go.

I'll submit another PR to enable Go 1.25 and 1.26 for CI builds, too.

@mxey mxey force-pushed the m.gass/add-t-output-vvksmylopnrp branch 2 times, most recently from 045e97e to 950e921 Compare March 30, 2026 10:24
@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Mar 30, 2026

@flyingmutant OK, I used build tags similar to synctest. Take another look :)

@flyingmutant
Copy link
Copy Markdown
Owner

I think I've communicated poorly here, sorry.

synctest support uses build tags because that's the only way to access testing/synctest package; it nevertheless defines rapid's SyncTest for all versions (which may or may not be a good decision). When I responded above I had in mind to only define Output for newer Go, using build tags – however, that would be inconsistent with what we do for synctest.

But do we really have to use build tags to be consistent with synctest (define the API always, fail on older Go versions)? Looks like interface{ Output() io.Writer } trick should allows us to just use a regular if (like for t.Context()) and keep code simple.

@mxey mxey force-pushed the m.gass/add-t-output-vvksmylopnrp branch from 950e921 to da9d7db Compare March 30, 2026 13:12
@mxey
Copy link
Copy Markdown
Contributor Author

mxey commented Mar 30, 2026

@flyingmutant How about now?

Output will not consistently fail on older Go because it doesn't depend on testing.T.Output unless rawLog isn't set. That's also why my test does not fail on older Go.

Should I move the interface check around so it will always fail on older Go? I don't know if t.tb is always set though.

@flyingmutant flyingmutant merged commit 6e9d413 into flyingmutant:master Mar 30, 2026
14 checks passed
@flyingmutant
Copy link
Copy Markdown
Owner

Great, thanks!

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