mirror of https://github.com/databricks/cli.git
some more tests
This commit is contained in:
parent
90c6ad0fdb
commit
6002e0d040
|
@ -41,7 +41,7 @@ var (
|
|||
// In order to debug CLI running under acceptance test, set this to full subtest name, e.g. "bundle/variables/empty"
|
||||
// Then install your breakpoints and click "debug test" near TestAccept in VSCODE.
|
||||
// example: var SingleTest = "bundle/variables/empty"
|
||||
var SingleTest = "bundle/exec/basic"
|
||||
var SingleTest = ""
|
||||
|
||||
// If enabled, instead of compiling and running CLI externally, we'll start in-process server that accepts and runs
|
||||
// CLI commands. The $CLI in test scripts is a helper that just forwards command-line arguments to this server (see bin/callserver.py).
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
bundle:
|
||||
name: foobar
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
>>> errcode [CLI] bundle exec -- echo Hello, World!
|
||||
Error: Please add a '--' separator. Usage: 'databricks bundle exec -- <command> arg1 arg2 ...'
|
||||
>>> errcode [CLI] bundle exec -- echo hello
|
||||
hello
|
||||
Error: Error waiting for command: exec: Wait was already called
|
||||
|
||||
Exit code: 1
|
||||
|
|
|
@ -1 +1 @@
|
|||
trace errcode $CLI bundle exec echo "Hello,\ World"
|
||||
trace errcode $CLI bundle exec -- echo hello
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
>>> [CLI] bundle exec echo hello
|
||||
Error: Please add a '--' separator. Usage: 'databricks bundle exec -- echo hello'
|
||||
|
||||
Exit code: 1
|
|
@ -0,0 +1 @@
|
|||
trace $CLI bundle exec echo hello
|
|
@ -25,8 +25,8 @@ func newExecCommand() *cobra.Command {
|
|||
Short: "Execute a command using the same authentication context as the bundle",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Long: `Examples:
|
||||
1. databricks bundle exec -- echo "Hello, world!"
|
||||
2. databricks bundle exec -- /bin/bash -c "echo 'Hello, world!'"
|
||||
1. databricks bundle exec -- echo hello
|
||||
2. databricks bundle exec -- /bin/bash -c "echo hello""
|
||||
3. databricks bundle exec -- uv run pytest"`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if cmd.ArgsLenAtDash() != 0 {
|
||||
|
@ -41,7 +41,7 @@ func newExecCommand() *cobra.Command {
|
|||
return diags.Error()
|
||||
}
|
||||
|
||||
childCmd := exec.Command(args[1], args[2:]...)
|
||||
childCmd := exec.Command(args[0], args[1:]...)
|
||||
childCmd.Env = auth.ProcessEnv(root.ConfigUsed(cmd.Context()))
|
||||
|
||||
// Create pipes for stdout and stderr
|
||||
|
@ -82,7 +82,7 @@ func newExecCommand() *cobra.Command {
|
|||
|
||||
// Wait for the command to finish.
|
||||
// TODO: Pretty exit codes?
|
||||
// TODO: Make CLI return the same exit codes?
|
||||
// TODO: Make CLI return the same exit codes? It has to, that's a requirement.
|
||||
err = childCmd.Wait()
|
||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
return fmt.Errorf("Command exited with code: %d", exitErr.ExitCode())
|
||||
|
|
Loading…
Reference in New Issue