e2e log: fix full stacktrace with Ginkgo 1.10.0

Ginkgo 1.10.0 includes the relevant fix for dumping the full stack
(https://github.com/onsi/ginkgo/pull/590), so when using that release
we can simplify the logging unit test.

By changing the skipping, we can avoid the rather volatile util.go
entries. However, that gomega is part of the stack trace still needs
to be fixed in Gingko.
This commit is contained in:
Patrick Ohly
2019-08-27 14:22:46 +02:00
parent 5219ad7be2
commit 02ce619078
52 changed files with 176 additions and 114 deletions

View File

@@ -131,10 +131,7 @@ func determinePackageName(name string, internal bool) string {
func fileExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
return false
return err == nil
}
func generateBootstrap(agouti, noDot, internal bool, customBootstrapFile string) {

View File

@@ -1,7 +1,6 @@
package convert
import (
"errors"
"fmt"
"go/ast"
)
@@ -24,7 +23,7 @@ func importsForRootNode(rootNode *ast.File) (imports *ast.GenDecl, err error) {
}
}
err = errors.New(fmt.Sprintf("Could not find imports for root node:\n\t%#v\n", rootNode))
err = fmt.Errorf("Could not find imports for root node:\n\t%#v\n", rootNode)
return
}

View File

@@ -24,7 +24,6 @@ func RewritePackage(packageName string) {
for _, filename := range findTestsInPackage(pkg) {
rewriteTestsInFile(filename)
}
return
}
/*

View File

@@ -61,7 +61,6 @@ func rewriteTestsInFile(pathToFile string) {
}
ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode())
return
}
/*
@@ -88,7 +87,6 @@ func rewriteTestFuncAsItStatement(testFunc *ast.FuncDecl, rootNode *ast.File, de
// remove the old test func from the root node's declarations
rootNode.Decls = append(rootNode.Decls[:funcIndex], rootNode.Decls[funcIndex+1:]...)
return
}
/*

View File

@@ -16,7 +16,7 @@ type InterruptHandler struct {
func NewInterruptHandler() *InterruptHandler {
h := &InterruptHandler{
lock: &sync.Mutex{},
C: make(chan bool, 0),
C: make(chan bool),
}
go h.handleInterrupt()

View File

@@ -153,6 +153,7 @@ func (c *Command) Matches(name string) bool {
}
func (c *Command) Run(args []string, additionalArgs []string) {
c.FlagSet.Usage = usage
c.FlagSet.Parse(args)
c.Command(c.FlagSet.Args(), additionalArgs)
}
@@ -215,20 +216,21 @@ func commandMatching(name string) (*Command, bool) {
}
func usage() {
fmt.Fprintf(os.Stderr, "Ginkgo Version %s\n\n", config.VERSION)
fmt.Printf("Ginkgo Version %s\n\n", config.VERSION)
usageForCommand(DefaultCommand, false)
for _, command := range Commands {
fmt.Fprintf(os.Stderr, "\n")
fmt.Printf("\n")
usageForCommand(command, false)
}
}
func usageForCommand(command *Command, longForm bool) {
fmt.Fprintf(os.Stderr, "%s\n%s\n", command.UsageCommand, strings.Repeat("-", len(command.UsageCommand)))
fmt.Fprintf(os.Stderr, "%s\n", strings.Join(command.Usage, "\n"))
fmt.Printf("%s\n%s\n", command.UsageCommand, strings.Repeat("-", len(command.UsageCommand)))
fmt.Printf("%s\n", strings.Join(command.Usage, "\n"))
if command.SuppressFlagDocumentation && !longForm {
fmt.Fprintf(os.Stderr, "%s\n", strings.Join(command.FlagDocSubstitute, "\n "))
fmt.Printf("%s\n", strings.Join(command.FlagDocSubstitute, "\n "))
} else {
command.FlagSet.SetOutput(os.Stdout)
command.FlagSet.PrintDefaults()
}
}

View File

@@ -41,7 +41,7 @@ func (r *SuiteRunner) compileInParallel(runners []*testrunner.TestRunner, numCom
//an array of channels - the nth runner's compilation output is sent to the nth channel in this array
//we read from these channels in order to ensure we run the suites in order
orderedCompilationOutputs := []chan compilationOutput{}
for _ = range runners {
for range runners {
orderedCompilationOutputs = append(orderedCompilationOutputs, make(chan compilationOutput, 1))
}

View File

@@ -156,7 +156,7 @@ func (t *TestRunner) CompileTo(path string) error {
fmt.Println(string(output))
}
if fileExists(path) == false {
if !fileExists(path) {
compiledFile := t.Suite.PackageName + ".test"
if fileExists(compiledFile) {
// seems like we are on an old go version that does not support the -o flag on go test
@@ -182,7 +182,7 @@ func (t *TestRunner) CompileTo(path string) error {
func fileExists(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsNotExist(err) == false
return err == nil || !os.IsNotExist(err)
}
// copyFile copies the contents of the file named src to the file named
@@ -523,7 +523,7 @@ func (t *TestRunner) combineCoverprofiles() {
lines := map[string]int{}
lineOrder := []string{}
for i, coverProfile := range profiles {
for _, line := range strings.Split(string(coverProfile), "\n")[1:] {
for _, line := range strings.Split(coverProfile, "\n")[1:] {
if len(line) == 0 {
continue
}

View File

@@ -77,7 +77,7 @@ func (d Dependencies) resolveAndAdd(deps []string, depth int) {
if err != nil {
continue
}
if pkg.Goroot == false && !ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) {
if !pkg.Goroot && !ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) {
d.addDepIfNotPresent(pkg.Dir, depth)
}
}

View File

@@ -36,7 +36,7 @@ func (p *PackageHash) CheckForChanges() bool {
codeHash, codeModifiedTime, testHash, testModifiedTime, deleted := p.computeHashes()
if deleted {
if p.Deleted == false {
if !p.Deleted {
t := time.Now()
p.CodeModifiedTime = t
p.TestModifiedTime = t