aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-12-06 18:09:11 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2017-12-07 15:40:28 +0000
commit44f241be8b905c7f479d2d058a45957220707f28 (patch)
treedaf0aa46169b9fee4a3d9195bc758244ad6cc7f1
parent3d3b8cc47716b9ce3df37b8babe48cfd074cd121 (diff)
downloadgo-44f241be8b905c7f479d2d058a45957220707f28.tar.gz
go-44f241be8b905c7f479d2d058a45957220707f28.zip
cmd/dist: only test SWIG if we have a new enough version
Fixes #22858 Change-Id: I0478d5609e381f01c7345e7f53c24af05d7f78ad Reviewed-on: https://go-review.googlesource.com/82415 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/cmd/dist/test.go59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index f35fbd4cb5..808439439b 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -583,7 +583,7 @@ func (t *tester) registerTests() {
},
})
}
- if swig, _ := exec.LookPath("swig"); swig != "" && goos != "android" {
+ if t.hasSwig() && goos != "android" {
t.tests = append(t.tests, distTest{
name: "swig_stdio",
heading: "../misc/swig/stdio",
@@ -1197,6 +1197,63 @@ func (t *tester) hasBash() bool {
return true
}
+func (t *tester) hasSwig() bool {
+ swig, err := exec.LookPath("swig")
+ if err != nil {
+ return false
+ }
+ out, err := exec.Command(swig, "-version").CombinedOutput()
+ if err != nil {
+ return false
+ }
+
+ re := regexp.MustCompile(`[vV]ersion +([\d]+)([.][\d]+)?([.][\d]+)?`)
+ matches := re.FindSubmatch(out)
+ if matches == nil {
+ // Can't find version number; hope for the best.
+ return true
+ }
+
+ major, err := strconv.Atoi(string(matches[1]))
+ if err != nil {
+ // Can't find version number; hope for the best.
+ return true
+ }
+ if major < 3 {
+ return false
+ }
+ if major > 3 {
+ // 4.0 or later
+ return true
+ }
+
+ // We have SWIG version 3.x.
+ if len(matches[2]) > 0 {
+ minor, err := strconv.Atoi(string(matches[2][1:]))
+ if err != nil {
+ return true
+ }
+ if minor > 0 {
+ // 3.1 or later
+ return true
+ }
+ }
+
+ // We have SWIG version 3.0.x.
+ if len(matches[3]) > 0 {
+ patch, err := strconv.Atoi(string(matches[3][1:]))
+ if err != nil {
+ return true
+ }
+ if patch < 6 {
+ // Before 3.0.6.
+ return false
+ }
+ }
+
+ return true
+}
+
func (t *tester) raceDetectorSupported() bool {
switch gohostos {
case "linux", "darwin", "freebsd", "windows":