]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: skip TestBuildFortvOS if the SDK is missing
authorElias Naur <mail@eliasnaur.com>
Thu, 21 Mar 2019 12:42:53 +0000 (13:42 +0100)
committerElias Naur <mail@eliasnaur.com>
Thu, 21 Mar 2019 13:04:52 +0000 (13:04 +0000)
While we're here, move the test from dwarf_test.go to link_test.go;
it doesn't have anything to do with DWARF.

Should fix the macOS builders with only the Xcode command line tools
installed.

Change-Id: Iaaba1b589f4d778705f7b627f78c2b12388e2b3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/168462
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/cmd/link/dwarf_test.go
src/cmd/link/link_test.go

index e9c9e293019b6223854ec54cc0854d2cd3d56e27..ecc96019befe07489a6db091306e9341d22a5576 100644 (file)
@@ -171,54 +171,3 @@ func TestDWARFiOS(t *testing.T) {
        testDWARF(t, "c-archive", true, cc, "CGO_ENABLED=1", "GOOS=darwin", "GOARCH=arm", "GOARM=7")
        testDWARF(t, "c-archive", true, cc, "CGO_ENABLED=1", "GOOS=darwin", "GOARCH=arm64")
 }
-
-func TestBuildFortvOS(t *testing.T) {
-       testenv.MustHaveCGO(t)
-       testenv.MustHaveGoBuild(t)
-
-       // Only run this on darwin/amd64, where we can cross build for tvOS.
-       if runtime.GOARCH != "amd64" || runtime.GOOS != "darwin" {
-               t.Skip("skipping on non-darwin/amd64 platform")
-       }
-       if err := exec.Command("xcrun", "--help").Run(); err != nil {
-               t.Skipf("error running xcrun, required for iOS cross build: %v", err)
-       }
-
-       sdkPath, err := exec.Command("xcrun", "--sdk", "appletvos", "--show-sdk-path").Output()
-       if err != nil {
-               t.Fatalf("xcrun --sdk appletvos --show-sdk-path failed: %v", err)
-       }
-       CC := []string{
-               "clang",
-               "-arch",
-               "arm64",
-               "-isysroot", strings.TrimSpace(string(sdkPath)),
-               "-mtvos-version-min=12.0",
-               "-fembed-bitcode",
-               "-framework", "CoreFoundation",
-       }
-       lib := filepath.Join("testdata", "lib.go")
-       tmpDir, err := ioutil.TempDir("", "go-link-TestBuildFortvOS")
-       if err != nil {
-               t.Fatal(err)
-       }
-       defer os.RemoveAll(tmpDir)
-
-       ar := filepath.Join(tmpDir, "lib.a")
-       cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", ar, lib)
-       cmd.Env = append(os.Environ(),
-               "CGO_ENABLED=1",
-               "GOOS=darwin",
-               "GOARCH=arm64",
-               "CC="+strings.Join(CC, " "),
-       )
-       if out, err := cmd.CombinedOutput(); err != nil {
-               t.Fatalf("%v: %v:\n%s", cmd.Args, err, out)
-       }
-
-       link := exec.Command(CC[0], CC[1:]...)
-       link.Args = append(link.Args, ar, filepath.Join("testdata", "main.m"))
-       if out, err := link.CombinedOutput(); err != nil {
-               t.Fatalf("%v: %v:\n%s", link.Args, err, out)
-       }
-}
index bcb3f2f58b809ee1484b9cba83e6fe72ca0262b6..5ecda58707f2a4111ed631080c44aa47a528f673 100644 (file)
@@ -7,6 +7,7 @@ import (
        "os/exec"
        "path/filepath"
        "regexp"
+       "runtime"
        "strings"
        "testing"
 )
@@ -177,3 +178,54 @@ main.x: relocation target main.zero not defined
                t.Fatalf("want:\n%sgot:\n%s", want, got)
        }
 }
+
+func TestBuildFortvOS(t *testing.T) {
+       testenv.MustHaveCGO(t)
+       testenv.MustHaveGoBuild(t)
+
+       // Only run this on darwin/amd64, where we can cross build for tvOS.
+       if runtime.GOARCH != "amd64" || runtime.GOOS != "darwin" {
+               t.Skip("skipping on non-darwin/amd64 platform")
+       }
+       if err := exec.Command("xcrun", "--help").Run(); err != nil {
+               t.Skipf("error running xcrun, required for iOS cross build: %v", err)
+       }
+
+       sdkPath, err := exec.Command("xcrun", "--sdk", "appletvos", "--show-sdk-path").Output()
+       if err != nil {
+               t.Skip("failed to locate appletvos SDK, skipping")
+       }
+       CC := []string{
+               "clang",
+               "-arch",
+               "arm64",
+               "-isysroot", strings.TrimSpace(string(sdkPath)),
+               "-mtvos-version-min=12.0",
+               "-fembed-bitcode",
+               "-framework", "CoreFoundation",
+       }
+       lib := filepath.Join("testdata", "lib.go")
+       tmpDir, err := ioutil.TempDir("", "go-link-TestBuildFortvOS")
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer os.RemoveAll(tmpDir)
+
+       ar := filepath.Join(tmpDir, "lib.a")
+       cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", ar, lib)
+       cmd.Env = append(os.Environ(),
+               "CGO_ENABLED=1",
+               "GOOS=darwin",
+               "GOARCH=arm64",
+               "CC="+strings.Join(CC, " "),
+       )
+       if out, err := cmd.CombinedOutput(); err != nil {
+               t.Fatalf("%v: %v:\n%s", cmd.Args, err, out)
+       }
+
+       link := exec.Command(CC[0], CC[1:]...)
+       link.Args = append(link.Args, ar, filepath.Join("testdata", "main.m"))
+       if out, err := link.CombinedOutput(); err != nil {
+               t.Fatalf("%v: %v:\n%s", link.Args, err, out)
+       }
+}