fix #14
This commit is contained in:
parent
13c7b6ba8c
commit
dac858ef07
@ -45,6 +45,11 @@ func (b *Build) MvProjectsToTmp() {
|
||||
} else {
|
||||
b.NewGOPATH = fmt.Sprintf("%v:%v", b.TmpDir, b.OriGOPATH)
|
||||
}
|
||||
// fix #14: unable to build project not in GOPATH in legacy mode
|
||||
// this kind of project does not have a pkg.Root value
|
||||
if b.Root == "" {
|
||||
b.NewGOPATH = b.OriGOPATH
|
||||
}
|
||||
log.Printf("New GOPATH: %v", b.NewGOPATH)
|
||||
return
|
||||
}
|
||||
|
@ -79,3 +79,18 @@ func TestNewDirParseInModProject(t *testing.T) {
|
||||
t.Fatalf("The New GOPATH is wrong. newgopath: %v, tmpdir: %v", b.NewGOPATH, b.TmpDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Test #14
|
||||
func TestLegacyProjectNotInGoPATH(t *testing.T) {
|
||||
workingDir := "../../tests/samples/simple_gopath_project/src/qiniu.com/simple_gopath_project"
|
||||
gopath := ""
|
||||
|
||||
os.Chdir(workingDir)
|
||||
fmt.Println(gopath)
|
||||
os.Setenv("GOPATH", gopath)
|
||||
os.Setenv("GO111MODULE", "off")
|
||||
b := NewBuild("", ".", "")
|
||||
if b.OriGOPATH != b.NewGOPATH {
|
||||
t.Fatalf("New GOPATH should be same with old GOPATH, for this kind of project. New: %v, old: %v", b.NewGOPATH, b.OriGOPATH)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user