Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash for excludedDirs #401

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/vendor/subpackage/subpackage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package subpackage

//Echo just returns your string
func Echo(s string) string {
return s
}
14 changes: 14 additions & 0 deletions examples/vendor/subpackage/subpackage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package subpackage

import (
"testing"

. "github.com/smartystreets/goconvey/convey"
)

func TestEcho(t *testing.T) {
s := "Hello"
Convey("Test Echo", t, func() {
So(Echo(s), ShouldEqual, s)
})
}
12 changes: 11 additions & 1 deletion goconvey.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ func main() {

longpollChan := make(chan chan string)
executor := executor.NewExecutor(tester, parser, longpollChan)

server := api.NewHTTPServer(working, watcherInput, executor, longpollChan)
go runTestOnUpdates(watcherOutput, executor, server)
go watcher.Listen()
go launchBrowser(host, port)
serveHTTP(server)
}

func checkExcludedDirs(s string, working string) []string {
//checkExcludedDirs checks whether the working directory is contained in the list of excluded
//if is, then drop it from the excludedDirs
func checkExcludedDirs(excludedDirs string, working string) []string {
var items []string
dirname := filepath.Base(working)

Expand Down Expand Up @@ -125,6 +128,13 @@ func runTestOnUpdates(queue chan messaging.Folders, executor contract.Executor,
for update := range queue {
log.Println("Received request from watcher to execute tests...")
packages := extractPackages(update)

//if extractPackages does not return packages
if len(packages) == 0 {
log.Println("Nothing to test, check the working directory")
continue
}

output := executor.ExecuteTests(packages)
root := extractRoot(update, packages)
server.ReceiveUpdate(root, output)
Expand Down
25 changes: 25 additions & 0 deletions goconvey_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"testing"

. "github.com/smartystreets/goconvey/convey"
)

func TestCheckExcludedDirs(t *testing.T) {
listOfTestExcludedDirs := map[string]string{
"/go/src/package/vendor": "vendor",
"/go/src/package/vendor/": "vendor",
"/go/src/package/node_modules": "node_modules",
"/go/src/package/node_modules/": "node_modules",
}

Convey("Exclude excluded directory for fake pathes", t, func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

`+ Convey("Exclude excluded directory for fake pathes paths", t, func() {

for working, excl := range listOfTestExcludedDirs {
excludedDirItems := checkExcludedDirs(excludedDirs, working)
for _, item := range excludedDirItems {
So(item, ShouldNotEqual, excl)
}
}
})
}