|
45 | 45 | LogRequests bool |
46 | 46 | LogConfig bool |
47 | 47 | UseVersion string |
| 48 | + CLIPath string |
48 | 49 | WorkspaceTmpDir bool |
49 | 50 | OnlyOutTestToml bool |
50 | 51 | Subset bool |
@@ -75,6 +76,7 @@ func init() { |
75 | 76 | flag.BoolVar(&LogRequests, "logrequests", false, "Log request and responses from testserver") |
76 | 77 | flag.BoolVar(&LogConfig, "logconfig", false, "Log merged for each test case") |
77 | 78 | flag.StringVar(&UseVersion, "useversion", "", "Download previously released version of CLI and use it to run the tests") |
| 79 | + flag.StringVar(&CLIPath, "clipath", "", "Use the CLI binary at this path instead of building from source (e.g. a CLI built from main for regression comparison)") |
78 | 80 |
|
79 | 81 | // DABs in the workspace runs on the workspace file system. This flags does the same for acceptance tests |
80 | 82 | // to simulate an identical environment. |
@@ -191,17 +193,27 @@ func hasRunFilter() bool { |
191 | 193 | // requirePrerequisites verifies external tool prerequisites before doing any |
192 | 194 | // work, so a stale toolchain fails fast with an actionable message instead of |
193 | 195 | // producing confusing diffs deep into the run. |
194 | | -func requirePrerequisites(t *testing.T) { |
195 | | - // Scripts use jq 1.7 features (the pick/1 builtin and the `.foo.[]` iteration syntax). |
196 | | - internal.RequireJQ(t, "1.7") |
197 | | - // uv builds the databricks-bundles wheel and provides the test interpreter |
198 | | - // via `uv python find`, which landed in the 0.3 line. |
199 | | - internal.RequireUV(t, "0.4") |
200 | | - // ruff 0.9.1 is pinned across the repo (python/pyproject.toml, Taskfile.yml); |
201 | | - // the check-formatting test's golden output assumes its formatter behavior. |
202 | | - internal.RequireRuff(t, "0.9.1") |
203 | | - // Acceptance scripts import the stdlib tomllib module, added in Python 3.11. |
204 | | - internal.EnsurePython(t, "3.11") |
| 196 | +// |
| 197 | +// It reports whether all checks passed; a failure surfaces as |
| 198 | +// TestAccept/prerequisites rather than a bare TestAccept. |
| 199 | +// |
| 200 | +// On DBR the serverless image only provides what the test archive ships, so |
| 201 | +// every tool required here must also be bundled in internal/testarchive. When |
| 202 | +// adding a new RequireX prerequisite, add a matching downloader there too, or |
| 203 | +// DBR runs will fail this check before any test runs. |
| 204 | +func requirePrerequisites(t *testing.T) bool { |
| 205 | + return t.Run("prerequisites", func(t *testing.T) { |
| 206 | + // Scripts use jq 1.7 features (the pick/1 builtin and the `.foo.[]` iteration syntax). |
| 207 | + internal.RequireJQ(t, "1.7") |
| 208 | + // uv builds the databricks-bundles wheel and provides the test interpreter |
| 209 | + // via `uv python find`, which landed in the 0.3 line. |
| 210 | + internal.RequireUV(t, "0.4") |
| 211 | + // ruff 0.9.1 is pinned across the repo (python/pyproject.toml, Taskfile.yml); |
| 212 | + // the check-formatting test's golden output assumes its formatter behavior. |
| 213 | + internal.RequireRuff(t, "0.9.1") |
| 214 | + // Acceptance scripts import the stdlib tomllib module, added in Python 3.11. |
| 215 | + internal.RequirePython(t, "3.11") |
| 216 | + }) |
205 | 217 | } |
206 | 218 |
|
207 | 219 | func testAccept(t *testing.T, inprocessMode bool, singleTest string) int { |
@@ -245,7 +257,14 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int { |
245 | 257 | os.Unsetenv(v) //nolint:usetesting // t.Setenv cannot unset |
246 | 258 | } |
247 | 259 |
|
248 | | - requirePrerequisites(t) |
| 260 | + if !requirePrerequisites(t) { |
| 261 | + // Don't run the suite against a stale toolchain; the failed subtest |
| 262 | + // has already marked the parent test as failed. |
| 263 | + return 0 |
| 264 | + } |
| 265 | + // Run after the version check passed; must use the top-level t so the PATH |
| 266 | + // change survives for the rest of the run. |
| 267 | + internal.ConfigurePython(t, "3.11") |
249 | 268 |
|
250 | 269 | buildDir := getBuildDir(t, cwd, runtime.GOOS, runtime.GOARCH) |
251 | 270 |
|
@@ -285,7 +304,11 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int { |
285 | 304 | t.Setenv("CMD_SERVER_URL", cmdServer.URL) |
286 | 305 | execPath = filepath.Join(cwd, "bin", "callserver.py") |
287 | 306 | } else { |
288 | | - if UseVersion != "" { |
| 307 | + if CLIPath != "" { |
| 308 | + // Use a prebuilt binary (e.g. a CLI built from main) instead of building |
| 309 | + // from the current source, so the test infra and tests stay on this branch. |
| 310 | + execPath = CLIPath |
| 311 | + } else if UseVersion != "" { |
289 | 312 | version := UseVersion |
290 | 313 | if version == "latest" { |
291 | 314 | version = resolveLatestVersion(t, buildDir) |
|
0 commit comments