-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix gopackagesdriver for Go 1.18 by replicating stdlib and add test for stdliblist.go #3157
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a886327
stdliblist: Fix for Go 1.18 by replicating stdlib
abhinav 6c94802
test/stdlib: Depend on _list_json
abhinav fa5c659
Fix file paths relative to OUTPUT_BASE
abhinav 41c0139
address comments
xytan0056 1de0b73
wip
xytan0056 bcb289f
rebase
xytan0056 89e0cf6
buildifier
xytan0056 68b94d1
clean up
xytan0056 8b0dde2
address comments
xytan0056 0c12fc9
works
xytan0056 d0e87d6
simpler version
xytan0056 309f5de
assume absolute path
xytan0056 7913ea3
test
xytan0056 ca25b77
use external/go_sdk
xytan0056 29449cc
buildifier
xytan0056 9a85829
use workDir
xytan0056 a9f613a
address comments
xytan0056 e568d43
minor renaming
xytan0056 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_stdliblist(t *testing.T) { | ||
testDir := t.TempDir() | ||
outJSON := filepath.Join(testDir, "out.json") | ||
|
||
test_args := []string{ | ||
fmt.Sprintf("-out=%s", outJSON), | ||
fmt.Sprintf("-sdk=%s", "external/go_sdk"), | ||
xytan0056 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
if err := stdliblist(test_args); err != nil { | ||
t.Errorf("calling stdliblist got err: %v", err) | ||
} | ||
f, err := os.Open(outJSON) | ||
if err != nil { | ||
t.Errorf("cannot open output json: %v", err) | ||
} | ||
defer func() { _ = f.Close() }() | ||
scanner := bufio.NewScanner(f) | ||
for scanner.Scan() { | ||
xytan0056 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var result flatPackage | ||
jsonLineStr := scanner.Text() | ||
if err := json.Unmarshal([]byte(jsonLineStr), &result); err != nil { | ||
t.Errorf("cannot parse result line %s \n to goListPackage{}: %v\n", err) | ||
} | ||
if !strings.HasPrefix(result.ID, "@io_bazel_rules_go//stdlib") { | ||
t.Errorf("ID should be prefixed with @io_bazel_rules_go//stdlib :%s", jsonLineStr) | ||
} | ||
if !strings.HasPrefix(result.ExportFile, "__BAZEL_OUTPUT_BASE__") { | ||
t.Errorf("export file should be prefixed with __BAZEL_OUTPUT_BASE__ :%s", jsonLineStr) | ||
} | ||
for _, gofile := range result.GoFiles { | ||
if !strings.HasPrefix(gofile, "__BAZEL_OUTPUT_BASE__/external/go_sdk") { | ||
t.Errorf("All go files should be prefixed with __BAZEL_OUTPUT_BASE__/go_sdk :%s", jsonLineStr) | ||
xytan0056 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This set of flags are reused in other places, which may not require it to be relative path. Let's instead check it in stdliblist to verify it's a relative path
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.
done