diff --git a/examples/vendor/subpackage/subpackage.go b/examples/vendor/subpackage/subpackage.go new file mode 100644 index 00000000..be5b41a7 --- /dev/null +++ b/examples/vendor/subpackage/subpackage.go @@ -0,0 +1,6 @@ +package subpackage + +//Echo just returns your string +func Echo(s string) string { + return s +} diff --git a/examples/vendor/subpackage/subpackage_test.go b/examples/vendor/subpackage/subpackage_test.go new file mode 100644 index 00000000..1da5eaac --- /dev/null +++ b/examples/vendor/subpackage/subpackage_test.go @@ -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) + }) +} diff --git a/goconvey.go b/goconvey.go index 4d5fc0ef..8ee01dd5 100644 --- a/goconvey.go +++ b/goconvey.go @@ -64,7 +64,7 @@ func main() { watcherInput := make(chan messaging.WatcherCommand) watcherOutput := make(chan messaging.Folders) - excludedDirItems := strings.Split(excludedDirs, `,`) + excludedDirItems := checkExcludedDirs(excludedDirs, working) watcher := watch.NewWatcher(working, depth, nap, watcherInput, watcherOutput, watchedSuffixes, excludedDirItems) parser := parser.NewParser(parser.ParsePackageResults) @@ -73,6 +73,7 @@ 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() @@ -80,6 +81,21 @@ func main() { serveHTTP(server) } +//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) + + for _, item := range strings.Split(excludedDirs, `,`) { + if item != dirname { + items = append(items, item) + } + } + + return items +} + func browserCmd() (string, bool) { browser := map[string]string{ "darwin": "open", @@ -112,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) diff --git a/goconvey_test.go b/goconvey_test.go new file mode 100644 index 00000000..f3468356 --- /dev/null +++ b/goconvey_test.go @@ -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() { + for working, excl := range listOfTestExcludedDirs { + excludedDirItems := checkExcludedDirs(excludedDirs, working) + for _, item := range excludedDirItems { + So(item, ShouldNotEqual, excl) + } + } + }) +}