Skip to content

Commit

Permalink
fix: go test no longer relies on environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmueller committed Dec 14, 2017
1 parent f4d7fd7 commit 4e548d8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
23 changes: 21 additions & 2 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"strings"
"testing"

"github.com/matthewmueller/joy/internal/paths"

"github.com/sanity-io/litter"
"github.com/sergi/go-diff/diffmatchpatch"

Expand Down Expand Up @@ -44,10 +46,25 @@ func Test(t *testing.T) {
t.Fatal(e)
}

gosrc := path.Join(os.Getenv("GOPATH"), "src")
root, err := paths.Joy()
if err != nil {
t.Fatal(err)
}

exists:
chromePath, err := chrome.Exists(path.Join(root, "chrome"))
if err != nil {
t.Fatal(err)
} else if chromePath == "" {
log.Infof("downloading headless chrome (this only needs to be done once)")
if err := chrome.Download(path.Join(root, "chrome")); err != nil {
t.Fatal(err)
}
goto exists
}

ch, err := chrome.New(ctx, &chrome.Settings{
ExecutablePath: os.Getenv("GOLLY_CHROME_PATH"),
ExecutablePath: chromePath,
Stderr: ioutil.Discard,
Stdout: ioutil.Discard,
})
Expand All @@ -56,6 +73,8 @@ func Test(t *testing.T) {
}
defer ch.Close()

gosrc := path.Join(os.Getenv("GOPATH"), "src")

for _, dir := range dirs {
if !dir.IsDir() {
continue
Expand Down
9 changes: 7 additions & 2 deletions internal/compiler/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ func New(program *loader.Program) (idx *index.Index, err error) {
}

for _, info := range program.AllPackages {
pkgpath := info.Pkg.Path()
// ignore the joy/macro package path when indexing
// TODO: is this going to work in every case?
if info.Pkg.Path() == "./macro" {
// TODO: this is a HUGE HACK and should be eliminated
// altogether. It shouldn't matter whether we include macro
// in the index, but right now index.DefinitionOf will return
// macro.File rather than the underlying type so rewrites
// currently get messed up
if pkgpath == "./macro" || strings.HasSuffix(pkgpath, "joy/macro") {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion internal/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Joy() (string, error) {
}

// short-circuit for testing
return getPath("joy")
// return getPath("joy")

root := path.Join(file, "..", "..", "..")
if _, err := os.Stat(root); !os.IsNotExist(err) {
Expand Down
1 change: 1 addition & 0 deletions macro/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
master
1 change: 1 addition & 0 deletions stdlib/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
master

0 comments on commit 4e548d8

Please sign in to comment.