Enable debugging integration tests in VS Code (#2053)

## 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:
https://github.com/databricks/cli/pull/2009. Specifically the addition
of internal.Main as the entrypoint for all integration tests.

## Tests
Manually, by trying to debug a test.
This commit is contained in:
shreyas-goenka 2025-01-02 16:52:33 +05:30 committed by GitHub
parent ea8445af9e
commit 890c57eabe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -11,14 +11,14 @@ import (
) )
// Detects if test is run from "debug test" feature in VS Code. // Detects if test is run from "debug test" feature in VS Code.
func isInDebug() bool { func IsInDebug() bool {
ex, _ := os.Executable() ex, _ := os.Executable()
return strings.HasPrefix(path.Base(ex), "__debug_bin") return strings.HasPrefix(path.Base(ex), "__debug_bin")
} }
// Loads debug environment from ~/.databricks/debug-env.json. // Loads debug environment from ~/.databricks/debug-env.json.
func loadDebugEnvIfRunFromIDE(t testutil.TestingT, key string) { func loadDebugEnvIfRunFromIDE(t testutil.TestingT, key string) {
if !isInDebug() { if !IsInDebug() {
return return
} }
home, err := os.UserHomeDir() home, err := os.UserHomeDir()

View File

@ -4,6 +4,8 @@ import (
"fmt" "fmt"
"os" "os"
"testing" "testing"
"github.com/databricks/cli/integration/internal/acc"
) )
// Main is the entry point for integration tests. // Main is the entry point for integration tests.
@ -11,7 +13,7 @@ import (
// they are not inadvertently executed when calling `go test ./...`. // they are not inadvertently executed when calling `go test ./...`.
func Main(m *testing.M) { func Main(m *testing.M) {
value := os.Getenv("CLOUD_ENV") value := os.Getenv("CLOUD_ENV")
if value == "" { if value == "" && !acc.IsInDebug() {
fmt.Println("CLOUD_ENV is not set, skipping integration tests") fmt.Println("CLOUD_ENV is not set, skipping integration tests")
return return
} }