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

cmd/errtrace: Fix toolexec with go run main.go #94

Merged
merged 2 commits into from
Feb 18, 2024
Merged

Conversation

prashantv
Copy link
Contributor

When compiling files passed as command line arguments, go uses a special
package name, "command-line-arguments". Similarly for tests, it uses
"command-line-arguments.test".

Rather than hardcoding these special package names, let's update the
stdlib detection to:

  • Rule out any package with "." (as no stdlib packages contain periods)
  • Look for "-std" in the arguments passed to compile

Update the toolexec tests to compile with files passed directly on the
command line, and verify both "go run" and "go build".

@prashantv prashantv requested a review from abhinav February 18, 2024 21:36
@prashantv prashantv force-pushed the prashant/run-files branch 2 times, most recently from e4a6133 to 024fb28 Compare February 18, 2024 21:38
When compiling files passed as command line arguments, go uses a special
package name, "command-line-arguments". Similarly for tests, it uses
"command-line-arguments.test".

Rather than hardcoding these special package names, let's update the
stdlib detection to:
* Rule out any package with "." (as no stdlib packages contain periods)
* Look for "-std" in the arguments passed to compile

Update the toolexec tests to compile with files passed directly on the
command line, and verify both "go run" and "go build".
Copy link
Contributor

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A+ tests.

@@ -10,6 +10,7 @@ import (
"path/filepath"
"runtime"
"runtime/debug"
"slices"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently have 1.20 in the supported list.
Options: drop the 1.20, or don't use slices.Contains.
Your call. I don't have a preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept 1.20 since it was simple enough to build a pre-1.21 slices contains.

cmd/errtrace/toolexec.go Outdated Show resolved Hide resolved
@prashantv prashantv merged commit c3648ce into main Feb 18, 2024
12 checks passed
@prashantv prashantv deleted the prashant/run-files branch February 18, 2024 22:49
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