Update test for go modules with mutliple variants
Go modules now generate files into a variant-specific subfolder.
Since that subfolder depends on the host os/arch, don't explicitly
check its value, but instead allow anything there.
Bug: 369916167
Test: m --no-skip-soong-tests
Change-Id: I37e395c866d34f596f0936b720b89c8f9615dcf8
diff --git a/golang/golang_test.go b/golang/golang_test.go
index b512144..9c5b809 100644
--- a/golang/golang_test.go
+++ b/golang/golang_test.go
@@ -16,9 +16,10 @@
import (
"android/soong/android"
- "github.com/google/blueprint/bootstrap"
- "path/filepath"
+ "regexp"
"testing"
+
+ "github.com/google/blueprint/bootstrap"
)
func TestGolang(t *testing.T) {
@@ -46,6 +47,12 @@
bin := result.ModuleForTests("gobin", result.Config.BuildOSTarget.String())
- expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "bin/go/gobin/obj/gobin")
- android.AssertPathsRelativeToTopEquals(t, "output files", []string{expected}, bin.OutputFiles(result.TestContext, t, ""))
+ expected := "^out/soong/host/" + result.Config.PrebuiltOS() + "/bin/go/gobin/?[^/]*/obj/gobin$"
+ actual := android.PathsRelativeToTop(bin.OutputFiles(result.TestContext, t, ""))
+ if len(actual) != 1 {
+ t.Fatalf("Expected 1 output file, got %v", actual)
+ }
+ if match, err := regexp.Match(expected, []byte(actual[0])); err != nil || !match {
+ t.Fatalf("Expected output file to match %q, but got %q", expected, actual[0])
+ }
}