mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
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:
parent
2484e1331a
commit
0efbec91cd
@ -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
|
|
@ -2,12 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build cgo
|
|
||||||
|
|
||||||
package swig
|
package swig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"cmd/internal/quoted"
|
||||||
|
"internal/testenv"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -19,11 +18,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStdio(t *testing.T) {
|
func TestStdio(t *testing.T) {
|
||||||
|
testenv.MustHaveCGO(t)
|
||||||
mustHaveSwig(t)
|
mustHaveSwig(t)
|
||||||
run(t, "testdata/stdio", false)
|
run(t, "testdata/stdio", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCall(t *testing.T) {
|
func TestCall(t *testing.T) {
|
||||||
|
testenv.MustHaveCGO(t)
|
||||||
mustHaveSwig(t)
|
mustHaveSwig(t)
|
||||||
mustHaveCxx(t)
|
mustHaveCxx(t)
|
||||||
run(t, "testdata/callback", false, "Call")
|
run(t, "testdata/callback", false, "Call")
|
||||||
@ -31,6 +32,7 @@ func TestCall(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallback(t *testing.T) {
|
func TestCallback(t *testing.T) {
|
||||||
|
testenv.MustHaveCGO(t)
|
||||||
mustHaveSwig(t)
|
mustHaveSwig(t)
|
||||||
mustHaveCxx(t)
|
mustHaveCxx(t)
|
||||||
run(t, "testdata/callback", false, "Callback")
|
run(t, "testdata/callback", false, "Callback")
|
||||||
@ -63,12 +65,14 @@ func mustHaveCxx(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("go env CXX failed: %s", err)
|
t.Fatalf("go env CXX failed: %s", err)
|
||||||
}
|
}
|
||||||
cxx = bytes.TrimSuffix(cxx, []byte("\n"))
|
args, err := quoted.Split(string(cxx))
|
||||||
// TODO(austin): "go env CXX" can return a quoted list. Use quoted.Split.
|
if err != nil {
|
||||||
p, err := exec.LookPath(string(cxx))
|
t.Skipf("could not parse 'go env CXX' output %q: %s", string(cxx), err)
|
||||||
if p == "" {
|
|
||||||
t.Skipf("test requires C++ compiler, but failed to find %s: %s", string(cxx), err)
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
t.Skip("no C++ compiler")
|
||||||
|
}
|
||||||
|
testenv.MustHaveExecPath(t, string(args[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
3
src/cmd/dist/test.go
vendored
3
src/cmd/dist/test.go
vendored
@ -870,9 +870,6 @@ func (t *tester) registerTests() {
|
|||||||
if goos != "android" {
|
if goos != "android" {
|
||||||
t.registerTest("cgo_testfortran", "", &goTest{dir: "cmd/cgo/internal/testfortran", timeout: 5 * time.Minute}, rtHostTest{})
|
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 {
|
if t.cgoEnabled {
|
||||||
t.registerCgoTests()
|
t.registerCgoTests()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user