On 2019年06月26日 22:00, Matt Madison wrote: > On Wed, Jun 26, 2019 at 2:02 AM Yu, Mingli wrote: >> >> >> >> On 2019年06月25日 20:23, Matt Madison wrote: >>> On Fri, Jun 21, 2019 at 2:08 AM Yu, Mingli wrote: >>>> >>>> Hi Matt, >>>> >>>> I noticed your commit is the latest update for go-dep ptest. But the >>>> go-dep ptest doesn't work in my environment. I'm trying to figure out >>>> what's wrong is here though I didn't know much about go. >>> >>> I went back over the commits, and I don't think I did anything with >>> go-dep specifically. I can see that the tests are failing for it, and >>> it looks like it's because go-dep's test programs make some >>> assumptions about the environment. For one thing, it needs the go >>> compiler installed. It also looks like it's expecting some source >>> files to be present... in other words, it's not really designed for a >>> cross-build setup, with tests run on the cross-built target. It could >>> be messy to work around that, and I'm not sure how useful it would be >>> anyway, seeing as how go-dep is more of a build tool. Might be better >>> to just disable ptests for it completely. >> >> Many thanks Matt for your information! >> Did you ever run go-dep ptest? >> Go through the run-ptest script for go-dep, it actually runs the >> /usr/lib64/go-dep/ptest/github.com/golang/dep/cmd/dep/dep.test whose >> source file is >> https://github.com/golang/dep/blob/master/cmd/dep/dep_test.go. > > Yes, I see that. That main program starts by rebuilding the dep > program from source, then runs the tests using that copy of the > program, so it's assuming that you're still in a development > environment where you can run a full go build. That's what I meant by > it not being designed for a cross-build setup. > > I've patched the test program to create a symlink to the installed dep > program instead of rebuilding, and got further. You'll need to > include 'go', 'git', and 'git-perltools' in the image to get the tests > to run. Some of the test cases failed until I set GOCACHE in the > environment to point to a valid path; I'm not sure why. The tests > took a long time to run on my qemux86 build, though - at least 30 > minutes. Thanks very much for Matt's guide! I have applied the patch you provide to create a symlink to the installed dep program instead of rebuilding and also add go', 'git', and 'git-perltools' into the image, but there is no PASS case, all failed as attached go-dep_ptest.log. BTW, you said you set GOCACHE, what's the valid path do you mean? Thanks, > > Here's the patch I applied to use the already-built dep binary. An > alternative approach would be to put everything in place to allow the > test program to rebuild the dep binary itself, but that would drive up > the time for the test run even further. > > Regards, > -Matt > > --- > cmd/dep/dep_test.go | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/src/github.com/golang/dep/cmd/dep/dep_test.go > b/src/github.com/golang/dep/cmd/dep/dep_test.go > index 687eef3a..535ca56d 100644 > --- a/src/github.com/golang/dep/cmd/dep/dep_test.go > +++ b/src/github.com/golang/dep/cmd/dep/dep_test.go > @@ -18,13 +18,18 @@ import ( > // deletes it after the tests have been run. > // Most of this is taken from > https://github.com/golang/go/blob/master/src/cmd/go/go_test.go and > reused here. > func TestMain(m *testing.M) { > - args := []string{"build", "-o", "testdep" + test.ExeSuffix} > - out, err := exec.Command("go", args...).CombinedOutput() > + args := []string{"dep"} > + out, err := exec.Command("which", args...).CombinedOutput() > if err != nil { > - fmt.Fprintf(os.Stderr, "building testdep failed: %v\n%s", err, out) > + fmt.Fprintf(os.Stderr, "finding dep failed: %v\n%s", err, out) > + os.Exit(2) > + } > + args = []string{"-s", string(out[:len(out)-1]), "testdep" + test.ExeSuffix} > + out, err = exec.Command("ln", args...).CombinedOutput() > + if err != nil { > + fmt.Fprintf(os.Stderr, "symlinking dep failed: %v\n%s", err, out) > os.Exit(2) > } > - > // Don't let these environment variables confuse the test. > os.Unsetenv("GOPATH") > os.Unsetenv("GIT_ALLOW_PROTOCOL") >