Skip to content

Commit

Permalink
make test work with and without bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
jayconrod committed Mar 20, 2024
1 parent c52ffa1 commit 3364dce
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions go/tools/gopackagesdriver/gopackagesdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,25 @@ func TestIncompatible(t *testing.T) {
t.Fatalf("unmarshaling response: %v", err)
}

helloLabel := "@@//:hello"
incompatibleLabel := "@@//:incompatible"
var foundHello bool
rootLabels := make(map[string]bool)
for _, root := range resp.Roots {
if root == helloLabel {
foundHello = true
}
if root == incompatibleLabel {
t.Errorf("response contains root %s", incompatibleLabel)
}
rootLabels[root] = true
}
if !foundHello {
t.Errorf("response does not contain root %s; roots were %s", helloLabel, strings.Join(resp.Roots, ", "))

// Verify //:hello is in .Roots and check whether its label starts with
// "@@" (bzlmod) or "@" (not bzlmod).
var incompatibleLabel string
if rootLabels["@@//:hello"] {
incompatibleLabel = "@@//:incompatible"
} else if rootLabels["@//:hello"] {
incompatibleLabel = "@//:incompatible"
} else {
t.Fatalf("response does not contain //:hello; roots were %s", strings.Join(resp.Roots, ", "))
}

// Verify //:incompatible is NOT in .Roots.
if rootLabels[incompatibleLabel] {
t.Fatalf("response contains root %s", incompatibleLabel)
}
}

Expand Down

0 comments on commit 3364dce

Please sign in to comment.