numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run")
summary = flag.Bool("summary", false, "show summary of results")
showSkips = flag.Bool("show_skips", false, "show skipped tests")
+ linkshared = flag.Bool("linkshared", false, "")
updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output")
runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run")
type runCmd func(...string) ([]byte, error)
func compileFile(runcmd runCmd, longname string) (out []byte, err error) {
- return runcmd("go", "tool", "compile", "-e", longname)
+ cmd := []string{"go", "tool", "compile", "-e"}
+ if *linkshared {
+ cmd = append(cmd, "-dynlink", "-installsuffix=dynlink")
+ }
+ cmd = append(cmd, longname)
+ return runcmd(cmd...)
}
func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err error) {
cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", "."}
+ if *linkshared {
+ cmd = append(cmd, "-dynlink", "-installsuffix=dynlink")
+ }
for _, name := range names {
cmd = append(cmd, filepath.Join(dir, name))
}
func linkFile(runcmd runCmd, goname string) (err error) {
pfile := strings.Replace(goname, ".go", ".o", -1)
- _, err = runcmd("go", "tool", "link", "-w", "-o", "a.exe", "-L", ".", pfile)
+ cmd := []string{"go", "tool", "link", "-w", "-o", "a.exe", "-L", "."}
+ if *linkshared {
+ cmd = append(cmd, "-linkshared", "-installsuffix=dynlink")
+ }
+ cmd = append(cmd, pfile)
+ _, err = runcmd(cmd...)
return
}
case "errorcheck":
cmdline := []string{"go", "tool", "compile", "-e", "-o", "a.o"}
+ // No need to add -dynlink even if linkshared if we're just checking for errors...
cmdline = append(cmdline, flags...)
cmdline = append(cmdline, long)
out, err := runcmd(cmdline...)
case "run":
useTmp = false
- out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
+ cmd := []string{"go", "run"}
+ if *linkshared {
+ cmd = append(cmd, "-linkshared")
+ }
+ cmd = append(cmd, t.goFileName())
+ out, err := runcmd(append(cmd, args...)...)
if err != nil {
t.err = err
return
<-rungatec
}()
useTmp = false
- out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
+ cmd := []string{"go", "run"}
+ if *linkshared {
+ cmd = append(cmd, "-linkshared")
+ }
+ cmd = append(cmd, t.goFileName())
+ out, err := runcmd(append(cmd, args...)...)
if err != nil {
t.err = err
return
t.err = fmt.Errorf("write tempfile:%s", err)
return
}
- out, err = runcmd("go", "run", tfile)
+ cmd = []string{"go", "run"}
+ if *linkshared {
+ cmd = append(cmd, "-linkshared")
+ }
+ cmd = append(cmd, tfile)
+ out, err = runcmd(cmd...)
if err != nil {
t.err = err
return
case "errorcheckoutput":
useTmp = false
- out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
+ cmd := []string{"go", "run"}
+ if *linkshared {
+ cmd = append(cmd, "-linkshared")
+ }
+ cmd = append(cmd, t.goFileName())
+ out, err := runcmd(append(cmd, args...)...)
if err != nil {
t.err = err
return