diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc831d15..4568db789 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## HEAD - `ginkgo` now provides a hint if you accidentally forget to run `ginkgo bootstrap` to generate a `*_suite_test.go` file that actually invokes the Ginkgo test runner. [#345](https://github.com/onsi/ginkgo/pull/345) +- thanks to improvements in `go test -c` `ginkgo` no longer needs to fix Go's compilation output to ensure compilation errors are expressed relative to the CWD. [#357] ## 1.3.0 3/28/2017 diff --git a/ginkgo/testrunner/test_runner.go b/ginkgo/testrunner/test_runner.go index 923fbc63a..e3c4a8d4d 100644 --- a/ginkgo/testrunner/test_runner.go +++ b/ginkgo/testrunner/test_runner.go @@ -8,7 +8,6 @@ import ( "os" "os/exec" "path/filepath" - "regexp" "strconv" "strings" "syscall" @@ -138,9 +137,8 @@ func (t *TestRunner) CompileTo(path string) error { output, err := cmd.CombinedOutput() if err != nil { - fixedOutput := fixCompilationOutput(string(output), t.Suite.Path) if len(output) > 0 { - return fmt.Errorf("Failed to compile %s:\n\n%s", t.Suite.PackageName, fixedOutput) + return fmt.Errorf("Failed to compile %s:\n\n%s", t.Suite.PackageName, output) } return fmt.Errorf("Failed to compile %s", t.Suite.PackageName) } @@ -217,38 +215,6 @@ func copyFile(src, dst string) error { return out.Chmod(mode) } -/* -go test -c -i spits package.test out into the cwd. there's no way to change this. - -to make sure it doesn't generate conflicting .test files in the cwd, Compile() must switch the cwd to the test package. - -unfortunately, this causes go test's compile output to be expressed *relative to the test package* instead of the cwd. - -this makes it hard to reason about what failed, and also prevents iterm's Cmd+click from working. - -fixCompilationOutput..... rewrites the output to fix the paths. - -yeah...... -*/ -func fixCompilationOutput(output string, relToPath string) string { - relToPath = filepath.Join(relToPath) - re := regexp.MustCompile(`^(\S.*\.go)\:\d+\:`) - lines := strings.Split(output, "\n") - for i, line := range lines { - indices := re.FindStringSubmatchIndex(line) - if len(indices) == 0 { - continue - } - - path := line[indices[2]:indices[3]] - if filepath.Dir(path) != relToPath { - path = filepath.Join(relToPath, path) - lines[i] = path + line[indices[3]:] - } - } - return strings.Join(lines, "\n") -} - func (t *TestRunner) Run() RunResult { if t.Suite.IsGinkgo { if t.numCPU > 1 {