-
Notifications
You must be signed in to change notification settings - Fork 23
fixed broken behavior of buffalo test -m #181
Conversation
for _, freeCmd := range anywhereCommands { | ||
if freeCmd != cmd.Name() { | ||
if freeCmd == cmdName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the current command (subcommand) is one of anywhereCommands
, just returns nil and stops prechecking. Otherwise, the command should be executed within the application directory that can be determined by checking .buffalo.dev.yml
currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding some comments to explain the changes.
cmdName := cmd.Name() | ||
if cmd.Parent() != cmd.Root() { | ||
// e.g. `completion` for `buffalo completion bash` instead of `bash` | ||
cmdName = cmd.Parent().Name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is possible that some "current command" is not a direct child of root but a grandchild. they should be checked with the name of their parent.
@@ -28,7 +28,8 @@ func plugs() plugins.List { | |||
func decorate(name string, cmd *cobra.Command) { | |||
pugs := plugs() | |||
for _, c := range pugs[name] { | |||
anywhereCommands = append(anywhereCommands, c.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugins are not anywhere commands. they should be executed within the app directory.
@@ -94,20 +92,9 @@ func runDevScript(ctx context.Context, app meta.App) error { | |||
func startDevServer(ctx context.Context, args []string) error { | |||
app := meta.New(".") | |||
|
|||
cfgFile := "./.buffalo.dev.yml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev
command is not an anywhere command, so if the command was executed from the directory that has no .buffalo.dev.yml
, the execution will be aborted by the root's pre-checking and this block should not be reachable.
@@ -156,11 +156,12 @@ func (m mFlagRunner) Run() error { | |||
continue | |||
} | |||
|
|||
cmd := newTestCmd(m.args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a command should be built within the app's root so the correct configuration was applied.
@@ -178,8 +179,9 @@ func (m mFlagRunner) Run() error { | |||
return nil | |||
} | |||
|
|||
func hasTestify(p string) bool { | |||
cmd := exec.Command("go", "test", "-thisflagdoesntexist") | |||
func hasTestify(args []string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the base of the checking command also should be a complete command (except the last wrong argument which causes an intentional error) so the execution can be guaranteed.
f7aad8b
to
d9a2fd2
Compare
This |
In our code, the
So what I found for |
Was taking the time to review how this impacted the v1 version of all this. Thanks for adding the comments @sio4. |
Not sure when the issue started, but
buffalo test -m TEST
was not working as expected. The bug was reported as #180 recently (transferred from thebuffalo
repository).This fix fixes the following things:
.buffalo.dev.yml
existence checking onbuffalo dev
command. The logic should not reach there since therootCmd
checks that before executing subcommands.anywhereCommands
checking.anywhereCommands
means they can be executed outside app root.anywhereCommands
. (maybe related to the above miss-checking?)buffalo test -m
handles argument properly especially withtestify
.fixes #180