misc/swig: move tests to cmd/cgo/internal

This moves the misc/swig test to cmd/cgo/internal.

This lets these tests access facilities in internal/testenv. It's also
now just a normal test that can run as part of the cmd tests.

For #37486.

Change-Id: Ibe5026219999d175aa0a310b9886bef3f6f9ed17
Reviewed-on: https://go-review.googlesource.com/c/go/+/492722
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Austin Clements 2023-05-04 12:13:27 -04:00
parent 2484e1331a
commit 0efbec91cd
9 changed files with 12 additions and 18 deletions

View File

@ -1,7 +0,0 @@
// 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

View File

@ -2,12 +2,11 @@
// 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"
@ -19,11 +18,13 @@ import (
)
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")
@ -31,6 +32,7 @@ func TestCall(t *testing.T) {
}
func TestCallback(t *testing.T) {
testenv.MustHaveCGO(t)
mustHaveSwig(t)
mustHaveCxx(t)
run(t, "testdata/callback", false, "Callback")
@ -63,12 +65,14 @@ func mustHaveCxx(t *testing.T) {
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 (

View File

@ -870,9 +870,6 @@ func (t *tester) registerTests() {
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()