constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 150 forks source link

Packages ignored when testing #702

Open jeromer opened 7 years ago

jeromer commented 7 years ago

My project looks like this:

➜  project.v2 git:(api/v2.0) ✗ tree ./src 
./src
├── api
│   ├── env.go
│   ├── handler.go
│   ├── handler_test.go
│   ├── main.go
│   ├── response.go
│   ├── response_test.go
│   └── router.go
[...]
├── passwd
│   ├── passwd.go
│   └── passwd_test.go

Even though there are tests in src/api/ gb seems to completely ignore them

➜  project.v2 git:(api/v2.0) ✗ gb test -tags project_api_test -v passwd
passwd
=== RUN   TestPasswdTestSuite
=== RUN   TestHashValidate
--- PASS: TestHashValidate (5.57s)
--- PASS: TestPasswdTestSuite (5.57s)
PASS
➜  project.v2 git:(api/v2.0) ✗ gb test -tags project_api_test -v passwd api
passwd
=== RUN   TestPasswdTestSuite
=== RUN   TestHashValidate
--- PASS: TestHashValidate (5.71s)
--- PASS: TestPasswdTestSuite (5.71s)
PASS
➜  project.v2 git:(api/v2.0) ✗ gb test -tags project_api_test -v api       
FATAL: command "test" failed: no test packages provided
➜  project.v2 git:(api/v2.0) ✗ gb test -tags project_api_test -v api passwd
passwd
=== RUN   TestPasswdTestSuite
=== RUN   TestHashValidate
--- PASS: TestHashValidate (5.55s)
--- PASS: TestPasswdTestSuite (5.55s)
PASS

I use gb d4ba64b0b29760e90322851fb793b04665b0c3c9

jeromer commented 7 years ago

I found why.

There was a bad import in one of my go files which for some unknown reason was not reported by gb.

This import ultimately triggers this error which is not displayed.

Do you think you could at leat display the error ?

davecheney commented 7 years ago

Sadly no, because no go error also happens when there are no go files at all, or no go files that match the current build tags. It's an error that is not an error.

Could you please include a sample project that demonstrates the issue and I'll try to work something out.

On Fri, 31 Mar 2017, 03:33 Jérôme Renard notifications@github.com wrote:

I found why.

There was a bad import in one of my go files which for some unknown reason was not reported by gb.

This import ultimately triggers this error https://github.com/constabulary/gb/blob/master/cmd/gb/build.go#L142 which is not displayed.

Do you think you could at leat display the error ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/702#issuecomment-290467210, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcAwfbXumRkqWO2G7Le3PD3RY-G4Twks5rq9lvgaJpZM4MukPT .

jeromer commented 7 years ago

issue720.tar.gz

Just run run gb test api you should get an error message.

If you run gb test you will see that the api package is silently ignored because of a bad import in src/api/handler_test.go (the testhelpers package does not exists).

This bug is quite a nasty one.

davecheney commented 7 years ago

This is what I get

deadwood(~/devel/issue720) % gb build FATAL: command "build" failed: failed to resolve import path "testhelpers/db": import "github.com/jeromer/pgx": not found: stat /home/dfc/devel/issue720/src/github.com/jeromer/pgx: no such file or directory

On Fri, Mar 31, 2017 at 8:31 AM, Jérôme Renard notifications@github.com wrote:

issue720.tar.gz https://github.com/constabulary/gb/files/883841/issue720.tar.gz

Just run run gb test api you should get an error message.

If you run gb test you will see that the api package is silently ignored because of a bad import in src/api/handler_test.go (the testhelpers package does not exists).

This bug is quite a nasty one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/702#issuecomment-290550984, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA_vAQdG-Odkg9dXdcmptPkCYvtvTks5rrB8vgaJpZM4MukPT .