Merge pull request #1151 from luoliwoshang/internal/build/testdir
internal/build:switch workdir from testpkg like go behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestZoo(t *testing.T) {
|
func TestZoo(t *testing.T) {
|
||||||
if Zoo() != 3 {
|
if Zoo() != 3 {
|
||||||
@@ -11,3 +14,10 @@ func TestZoo(t *testing.T) {
|
|||||||
func TestFalse(t *testing.T) {
|
func TestFalse(t *testing.T) {
|
||||||
// t.Fatal("false")
|
// t.Fatal("false")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSwitchWd(t *testing.T) {
|
||||||
|
_, err := os.Stat("./foo")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -580,6 +580,7 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, global l
|
|||||||
switch mode {
|
switch mode {
|
||||||
case ModeTest:
|
case ModeTest:
|
||||||
cmd := exec.Command(app, conf.RunArgs...)
|
cmd := exec.Command(app, conf.RunArgs...)
|
||||||
|
cmd.Dir = pkg.Dir
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user