Skip to content

Commit 3fe2d04

Browse files
authored
acceptance: drop darwin-only gate from bundle open + force_pull_commands (#5217)
## Why Follow-up to #5212. Both `acceptance/bundle/open` and `acceptance/bundle/state/force_pull_commands` are gated to darwin only (`GOOS.windows = false`, `GOOS.linux = false`) because they relied on `export PATH=.:$PATH` plus a local `open` stub to keep the real browser from launching. That trick is macOS-specific, and Go's `exec.LookPath` rejects results from `.` anyway, which is why the captured output included `Error: exec: "open": cannot run executable found relative to current directory`. Pieter pointed out that `libs/browser` already honors `$BROWSER` and routes through `libs/exec`, so a fake browser command is portable across darwin/linux/windows. ## Changes **Before:** `export PATH=.:$PATH` + local `open` script; tests gated to darwin; output captured a Go exec error as the assertion. **Now:** `export BROWSER=echo_browser.py`; the stub prints the URL and exits 0; tests run on all three platforms; output shows a clean "Opening browser at <url>" line (and the echoed URL where stdout isn't redirected to /dev/null). - New `acceptance/bin/echo_browser.py`: prints argv[1] and exits. Distinct from the existing `browser.py`, which performs an HTTP GET to close the OAuth callback loop in auth tests; that fetch would have polluted `out.requests.txt` in `force_pull_commands`. - `acceptance/bundle/open/`: replace PATH trick with `BROWSER=echo_browser.py`, drop `musterr`, delete the local `open` stub, delete the test-local `test.toml` (was only setting GOOS overrides). - `acceptance/bundle/state/force_pull_commands/`: same script swap, drop GOOS overrides from `test.toml`, delete local `open` stub. ## Test plan - [x] `go test ./acceptance -run "TestAccept/bundle/open$" -v` passes on darwin (both `direct` and `terraform` engines) - [x] `go test ./acceptance -run "TestAccept/bundle/state/force_pull_commands$" -v` passes on darwin (both engines) - [x] `go test ./acceptance -run "TestAccept/bundle/state/" ` passes (no neighbors broken) - [x] `./task checks`, `./task fmt`, `./task lint-q` clean - [ ] Linux + Windows CI on this PR This pull request and its description were written by Isaac.
1 parent 8d8565d commit 3fe2d04

11 files changed

Lines changed: 31 additions & 29 deletions

File tree

acceptance/bin/echo_browser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Fake browser that prints the URL it was asked to open and exits.
4+
5+
Used by acceptance tests that exercise commands which call libs/browser.Open
6+
but don't need to follow the URL (unlike auth tests, which use browser.py to
7+
close the OAuth callback loop). Setting BROWSER=echo_browser.py is portable
8+
across darwin/linux/windows because libs/browser routes through libs/exec.
9+
10+
Usage: echo_browser.py <url>
11+
"""
12+
13+
import sys
14+
15+
if len(sys.argv) < 2:
16+
sys.stderr.write("Usage: echo_browser.py <url>\n")
17+
sys.exit(1)
18+
19+
print(sys.argv[1])

acceptance/bundle/open/open

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/open/out.test.toml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/open/output.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Deploying resources...
1717
Updating deployment state...
1818
Deployment complete!
1919

20-
=== Modify PATH so that real open is not run
21-
=== open after deployment. This will fail to open browser and complain, that's ok, we only want the message
20+
=== Use a fake browser that just prints the URL it would have opened
21+
=== open after deployment
2222
>>> [CLI] bundle open foo
2323
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
24-
Error: exec: "open": cannot run executable found relative to current directory
24+
[DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
2525

2626
=== test auto-completion handler
2727
>>> [CLI] __complete bundle open ,

acceptance/bundle/open/script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ errcode trace $CLI bundle open foo
66

77
errcode trace $CLI bundle deploy
88

9-
title "Modify PATH so that real open is not run"
10-
export PATH=.:$PATH
9+
title "Use a fake browser that just prints the URL it would have opened"
10+
export BROWSER="echo_browser.py"
1111

12-
title "open after deployment. This will fail to open browser and complain, that's ok, we only want the message"
13-
musterr trace $CLI bundle open foo
12+
title "open after deployment"
13+
trace $CLI bundle open foo
1414

1515
title "test auto-completion handler"
1616
trace $CLI __complete bundle open ,

acceptance/bundle/open/test.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/state/force_pull_commands/open

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/state/force_pull_commands/out.test.toml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/state/force_pull_commands/output.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Deploying resources...
55
Updating deployment state...
66
Deployment complete!
77

8-
=== Modify PATH so that real open is not run
8+
=== Use a fake browser that just prints the URL it would have opened
99
=== bundle summary without --force-pull: no remote state read
1010

1111
>>> [CLI] bundle summary
@@ -22,13 +22,11 @@ Deployment complete!
2222

2323
>>> [CLI] bundle open foo
2424
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
25-
Error: exec: "open": cannot run executable found relative to current directory
2625

2726
=== bundle open --force-pull: remote state read
2827

2928
>>> [CLI] bundle open foo --force-pull
3029
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
31-
Error: exec: "open": cannot run executable found relative to current directory
3230
{
3331
"method": "GET",
3432
"path": "/api/2.0/workspace-files/Workspace/Users/[USERNAME]/.bundle/force-pull-commands/default/state/STATE_FILENAME"

acceptance/bundle/state/force_pull_commands/script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
trace $CLI bundle deploy > /dev/null
22
rm -f out.requests.txt
33

4-
title "Modify PATH so that real open is not run"
5-
export PATH=.:$PATH
4+
title "Use a fake browser that just prints the URL it would have opened"
5+
export BROWSER="echo_browser.py"
66

77
# touch out.requests.txt before each print_requests.py call: the commands without
88
# --force-pull make zero HTTP requests, so the file is never created and
@@ -19,11 +19,11 @@ touch out.requests.txt
1919
print_requests.py --get //workspace-files/
2020

2121
title "bundle open without --force-pull: no remote state read\n"
22-
musterr trace $CLI bundle open foo > /dev/null
22+
trace $CLI bundle open foo > /dev/null
2323
touch out.requests.txt
2424
print_requests.py --get //workspace-files/
2525

2626
title "bundle open --force-pull: remote state read\n"
27-
musterr trace $CLI bundle open foo --force-pull > /dev/null
27+
trace $CLI bundle open foo --force-pull > /dev/null
2828
touch out.requests.txt
2929
print_requests.py --get //workspace-files/

0 commit comments

Comments
 (0)