Skip to content

Commit

Permalink
Enable debugging integration tests in VS Code (#2053)
Browse files Browse the repository at this point in the history
## Changes
This PR adds back debugging functionality that was lost during migration
to `internal.Main` as an entry point for integration tests.

The PR that caused the regression:
#2009. Specifically the addition
of internal.Main as the entrypoint for all integration tests.

## Tests
Manually, by trying to debug a test.
  • Loading branch information
shreyas-goenka authored Jan 2, 2025
1 parent ea8445a commit 890c57e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions integration/internal/acc/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
)

// Detects if test is run from "debug test" feature in VS Code.
func isInDebug() bool {
func IsInDebug() bool {
ex, _ := os.Executable()
return strings.HasPrefix(path.Base(ex), "__debug_bin")
}

// Loads debug environment from ~/.databricks/debug-env.json.
func loadDebugEnvIfRunFromIDE(t testutil.TestingT, key string) {
if !isInDebug() {
if !IsInDebug() {
return
}
home, err := os.UserHomeDir()
Expand Down
4 changes: 3 additions & 1 deletion integration/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import (
"fmt"
"os"
"testing"

"github.com/databricks/cli/integration/internal/acc"
)

// Main is the entry point for integration tests.
// We use this for all integration tests defined in this subtree to ensure
// they are not inadvertently executed when calling `go test ./...`.
func Main(m *testing.M) {
value := os.Getenv("CLOUD_ENV")
if value == "" {
if value == "" && !acc.IsInDebug() {
fmt.Println("CLOUD_ENV is not set, skipping integration tests")
return
}
Expand Down

0 comments on commit 890c57e

Please sign in to comment.