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

feat: add test.run #599

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -12,8 +12,8 @@ GoConvey is a popular 2-pronged, open-source github project (1,600+ stargazers,
----

- http://goconvey.co/
- https://github.com/smartystreets/goconvey
- https://github.com/smartystreets/goconvey/wiki
- https://github.com/luchuanbing123/goconvey
- https://github.com/luchuanbing123/goconvey/wiki

_I should mention that the [assertions package](https://github.com/smartystreets/assertions) imported by the convey package is used by other projects at SmartyStreets and so we will be continuing to maintain that project internally._

Expand Down
22 changes: 11 additions & 11 deletions README.md
Expand Up @@ -2,7 +2,7 @@ GoConvey is awesome Go testing
==============================

[![Build Status](https://travis-ci.org/smartystreets/goconvey.png)](https://travis-ci.org/smartystreets/goconvey)
[![GoDoc](https://godoc.org/github.com/smartystreets/goconvey?status.svg)](http://godoc.org/github.com/smartystreets/goconvey)
[![GoDoc](https://godoc.org/github.com/luchuanbing123/goconvey?status.svg)](http://godoc.org/github.com/luchuanbing123/goconvey)


Welcome to GoConvey, a yummy Go testing tool for gophers. Works with `go test`. Use it in the terminal or browser according to your viewing pleasure. **[View full feature tour.](http://goconvey.co)**
Expand Down Expand Up @@ -35,9 +35,9 @@ You can ask questions about how to use GoConvey on [StackOverflow](http://stacko
Installation
------------

$ go get github.com/smartystreets/goconvey
$ go get github.com/luchuanbing123/goconvey

[Quick start](https://github.com/smartystreets/goconvey/wiki#get-going-in-25-seconds)
[Quick start](https://github.com/luchuanbing123/goconvey/wiki#get-going-in-25-seconds)
-----------

Make a test, for example:
Expand All @@ -47,7 +47,7 @@ package package_name

import (
"testing"
. "github.com/smartystreets/goconvey/convey"
. "github.com/luchuanbing123/goconvey/convey"
)

func TestSpec(t *testing.T) {
Expand All @@ -68,7 +68,7 @@ func TestSpec(t *testing.T) {
```


#### [In the browser](https://github.com/smartystreets/goconvey/wiki/Web-UI)
#### [In the browser](https://github.com/luchuanbing123/goconvey/wiki/Web-UI)

Start up the GoConvey web server at your project's path:

Expand All @@ -89,11 +89,11 @@ As long as GoConvey is running, test results will automatically update in your b
The design is responsive, so you can squish the browser real tight if you need to put it beside your code.


The [web UI](https://github.com/smartystreets/goconvey/wiki/Web-UI) supports traditional Go tests, so use it even if you're not using GoConvey tests.
The [web UI](https://github.com/luchuanbing123/goconvey/wiki/Web-UI) supports traditional Go tests, so use it even if you're not using GoConvey tests.



#### [In the terminal](https://github.com/smartystreets/goconvey/wiki/Execution)
#### [In the terminal](https://github.com/luchuanbing123/goconvey/wiki/Execution)

Just do what you do best:

Expand All @@ -104,13 +104,13 @@ Or if you want the output to include the story:
$ go test -v


[Documentation](https://github.com/smartystreets/goconvey/wiki)
[Documentation](https://github.com/luchuanbing123/goconvey/wiki)
-----------

Check out the

- [GoConvey wiki](https://github.com/smartystreets/goconvey/wiki),
- [![GoDoc](https://godoc.org/github.com/smartystreets/goconvey?status.png)](http://godoc.org/github.com/smartystreets/goconvey)
- [GoConvey wiki](https://github.com/luchuanbing123/goconvey/wiki),
- [![GoDoc](https://godoc.org/github.com/luchuanbing123/goconvey?status.png)](http://godoc.org/github.com/luchuanbing123/goconvey)
- and the *_test.go files scattered throughout this project.

[Screenshots](http://goconvey.co)
Expand All @@ -121,4 +121,4 @@ For web UI and terminal screenshots, check out [the full feature tour](http://go
Contributors
----------------------

GoConvey is brought to you by [SmartyStreets](https://github.com/smartystreets) and [several contributors](https://github.com/smartystreets/goconvey/graphs/contributors) (Thanks!).
GoConvey is brought to you by [SmartyStreets](https://github.com/smartystreets) and [several contributors](https://github.com/luchuanbing123/goconvey/graphs/contributors) (Thanks!).
2 changes: 1 addition & 1 deletion convey/context.go
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/jtolds/gls"
"github.com/smartystreets/goconvey/convey/reporting"
"github.com/luchuanbing123/goconvey/convey/reporting"
)

type conveyErr struct {
Expand Down
2 changes: 1 addition & 1 deletion convey/convey.goconvey
@@ -1,4 +1,4 @@
#ignore
-timeout=1s
#-covermode=count
#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting
#-coverpkg=github.com/luchuanbing123/goconvey/convey,github.com/luchuanbing123/goconvey/convey/gotest,github.com/luchuanbing123/goconvey/convey/reporting
2 changes: 1 addition & 1 deletion convey/doc.go
Expand Up @@ -3,7 +3,7 @@
// packages from this project as they serve internal purposes.
package convey

import "github.com/smartystreets/goconvey/convey/reporting"
import "github.com/luchuanbing123/goconvey/convey/reporting"

////////////////////////////////// suite //////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion convey/init.go
Expand Up @@ -5,8 +5,8 @@ import (
"os"

"github.com/jtolds/gls"
"github.com/luchuanbing123/goconvey/convey/reporting"
"github.com/smartystreets/assertions"
"github.com/smartystreets/goconvey/convey/reporting"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion convey/nilReporter.go
@@ -1,7 +1,7 @@
package convey

import (
"github.com/smartystreets/goconvey/convey/reporting"
"github.com/luchuanbing123/goconvey/convey/reporting"
)

type nilReporter struct{}
Expand Down
4 changes: 2 additions & 2 deletions convey/reporting/reports.go
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"strings"

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

////////////////// ScopeReport ////////////////////
Expand Down Expand Up @@ -67,7 +67,7 @@ func NewStoryReport(test T) *StoryReport {
return self
}

// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName".
// name comes in looking like "github.com/luchuanbing123/goconvey/examples.TestName".
// We only want the stuff after the last '.', which is the name of the test function.
func removePackagePath(name string) string {
parts := strings.Split(name, ".")
Expand Down
2 changes: 1 addition & 1 deletion convey/reporting_hooks_test.go
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"testing"

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

func TestSingleScopeReported(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/assertion_examples_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

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

func TestAssertionsAreAvailableFromConveyPackage(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/bowling_game_test.go
Expand Up @@ -12,7 +12,7 @@ package examples
import (
"testing"

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

func TestBowlingGameScoring(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_example_test.go
Expand Up @@ -3,7 +3,7 @@ package examples
import (
"testing"

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

func TestIntegerManipulation(t *testing.T) {
Expand Down
8 changes: 6 additions & 2 deletions go.mod
@@ -1,8 +1,12 @@
module github.com/smartystreets/goconvey
module github.com/luchuanbing123/goconvey

go 1.17

require (
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/jtolds/gls v4.20.0+incompatible
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
)

require github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect

18 changes: 10 additions & 8 deletions goconvey.go
Expand Up @@ -19,13 +19,13 @@ import (
"strings"
"time"

"github.com/smartystreets/goconvey/web/server/api"
"github.com/smartystreets/goconvey/web/server/contract"
"github.com/smartystreets/goconvey/web/server/executor"
"github.com/smartystreets/goconvey/web/server/messaging"
"github.com/smartystreets/goconvey/web/server/parser"
"github.com/smartystreets/goconvey/web/server/system"
"github.com/smartystreets/goconvey/web/server/watch"
"github.com/luchuanbing123/goconvey/web/server/api"
"github.com/luchuanbing123/goconvey/web/server/contract"
"github.com/luchuanbing123/goconvey/web/server/executor"
"github.com/luchuanbing123/goconvey/web/server/messaging"
"github.com/luchuanbing123/goconvey/web/server/parser"
"github.com/luchuanbing123/goconvey/web/server/system"
"github.com/luchuanbing123/goconvey/web/server/watch"
)

func init() {
Expand All @@ -45,6 +45,7 @@ func flags() {
flag.StringVar(&excludedDirs, "excludedDirs", "vendor,node_modules", "A comma separated list of directories that will be excluded from being watched.")
flag.StringVar(&workDir, "workDir", "", "set goconvey working directory (default current directory).")
flag.BoolVar(&autoLaunchBrowser, "launchBrowser", true, "toggle auto launching of browser.")
flag.StringVar(&run, "run", "^Test", "same with standard test flag -run regexp")

log.SetOutput(os.Stdout)
log.SetFlags(log.LstdFlags | log.Lshortfile)
Expand Down Expand Up @@ -130,7 +131,7 @@ func extractPackages(folderList messaging.Folders) []*contract.Package {
packageName := resolvePackageName(folder.Path)
packageList = append(
packageList,
contract.NewPackage(folder, packageName, hasImportCycle),
contract.NewPackage(folder, packageName, hasImportCycle, contract.AppendTestArg("-run="+run)),
)
}
return packageList
Expand Down Expand Up @@ -275,6 +276,7 @@ var (
watchedSuffixes string
excludedDirs string
autoLaunchBrowser bool
run string

static string
reports string
Expand Down
4 changes: 2 additions & 2 deletions web/client/index.html
Expand Up @@ -287,7 +287,7 @@
<div class="panic-story">
<div class="panic-file">
{{if File|notempty}}
<a href="goconvey://open/?url=file://{{File|url}}&line={{Line}}">{{File|relativePath}}{{if Line|more>0}}:{{Line}}{{/if}}&nbsp; <i class="fa fa-external-link"></i></a>
<a href="goconvey://open/?url=file://{{PackageName}}&line={{Line}}">{{PackageName}}/{{File|relativePath}}{{if Line|more>0}}:{{Line}}{{/if}}&nbsp; <i class="fa fa-external-link"></i></a>
{{else}}
<b>{{TestName}}</b>
{{/if}}
Expand Down Expand Up @@ -321,7 +321,7 @@
<div class="failure-story">
<div class="failure-file">
{{if File|notempty}}
<a href="goconvey://open/?url=file://{{File|url}}&line={{Line}}">{{File|relativePath}}{{if Line|more>0}}:{{Line}}{{/if}}&nbsp; <i class="fa fa-external-link"></i></a>
<a href="goconvey://open/?url=file://{{PackageName}}/{{File|url}}&line={{Line}}">{{PackageName}}/{{File|relativePath}}{{if Line|more>0}}:{{Line}}{{/if}}&nbsp; <i class="fa fa-external-link"></i></a>
{{else}}
<b class="test-name-link"><a href="#test-{{_id}}">{{TestName}}</a></b>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions web/client/resources/js/composer.js
Expand Up @@ -90,7 +90,7 @@ Mark.pipes.showImports = function(item)
{
console.log(item);
if (root.title === "(root)" && root.stories.length > 0)
return 'import (\n\t"testing"\n\t. "github.com/smartystreets/goconvey/convey"\n)\n';
return 'import (\n\t"testing"\n\t. "github.com/luchuanbing123/goconvey/convey"\n)\n';
else
return "";
}
Expand All @@ -102,7 +102,7 @@ function generate(input)
var root = parseInput(input);
$('#output').text(Mark.up(composer.template, root.stories));
if (root.stories.length > 0 && root.stories[0].title.substr(0, 4) === "Test")
$('#output').prepend('import (\n\t"testing"\n\t. "github.com/smartystreets/goconvey/convey"\n)\n\n');
$('#output').prepend('import (\n\t"testing"\n\t. "github.com/luchuanbing123/goconvey/convey"\n)\n\n');
}

function parseInput(input)
Expand Down
3 changes: 3 additions & 0 deletions web/client/resources/js/goconvey.js
Expand Up @@ -667,6 +667,7 @@ function process(data, status, jqxhr)
test._status = convey.statuses.fail;
pkg._failed++;
test._failed++;
test.PackageName=pkg.PackageName.replaceAll("\\","/")
current().assertions.failed.push(test);
}
else if (test.Skipped)
Expand Down Expand Up @@ -1318,9 +1319,11 @@ function customMarkupPipes()
// MARKUP.JS custom pipes
Mark.pipes.relativePath = function(str)
{
console.log("str:",str)
basePath = new RegExp($('#path').val()+'[\\/]', 'gi');
return str.replace(basePath, '');
};

Mark.pipes.htmlSafe = function(str)
{
return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
Expand Down
4 changes: 2 additions & 2 deletions web/server/api/server.go
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"
"time"

"github.com/smartystreets/goconvey/web/server/contract"
"github.com/smartystreets/goconvey/web/server/messaging"
"github.com/luchuanbing123/goconvey/web/server/contract"
"github.com/luchuanbing123/goconvey/web/server/messaging"
)

type HTTPServer struct {
Expand Down
6 changes: 3 additions & 3 deletions web/server/api/server_test.go
Expand Up @@ -10,9 +10,9 @@ import (
"testing"
"time"

. "github.com/smartystreets/goconvey/convey"
"github.com/smartystreets/goconvey/web/server/contract"
"github.com/smartystreets/goconvey/web/server/messaging"
. "github.com/luchuanbing123/goconvey/convey"
"github.com/luchuanbing123/goconvey/web/server/contract"
"github.com/luchuanbing123/goconvey/web/server/messaging"
)

const initialRoot = "/root/gopath/src/github.com/smartystreets/project"
Expand Down
17 changes: 14 additions & 3 deletions web/server/contract/result.go
@@ -1,8 +1,8 @@
package contract

import (
"github.com/smartystreets/goconvey/convey/reporting"
"github.com/smartystreets/goconvey/web/server/messaging"
"github.com/luchuanbing123/goconvey/convey/reporting"
"github.com/luchuanbing123/goconvey/web/server/messaging"
)

type Package struct {
Expand All @@ -19,7 +19,15 @@ type Package struct {
HasImportCycle bool
}

func NewPackage(folder *messaging.Folder, name string, hasImportCycle bool) *Package {
type PackageOption func(p *Package)

func AppendTestArg(a string) PackageOption {
return func(p *Package) {
p.TestArguments = append(p.TestArguments, a)
}
}

func NewPackage(folder *messaging.Folder, name string, hasImportCycle bool, opts ...PackageOption) *Package {
self := new(Package)
self.Path = folder.Path
self.Name = name
Expand All @@ -29,6 +37,9 @@ func NewPackage(folder *messaging.Folder, name string, hasImportCycle bool) *Pac
self.BuildTags = folder.BuildTags
self.TestArguments = folder.TestArguments
self.HasImportCycle = hasImportCycle
for _, opt := range opts {
opt(self)
}
return self
}

Expand Down
2 changes: 1 addition & 1 deletion web/server/executor/contract.go
@@ -1,6 +1,6 @@
package executor

import "github.com/smartystreets/goconvey/web/server/contract"
import "github.com/luchuanbing123/goconvey/web/server/contract"

type Parser interface {
Parse([]*contract.Package)
Expand Down
2 changes: 1 addition & 1 deletion web/server/executor/coordinator.go
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

"github.com/smartystreets/goconvey/web/server/contract"
"github.com/luchuanbing123/goconvey/web/server/contract"
)

type concurrentCoordinator struct {
Expand Down
2 changes: 1 addition & 1 deletion web/server/executor/executor.go
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"time"

"github.com/smartystreets/goconvey/web/server/contract"
"github.com/luchuanbing123/goconvey/web/server/contract"
)

const (
Expand Down