+++ /dev/null
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file is just to avoid build errors if there's no cgo.
-
-package swig
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build cgo
-
package swig
import (
- "bytes"
+ "cmd/internal/quoted"
+ "internal/testenv"
"os"
"os/exec"
"path/filepath"
)
func TestStdio(t *testing.T) {
+ testenv.MustHaveCGO(t)
mustHaveSwig(t)
run(t, "testdata/stdio", false)
}
func TestCall(t *testing.T) {
+ testenv.MustHaveCGO(t)
mustHaveSwig(t)
mustHaveCxx(t)
run(t, "testdata/callback", false, "Call")
}
func TestCallback(t *testing.T) {
+ testenv.MustHaveCGO(t)
mustHaveSwig(t)
mustHaveCxx(t)
run(t, "testdata/callback", false, "Callback")
if err != nil {
t.Fatalf("go env CXX failed: %s", err)
}
- cxx = bytes.TrimSuffix(cxx, []byte("\n"))
- // TODO(austin): "go env CXX" can return a quoted list. Use quoted.Split.
- p, err := exec.LookPath(string(cxx))
- if p == "" {
- t.Skipf("test requires C++ compiler, but failed to find %s: %s", string(cxx), err)
+ args, err := quoted.Split(string(cxx))
+ if err != nil {
+ t.Skipf("could not parse 'go env CXX' output %q: %s", string(cxx), err)
+ }
+ if len(args) == 0 {
+ t.Skip("no C++ compiler")
}
+ testenv.MustHaveExecPath(t, string(args[0]))
}
var (
if goos != "android" {
t.registerTest("cgo_testfortran", "", &goTest{dir: "cmd/cgo/internal/testfortran", timeout: 5 * time.Minute}, rtHostTest{})
}
- if goos != "android" {
- t.registerTest("swig", "", &goTest{dir: "../misc/swig"})
- }
}
if t.cgoEnabled {
t.registerCgoTests()