mirror of https://github.com/go-python/gopy.git
gopy: fix tests to work with go modules
This commit is contained in:
parent
6fbd665bfb
commit
3b6e67ffd2
15
main_test.go
15
main_test.go
|
@ -805,6 +805,19 @@ func testPkg(t *testing.T, table pkg) {
|
|||
}
|
||||
}
|
||||
|
||||
func writeGoMod(t *testing.T, pkgDir, tstDir string) {
|
||||
template := `
|
||||
module dummy
|
||||
|
||||
require github.com/go-python/gopy v0.0.0
|
||||
replace github.com/go-python/gopy => %s
|
||||
`
|
||||
contents := fmt.Sprintf(template, pkgDir)
|
||||
if err := ioutil.WriteFile(filepath.Join(tstDir, "go.mod"), []byte(contents), 0666); err != nil {
|
||||
t.Fatalf("failed to write go.mod file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testPkgBackend(t *testing.T, pyvm string, table pkg) {
|
||||
curPkgPath := reflect.TypeOf(table).PkgPath()
|
||||
_, pkgNm := filepath.Split(table.path)
|
||||
|
@ -821,6 +834,8 @@ func testPkgBackend(t *testing.T, pyvm string, table pkg) {
|
|||
defer os.RemoveAll(workdir)
|
||||
defer bind.ResetPackages()
|
||||
|
||||
writeGoMod(t, cwd, workdir)
|
||||
|
||||
// fmt.Printf("building in work dir: %s\n", workdir)
|
||||
fpath := "./" + table.path
|
||||
if table.cmd != "build" { // non-build cases end up inside the working dir -- need a global import path
|
||||
|
|
Loading…
Reference in New Issue