mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
fffb3a5c20
commit
caf968616a
3 changed files with 23 additions and 50 deletions
|
|
@ -1,47 +1,8 @@
|
|||
// +build !nacl,!js,!plan9,!windows
|
||||
// run
|
||||
// errorcheckdir -n
|
||||
|
||||
// run
|
||||
// Copyright 2011 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.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// TODO: If we get rid of errchk, re-enable this test on Plan 9 and Windows.
|
||||
errchk, err := filepath.Abs("errchk")
|
||||
check(err)
|
||||
|
||||
bugDir := filepath.Join(".", "fixedbugs", "bug345.dir")
|
||||
run("go", "tool", "compile", filepath.Join(bugDir, "io.go"))
|
||||
run(errchk, "go", "tool", "compile", "-e", filepath.Join(bugDir, "main.go"))
|
||||
|
||||
os.Remove("io.o")
|
||||
}
|
||||
|
||||
var bugRE = regexp.MustCompile(`(?m)^BUG`)
|
||||
|
||||
func run(name string, args ...string) {
|
||||
cmd := exec.Command(name, args...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if bugRE.Match(out) || err != nil {
|
||||
fmt.Println(string(out))
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func check(err error) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
package ignored
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue