-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: optionally include full (or relative) path name #37708
Comments
@rogpeppe, @myitcv and myself discussed a very similar idea not too long ago. It's unfortunate that we can't change the default. However, there is some precedent for such an opt-in flag:
I also wonder if |
also ccing @mpvl |
Is there anyway we can do this similar to how the log package sets flags for log outputs?
Proposed:
|
#55976 was closed as a duplicate of this issue, but this one seems to be stuck in the backlog. Can we turn this into a proposal? Moving my comment here for consideration: I've noticed occasionally GoLand links to the wrong file when tests are run from the terminal window inside GoLand. I suspect it's for exactly the reason described above. The filename is ambiguous. There can be multiple files with the same name in a project, and when tests are run from the terminal window, it doesn't know which of those files to link to. An absolute path would allow this feature to work reliably. This problem exists even when I suspect the absolute path is really only useful when the output is being read by another application, and the filename is better when the output is being read by a human. Instead of a new flag to enable this behaviour, the existing 1c72ee7 recently added |
This proposal has been added to the active column of the proposals project |
Excited to see that the proposal will be reviewed at the weekly proposal review meeting! It would be great if there was an option to print the full/relative path of the source file even when the test succeeds. For my company's repos, I'm working on associating tests with owners (using a CODEOWNERS file within the repo). We have large packages that multiple teams contribute too, so it's impossible to assign ownership based on package unless we take on a large amount of refactoring work. It's fairly easy however to assign ownership by files. I'm able to assign ownership to a testcase when it fails based on the filename printed, however, I haven't been able to assign ownership for tests that pass. Printing the full/relative path of the source file for every test run would enable this. |
I think the most reasonable way to do this would be to add an option to So what should the option be? I suggest |
Does anyone object to adding |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Great! Does anyone want to contribute a CL for this? Otherwise I can have a look, but it might be a few weeks until I find the time. |
@stapelberg, I've prepared a CL for this, and I'll send it in the next few days. |
This will help vscode go extension's job much easier. (vscode runs |
Change https://go.dev/cl/463837 mentions this issue: |
I can confirm that setting
Pressing Thanks for getting this implemented :) |
Change https://go.dev/cl/498396 mentions this issue: |
For #37708 Change-Id: I7b04d6331c15771c7d74ff77afd523c435e0dafe Reviewed-on: https://go-review.googlesource.com/c/go/+/498396 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Eli Bendersky <eliben@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Previous discussion happened in issue #21119.
Currently,
t.Error
calls print only the base name of the source file.This is fine when running a single test, but in larger projects, it is a significant productivity boost to have relative (or full) path names, which make the “jump to next compilation error” feature in popular editors work.
I understand the outcome of #21119 (can’t change the default), but I suggest adding a knob to opt into printing relative or full paths.
Perhaps this could be similar to
log.SetFlags
, where you can specify Llongfile or Lshortfile?Let me know if this would be okay, and I’d be happy to send a CL.
The text was updated successfully, but these errors were encountered: