some more tests

This commit is contained in:
Shreyas Goenka 2025-03-03 14:01:41 +01:00
parent 90c6ad0fdb
commit 6002e0d040
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
7 changed files with 17 additions and 8 deletions

View File

@ -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).

View File

@ -0,0 +1,2 @@
bundle:
name: foobar

View File

@ -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

View File

@ -1 +1 @@
trace errcode $CLI bundle exec echo "Hello,\ World"
trace errcode $CLI bundle exec -- echo hello

View File

@ -0,0 +1,5 @@
>>> [CLI] bundle exec echo hello
Error: Please add a '--' separator. Usage: 'databricks bundle exec -- echo hello'
Exit code: 1

View File

@ -0,0 +1 @@
trace $CLI bundle exec echo hello

View File

@ -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())