internal/build:switch workdir from testpkg like go behavior

This commit is contained in:
luoliwoshang
2025-06-12 16:40:10 +08:00
parent 26aaa65c1d
commit 48bd1d46af
2 changed files with 12 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
package main
import "testing"
import (
"os"
"testing"
)
func TestZoo(t *testing.T) {
if Zoo() != 3 {
@@ -11,3 +14,10 @@ func TestZoo(t *testing.T) {
func TestFalse(t *testing.T) {
// t.Fatal("false")
}
func TestSwitchWd(t *testing.T) {
_, err := os.Stat("./foo")
if err != nil {
t.Fatal(err)
}
}

View File

@@ -508,6 +508,7 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, conf *Co
switch mode {
case ModeTest:
cmd := exec.Command(app, conf.RunArgs...)
cmd.Dir = pkg.Dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()