Commit 8476fd7b authored by Ian Lance Taylor's avatar Ian Lance Taylor

go/internal/gccgoimporter: fix test when using gccgo before GCC 7

In TestObjImporter skip tests that use type aliases when using a
version of gccgo before GCC 7, since that is when type aliases were
added.

Fixes #29006

Change-Id: I676bae9f023931cf95ac9b4d4de893fe8517af9b
Reviewed-on: https://go-review.googlesource.com/c/152078Reviewed-by: default avatarThan McIntosh <thanm@google.com>
parent 3ce9e5a1
...@@ -11,6 +11,8 @@ import ( ...@@ -11,6 +11,8 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"regexp"
"strconv"
"testing" "testing"
) )
...@@ -120,6 +122,25 @@ func TestObjImporter(t *testing.T) { ...@@ -120,6 +122,25 @@ func TestObjImporter(t *testing.T) {
t.Skip("This test needs gccgo") t.Skip("This test needs gccgo")
} }
verout, err := exec.Command(gpath, "--version").CombinedOutput()
if err != nil {
t.Logf("%s", verout)
t.Fatal(err)
}
vers := regexp.MustCompile(`([0-9]+)\.([0-9]+)`).FindSubmatch(verout)
if len(vers) == 0 {
t.Fatalf("could not find version number in %s", verout)
}
major, err := strconv.Atoi(string(vers[1]))
if err != nil {
t.Fatal(err)
}
minor, err := strconv.Atoi(string(vers[2]))
if err != nil {
t.Fatal(err)
}
t.Logf("gccgo version %d.%d", major, minor)
tmpdir, err := ioutil.TempDir("", "") tmpdir, err := ioutil.TempDir("", "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -135,6 +156,14 @@ func TestObjImporter(t *testing.T) { ...@@ -135,6 +156,14 @@ func TestObjImporter(t *testing.T) {
arimp := GetImporter([]string{artmpdir}, arinitmap) arimp := GetImporter([]string{artmpdir}, arinitmap)
for _, test := range importerTests { for _, test := range importerTests {
// Support for type aliases was added in GCC 7.
if test.pkgpath == "aliases" || test.pkgpath == "issue27856" {
if major < 7 {
t.Logf("skipping %q: not supported before gccgo version 7", test.pkgpath)
continue
}
}
gofile := filepath.Join("testdata", test.pkgpath+".go") gofile := filepath.Join("testdata", test.pkgpath+".go")
if _, err := os.Stat(gofile); os.IsNotExist(err) { if _, err := os.Stat(gofile); os.IsNotExist(err) {
continue continue
......
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