Skip to content

Conversation

hectorj
Copy link

@hectorj hectorj commented Apr 21, 2017

To test it, export GOPATH=~/go:/tmp/whatever and go test -v ./generator/. On master it fails :

→ go test -v ./generator/
# gopkg.in/src-d/go-kallax.v1/generator
generator/processor_test.go:12:2: cannot find package "srcd.works/go-parse-utils.v1" in any of:
	/home/hectorj/.local/share/umake/go/go-lang/src/srcd.works/go-parse-utils.v1 (from $GOROOT)
	/home/hectorj/go/src/srcd.works/go-parse-utils.v1 (from $GOPATH)
	/tmp/whatever/src/srcd.works/go-parse-utils.v1
FAIL	gopkg.in/src-d/go-kallax.v1/generator [setup failed]

After this PR it passes

@codecov
Copy link

codecov bot commented Apr 21, 2017

Codecov Report

❗ No coverage uploaded for pull request base (gopath-fix@5e682e4). Click here to learn what that means.
The diff coverage is 69.23%.

Impacted file tree graph

@@              Coverage Diff              @@
##             gopath-fix     #130   +/-   ##
=============================================
  Coverage              ?   80.22%           
=============================================
  Files                 ?       15           
  Lines                 ?     2797           
  Branches              ?        0           
=============================================
  Hits                  ?     2244           
  Misses                ?      378           
  Partials              ?      175
Impacted Files Coverage Δ
generator/template.go 92.37% <100%> (ø)
generator/processor.go 87.96% <63.63%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e682e4...c97b611. Read the comment docs.

@erizocosmico
Copy link
Contributor

erizocosmico commented Apr 21, 2017 via email


func removeGoPath(path string) string {
return strings.Replace(path, goPath+"/src/", "", -1)
for _, goPath := range goPaths {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to use a strings.Replacer (though strings.NewReplacer is not very practical to use in this case)

var goPaths = filepath.SplitList(build.Default.GOPATH)

func getPkgSrcDir(importPath string) (string, error) {
wd, err := os.Getwd()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure that the current working directory is the good thing to pass to build.Import, but it seems to do the job

@erizocosmico erizocosmico changed the base branch from master to gopath-fix April 21, 2017 11:44
@hectorj
Copy link
Author

hectorj commented Apr 25, 2017

I merged the test change from the gopath-fix branch, and now the travis build is failing 🤔

But I can't reproduce that fail on my local...

@erizocosmico
Copy link
Contributor

erizocosmico commented Apr 26, 2017

This approach only works while using go generate because the working directory is the one of the package being generated. But if you run kallax gen by hand this does not work.

EDIT: i think we should fix this in go-parse-utils (though there's still things to fix here even if we do it there).

@erizocosmico
Copy link
Contributor

erizocosmico commented Apr 26, 2017

Closing this in favor of #138.

Thanks for the contribution!

@hectorj
Copy link
Author

hectorj commented Apr 26, 2017

ah, I forgot I had src-d/go-parse-utils#6 on my local, might have been what made my tests pass.

Anyway, #138 looks good 👍

@hectorj hectorj deleted the fix-123 branch April 26, 2017 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants