Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions gazelle/manifest/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def gazelle_python_manifest(
if requirements:
attrs = {
"env": {
"_TEST_MANIFEST": "$(rootpath {})".format(manifest),
"_TEST_MANIFEST": "$(rlocationpath {})".format(manifest),
"_TEST_MANIFEST_GENERATOR_HASH": "$(rlocationpath {})".format(manifest_generator_hash),
"_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
"_TEST_REQUIREMENTS": "$(rlocationpath {})".format(requirements),
},
"size": "small",
}
Expand Down
24 changes: 16 additions & 8 deletions gazelle/manifest/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,31 @@ import (
"path/filepath"
"testing"

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

func TestGazelleManifestIsUpdated(t *testing.T) {
requirementsPath := os.Getenv("_TEST_REQUIREMENTS")
if requirementsPath == "" {
requirementsPathResolved, err := runfiles.Rlocation(requirementsPath)
if err != nil {
t.Fatalf("failed to resolve runfiles path of requirements: %v", err)
}
if requirementsPathResolved == "" {
t.Fatal("_TEST_REQUIREMENTS must be set")
}

manifestPath := os.Getenv("_TEST_MANIFEST")
if manifestPath == "" {
manifestPathResolved, err := runfiles.Rlocation(manifestPath)
if err != nil {
t.Fatalf("failed to resolve runfiles path of manifest: %v", err)
}
if manifestPathResolved == "" {
t.Fatal("_TEST_MANIFEST must be set")
}

manifestFile := new(manifest.File)
if err := manifestFile.Decode(manifestPath); err != nil {
if err := manifestFile.Decode(manifestPathResolved); err != nil {
t.Fatalf("decoding manifest file: %v", err)
}

Expand All @@ -62,9 +70,9 @@ func TestGazelleManifestIsUpdated(t *testing.T) {
}
defer manifestGeneratorHash.Close()

requirements, err := os.Open(requirementsPath)
requirements, err := os.Open(requirementsPathResolved)
if err != nil {
t.Fatalf("opening %q: %v", requirementsPath, err)
t.Fatalf("opening %q: %v", requirementsPathResolved, err)
}
defer requirements.Close()

Expand All @@ -73,9 +81,9 @@ func TestGazelleManifestIsUpdated(t *testing.T) {
t.Fatalf("verifying integrity: %v", err)
}
if !valid {
manifestRealpath, err := filepath.EvalSymlinks(manifestPath)
manifestRealpath, err := filepath.EvalSymlinks(manifestPathResolved)
if err != nil {
t.Fatalf("evaluating symlink %q: %v", manifestPath, err)
t.Fatalf("evaluating symlink %q: %v", manifestPathResolved, err)
}
t.Errorf(
"%q is out-of-date. Follow the update instructions in that file to resolve this",
Expand Down