From 890c57eabeb6252a98bbdfe7fe5a061a6284d48f Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:52:33 +0530 Subject: [PATCH] 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. --- integration/internal/acc/debug.go | 4 ++-- integration/internal/main.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/integration/internal/acc/debug.go b/integration/internal/acc/debug.go index b4939881e..08e385b09 100644 --- a/integration/internal/acc/debug.go +++ b/integration/internal/acc/debug.go @@ -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() diff --git a/integration/internal/main.go b/integration/internal/main.go index 6d69dcf70..6aa2a4c93 100644 --- a/integration/internal/main.go +++ b/integration/internal/main.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "testing" + + "github.com/databricks/cli/integration/internal/acc" ) // Main is the entry point for integration tests. @@ -11,7 +13,7 @@ import ( // 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 }