aboutsummaryrefslogtreecommitdiff
path: root/test/run.go
diff options
context:
space:
mode:
authorYury Smolsky <yury@smolsky.by>2018-05-30 19:46:59 +0300
committerBrad Fitzpatrick <bradfitz@golang.org>2018-05-31 13:29:50 +0000
commitcaf968616a3ee09d6c820428b4edebb68cfbde09 (patch)
tree77bdaa5ab17c8c8008bbd3e53b43591432b36741 /test/run.go
parentfffb3a5c20b31a8d6916697ebac19ac9e8d3f6e7 (diff)
downloadgo-caf968616a3ee09d6c820428b4edebb68cfbde09.tar.gz
go-caf968616a3ee09d6c820428b4edebb68cfbde09.zip
test: eliminate use of Perl in fixedbugs/bug345.go
To allow testing of fixedbugs/bug345.go in Go, a new flag -n is introduced. This flag disables setting of relative path for local imports and imports search path to current dir, namely -D . -I . are not passed to the compiler. Error regexps are fixed to allow running the test in temp directory. This change eliminates the last place where Perl script "errchk" was used. Fixes #25586. Change-Id: If085f466e6955312d77315f96d3ef1cb68495aef Reviewed-on: https://go-review.googlesource.com/115277 Run-TryBot: Yury Smolsky <yury@smolsky.by> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'test/run.go')
-rw-r--r--test/run.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/run.go b/test/run.go
index 81c0c0b929..0805ecd4fc 100644
--- a/test/run.go
+++ b/test/run.go
@@ -216,8 +216,12 @@ func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, er
return runcmd(cmd...)
}
-func compileInDir(runcmd runCmd, dir string, flags []string, names ...string) (out []byte, err error) {
- cmd := []string{goTool(), "tool", "compile", "-e", "-D", ".", "-I", "."}
+func compileInDir(runcmd runCmd, dir string, flags []string, localImports bool, names ...string) (out []byte, err error) {
+ cmd := []string{goTool(), "tool", "compile", "-e"}
+ if localImports {
+ // Set relative path for local imports and import search path to current dir.
+ cmd = append(cmd, "-D", ".", "-I", ".")
+ }
cmd = append(cmd, flags...)
if *linkshared {
cmd = append(cmd, "-dynlink", "-installsuffix=dynlink")
@@ -489,6 +493,7 @@ func (t *test) run() {
wantError := false
wantAuto := false
singlefilepkgs := false
+ localImports := true
f := strings.Fields(action)
if len(f) > 0 {
action = f[0]
@@ -530,6 +535,12 @@ func (t *test) run() {
wantError = false
case "-s":
singlefilepkgs = true
+ case "-n":
+ // Do not set relative path for local imports to current dir,
+ // e.g. do not pass -D . -I . to the compiler.
+ // Used in fixedbugs/bug345.go to allow compilation and import of local pkg.
+ // See golang.org/issue/25635
+ localImports = false
case "-t": // timeout in seconds
args = args[1:]
var err error
@@ -668,7 +679,7 @@ func (t *test) run() {
return
}
for _, gofiles := range pkgs {
- _, t.err = compileInDir(runcmd, longdir, flags, gofiles...)
+ _, t.err = compileInDir(runcmd, longdir, flags, localImports, gofiles...)
if t.err != nil {
return
}
@@ -690,7 +701,7 @@ func (t *test) run() {
errPkg--
}
for i, gofiles := range pkgs {
- out, err := compileInDir(runcmd, longdir, flags, gofiles...)
+ out, err := compileInDir(runcmd, longdir, flags, localImports, gofiles...)
if i == errPkg {
if wantError && err == nil {
t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
@@ -727,7 +738,7 @@ func (t *test) run() {
return
}
for i, gofiles := range pkgs {
- _, err := compileInDir(runcmd, longdir, flags, gofiles...)
+ _, err := compileInDir(runcmd, longdir, flags, localImports, gofiles...)
// Allow this package compilation fail based on conditions below;
// its errors were checked in previous case.
if err != nil && !(wantError && action == "errorcheckandrundir" && i == len(pkgs)-2) {