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

fix: Resolve the test manifest with the runfiles lib. #1993

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gazelle/manifest/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def gazelle_python_manifest(
attrs = {
"env": {
"_TEST_MANIFEST": "$(rootpath {})".format(manifest),
"_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
"_TEST_MANIFEST_GENERATOR_HASH": "$(rlocationpath {})".format(manifest_generator_hash),
"_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
},
"size": "small",
Expand All @@ -130,7 +130,10 @@ def gazelle_python_manifest(
manifest_generator_hash,
],
rundir = ".",
deps = [Label("//manifest")],
deps = [
Label("//manifest"),
Label("@com_github_bazelbuild_rules_go//go/runfiles"),
],
# kwargs could contain test-specific attributes like size or timeout
**dict(attrs, **kwargs)
)
Expand Down
8 changes: 7 additions & 1 deletion gazelle/manifest/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path/filepath"
"testing"

"github.com/bazelbuild/rules_go/go/runfiles"
"github.com/bazelbuild/rules_python/gazelle/manifest"
)

Expand All @@ -49,7 +50,12 @@ func TestGazelleManifestIsUpdated(t *testing.T) {
t.Fatal("failed to find the Gazelle manifest file integrity")
}

manifestGeneratorHashPath := os.Getenv("_TEST_MANIFEST_GENERATOR_HASH")
manifestGeneratorHashPath, err := runfiles.Rlocation(
os.Getenv("_TEST_MANIFEST_GENERATOR_HASH"))
if err != nil {
t.Fatal("failed to resolve runfiles path of manifest: %v", err)
}

manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath)
if err != nil {
t.Fatalf("opening %q: %v", manifestGeneratorHashPath, err)
Expand Down