Skip to content

Commit

Permalink
Fix integration tests with Bazel@HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 11, 2023
1 parent 43e644e commit 2ba7d07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions tests/core/transition/hermeticity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ func TestGoProtoLibraryToolAttrsAreReset(t *testing.T) {
}

func assertDependsCleanlyOnWithFlags(t *testing.T, targetA, targetB string, flags ...string) {
// Analyze the targets to ensure that MODULE.bazel.lock has been created, otherwise bazel config
// will fail after the cquery command due to the Skyframe invalidation caused by a changed file.
err := bazel_testing.RunBazel(append([]string{"build", targetA, targetB, "--nobuild"}, flags...)...)
if err != nil {
t.Fatalf("bazel build %s %s: %v", targetA, targetB, err)
}
query := fmt.Sprintf("deps(%s) intersect %s", targetA, targetB)
out, err := bazel_testing.BazelOutput(append(
[]string{
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/gopackagesdriver/gopackagesdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func TestHelloExternal(t *testing.T) {}
}

const (
osPkgID = "@io_bazel_rules_go//stdlib:os"
osPkgID = "@io_bazel_rules_go//stdlib:os"
bzlmodOsPkgID = "@@io_bazel_rules_go//stdlib:os"
)

func TestBaseFileLookup(t *testing.T) {
Expand Down Expand Up @@ -122,16 +123,16 @@ func TestBaseFileLookup(t *testing.T) {
return
}

if pkg.Imports["os"] != osPkgID {
t.Errorf("Expected os import to map to %q:\n%+v", osPkgID, pkg)
if pkg.Imports["os"] != osPkgID && pkg.Imports["os"] != bzlmodOsPkgID {
t.Errorf("Expected os import to map to %q or %q:\n%+v", osPkgID, bzlmodOsPkgID, pkg)
return
}
})

t.Run("dependency", func(t *testing.T) {
var osPkg *gpd.FlatPackage
for _, p := range resp.Packages {
if p.ID == osPkgID {
if p.ID == osPkgID || p.ID == bzlmodOsPkgID {
osPkg = p
}
}
Expand Down

0 comments on commit 2ba7d07

Please sign in to comment.