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"
|
// 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.
|
// Then install your breakpoints and click "debug test" near TestAccept in VSCODE.
|
||||||
// example: var SingleTest = "bundle/variables/empty"
|
// 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
|
// 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).
|
// 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!
|
>>> errcode [CLI] bundle exec -- echo hello
|
||||||
Error: Please add a '--' separator. Usage: 'databricks bundle exec -- <command> arg1 arg2 ...'
|
hello
|
||||||
|
Error: Error waiting for command: exec: Wait was already called
|
||||||
|
|
||||||
Exit code: 1
|
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",
|
Short: "Execute a command using the same authentication context as the bundle",
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Long: `Examples:
|
Long: `Examples:
|
||||||
1. databricks bundle exec -- echo "Hello, world!"
|
1. databricks bundle exec -- echo hello
|
||||||
2. databricks bundle exec -- /bin/bash -c "echo 'Hello, world!'"
|
2. databricks bundle exec -- /bin/bash -c "echo hello""
|
||||||
3. databricks bundle exec -- uv run pytest"`,
|
3. databricks bundle exec -- uv run pytest"`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if cmd.ArgsLenAtDash() != 0 {
|
if cmd.ArgsLenAtDash() != 0 {
|
||||||
|
@ -41,7 +41,7 @@ func newExecCommand() *cobra.Command {
|
||||||
return diags.Error()
|
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()))
|
childCmd.Env = auth.ProcessEnv(root.ConfigUsed(cmd.Context()))
|
||||||
|
|
||||||
// Create pipes for stdout and stderr
|
// Create pipes for stdout and stderr
|
||||||
|
@ -82,7 +82,7 @@ func newExecCommand() *cobra.Command {
|
||||||
|
|
||||||
// Wait for the command to finish.
|
// Wait for the command to finish.
|
||||||
// TODO: Pretty exit codes?
|
// 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()
|
err = childCmd.Wait()
|
||||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
return fmt.Errorf("Command exited with code: %d", exitErr.ExitCode())
|
return fmt.Errorf("Command exited with code: %d", exitErr.ExitCode())
|
||||||
|
|
Loading…
Reference in New Issue