-
Notifications
You must be signed in to change notification settings - Fork 24
feature: pass test flags through to go test #241
Comments
I agree with this one. I will work on it and keep you posted @mattbnz. |
Yeah, I agree too. definitely, we need to fix it. However, I would like to approach this issue in a slightly different direction from the perspective of command line syntax along with the style of "POSIX vs. Go". Previously before #168, the boundary of global flags and sub-command flags was not clear and some of the sequences worked but some did not. Inconsistent. Now we have the order of flags like below but still, we don't have a kind of pass-through flags that is related to this issue. Currently, we have the following syntax: $ buffalo [global flags...] subcommand [subcommand flags...] For the This is the current condition. Now, I would like to suggest introducing the "end of options" flag which is $ buffalo [global flags...] subcommand [subcommand flags...] [-- arguments should be passed as is] With this proposed change, users can provide unlimited flags and arguments to the Additionally, the current command line for testing could be something like the below: $ buffalo test --force-migrations -run TestMyMethod As you see, the The proposed command line example could be: $ buffalo test --force-migrations -- -cover -timeout 60s -v -run TestCase (let $ buffalo test --force-migrations --run TestCase -- -cover -timeout 60s -v (do Related issues/PRs:
Will continue with summarizing the current behavior. |
The current behavior as a record: Supported pass-through flags are $ buffalo test -v
XXX commandArgs [-v]
XXX packageArgs []
XXX cmd.Run in /home/sio4/git/bt/coco
INFO[0000] go test -p 1 -tags development sqlite -v coco/actions coco/cmd/app coco/grifts coco/locales coco/models coco/public coco/templates
$ buffalo test -timeout 5s
XXX commandArgs [-timeout 5s]
XXX packageArgs []
XXX cmd.Run in /home/sio4/git/bt/coco
INFO[0000] go test -p 1 -tags development sqlite -timeout 5s coco/actions coco/cmd/app coco/grifts coco/locales coco/models coco/public coco/templates When we use unsupported flags like $ buffalo test -cover
XXX commandArgs []
XXX packageArgs [-cover]
XXX cmd.Run in /home/sio4/git/bt/coco
INFO[0000] go test -p 1 -tags development sqlite -cover
no Go files in /home/sio4/git/bt/coco But if we also provide $ buffalo test -cover ./...
XXX commandArgs []
XXX packageArgs [-cover ./...]
XXX cmd.Run in /home/sio4/git/bt/coco
INFO[0000] go test -p 1 -tags development sqlite -cover ./...
$ buffalo test -run Test_NameOthername
XXX commandArgs []
XXX packageArgs []
XXX cmd.Run in /home/sio4/git/bt/coco/actions
INFO[0001] go test -p 1 -tags development sqlite -testify.m Test_NameOthername
XXX cmd.Run in /home/sio4/git/bt/coco/cmd/app
INFO[0003] go test -p 1 -tags development sqlite -run Test_NameOthername
XXX cmd.Run in /home/sio4/git/bt/coco/grifts
INFO[0004] go test -p 1 -tags development sqlite -run Test_NameOthername
... CLI will walk through found packages (the package detection is actually required for this) and runs Providing the package name at the end of the command line works like the below, the same as the previous buggy example: $ buffalo test -run Test_NameOthername actions
XXX commandArgs []
XXX packageArgs [actions]
XXX cmd.Run in /home/sio4/git/bt/coco/actions
INFO[0001] go test -p 1 -tags development sqlite -testify.m Test_NameOthername However, $ buffalo test -run Test_NameOthername ./...
XXX commandArgs []
XXX packageArgs [./...]
XXX cmd.Run in /home/sio4/git/bt/coco
INFO[0000] go test -p 1 -tags development sqlite -run Test_NameOthername
no Go files in /home/sio4/git/bt/coco Those are some examples of the current behavior. |
I wondered if we really need to use the flag Go versionsIt seems like Go 1.7 started to support '/' separation. I am not fully sure what was the status of the support by the way. The release date of the version is 2016-08-15. TestifyTestify introduced the BuffaloThe related code with package looping for Anyway, I feel like we can deprecate the switching and just support |
Roughly, I tested with this patch, and it could be OK for all the use cases I described above. https://gist.github.com/sio4/0d892ca8413e994c3ccb99af1ca744bb |
Hi @sio4, I saw your patch and I think it would work well only if we want to keep the users limited in terms of the flags that could be passed to underlying the More broadly, I think we should consider if we should support Testify instead of the |
(As a cross note) I wrote detailed comments and my thoughts on #247 |
Description
buffalo test (in both the existing stable, and upcoming v2 CLI branch AFAICT) heavily restricts what test flags can be passed through to the underling go test run which makes it hard to take advantage of standard go testing features via buffalo (e.g. -short to trigger a cut-down set of tests).
Could buffalo test be modified so that any unknown flag encountered in the list of arguments be treated as an entry for commandArgs, rather than the packageArgs lists and therefore be correctly passed through to go test ?
Additional Information
No response
The text was updated successfully, but these errors were encountered: