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 Jan 3, 2024
1 parent 15ff159 commit c698f48
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/integration/gopackagesdriver/gopackagesdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,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 c698f48

Please sign in to comment.