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

Failed to compile <package>: output file "<test binary>" could not be found #427

Closed
Bo0mer opened this issue Feb 8, 2018 · 3 comments · May be fixed by #570
Closed

Failed to compile <package>: output file "<test binary>" could not be found #427

Bo0mer opened this issue Feb 8, 2018 · 3 comments · May be fixed by #570
Labels
v2 Issues that will be resolved by v2

Comments

@Bo0mer
Copy link

Bo0mer commented Feb 8, 2018

My environment

I'm running using ginkgo 747514b.
Go version is go version go1.9.2 darwin/amd64
Go env:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/borshukov/workspace/Go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kj/ywpvnhgj1pbfyz61h8lvvbgm0000gn/T/go-build470251122=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What I'm trying to do

Run the following commands:

go get -u github.com/Bo0mer/ginko-failure-example/...
cd $GOPATH/src/github.com/Bo0mer/ginko-failure-example
ginkgo -r

What I expect to see

No failure as there are no test cases.

What I see instead

$ ginkgo -r
?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

Failed to compile integration: output file "/var/folders/kj/ywpvnhgj1pbfyz61h8lvvbgm0000gn/T/ginkgo823659099/integration.test" could not be found
Ginkgo ran 1 suite in 720.425249ms
Test Suite Failed

I've tested the same sequence of commands, but using go test instead of ginkgo -r, and it works just fine:

$ go test ./...
?   	github.com/Bo0mer/ginko-failure-example/integration	[no test files]

I have not looked at ginkgo`s source code in order to troubleshoot the problem. I plan to do so tomorrow.

Thanks for your awesome work!
Ivan

@Bo0mer Bo0mer changed the title Failed to compile integration: output file "<test binary>" could not be found Failed to compile <package>: output file "<test binary>" could not be found Feb 8, 2018
@Bo0mer
Copy link
Author

Bo0mer commented Feb 9, 2018

Hello,

The problem seems that ginkgo does not check whether there are any test files that could be compiled into a test binary. Applying the following diff resolves the problem:

diff --git a/ginkgo/testrunner/test_runner.go b/ginkgo/testrunner/test_runner.go
index e129136..7bbea4a 100644
--- a/ginkgo/testrunner/test_runner.go
+++ b/ginkgo/testrunner/test_runner.go
@@ -23,6 +23,7 @@ import (
 type TestRunner struct {
 	Suite testsuite.TestSuite
 
+	noTestFiles           bool
 	compiled              bool
 	compilationTargetPath string
 
@@ -151,6 +152,11 @@ func (t *TestRunner) CompileTo(path string) error {
 		fmt.Println(string(output))
 	}
 
+	if bytes.Contains(output, []byte("[no test files]")) {
+		t.noTestFiles = true
+		return nil
+	}
+
 	if fileExists(path) == false {
 		compiledFile := t.Suite.PackageName + ".test"
 		if fileExists(compiledFile) {
@@ -224,6 +230,9 @@ func copyFile(src, dst string) error {
 }
 
 func (t *TestRunner) Run() RunResult {
+	if t.noTestFiles {
+		return PassingRunResult()
+	}
 	if t.Suite.IsGinkgo {
 		if t.numCPU > 1 {
 			if t.parallelStream {

Let me know if any more debugging is needed on my side. If you're OK with the proposed change, I'd be happy to send a PR.

Cheers,
Ivan

@saschagrunert
Copy link
Contributor

Hey, I run into the same issue and prepared your changes as a fix. Bear with me! 🙏

@onsi
Copy link
Owner

onsi commented Apr 6, 2021

I'm working through the backlog of old Ginkgo issues - apologies as this issue is probably stale now. I've added this to the v2 backlog.

@onsi onsi added v2 Issues that will be resolved by v2 and removed needs-review labels Apr 6, 2021
@onsi onsi closed this as completed in 6475d9a Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Issues that will be resolved by v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants