Commit 44f241be authored by Ian Lance Taylor's avatar Ian Lance Taylor Committed by Brad Fitzpatrick

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: 's avatarAlberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: 's avatarLynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3d3b8cc4
......@@ -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":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment