diff --git a/acceptance/bin/echo_browser.py b/acceptance/bin/echo_browser.py new file mode 100755 index 00000000000..3d451cf4526 --- /dev/null +++ b/acceptance/bin/echo_browser.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +""" +Fake browser that prints the URL it was asked to open and exits. + +Used by acceptance tests that exercise commands which call libs/browser.Open +but don't need to follow the URL (unlike auth tests, which use browser.py to +close the OAuth callback loop). Setting BROWSER=echo_browser.py is portable +across darwin/linux/windows because libs/browser routes through libs/exec. + +Usage: echo_browser.py +""" + +import sys + +if len(sys.argv) < 2: + sys.stderr.write("Usage: echo_browser.py \n") + sys.exit(1) + +print(sys.argv[1]) diff --git a/acceptance/bundle/open/open b/acceptance/bundle/open/open deleted file mode 100755 index 5c6c78d6a78..00000000000 --- a/acceptance/bundle/open/open +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "I AM BROWSER" diff --git a/acceptance/bundle/open/out.test.toml b/acceptance/bundle/open/out.test.toml index 519954aedc9..f784a183258 100644 --- a/acceptance/bundle/open/out.test.toml +++ b/acceptance/bundle/open/out.test.toml @@ -1,5 +1,3 @@ Local = true Cloud = false -GOOS.linux = false -GOOS.windows = false EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/bundle/open/output.txt b/acceptance/bundle/open/output.txt index e310567b110..2da91364c7b 100644 --- a/acceptance/bundle/open/output.txt +++ b/acceptance/bundle/open/output.txt @@ -17,11 +17,11 @@ Deploying resources... Updating deployment state... Deployment complete! -=== Modify PATH so that real open is not run -=== open after deployment. This will fail to open browser and complain, that's ok, we only want the message +=== Use a fake browser that just prints the URL it would have opened +=== open after deployment >>> [CLI] bundle open foo Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID] -Error: exec: "open": cannot run executable found relative to current directory +[DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID] === test auto-completion handler >>> [CLI] __complete bundle open , diff --git a/acceptance/bundle/open/script b/acceptance/bundle/open/script index 724bb42871e..1fcc79ddbff 100644 --- a/acceptance/bundle/open/script +++ b/acceptance/bundle/open/script @@ -6,11 +6,11 @@ errcode trace $CLI bundle open foo errcode trace $CLI bundle deploy -title "Modify PATH so that real open is not run" -export PATH=.:$PATH +title "Use a fake browser that just prints the URL it would have opened" +export BROWSER="echo_browser.py" -title "open after deployment. This will fail to open browser and complain, that's ok, we only want the message" -musterr trace $CLI bundle open foo +title "open after deployment" +trace $CLI bundle open foo title "test auto-completion handler" trace $CLI __complete bundle open , diff --git a/acceptance/bundle/open/test.toml b/acceptance/bundle/open/test.toml deleted file mode 100644 index 078e52c97ea..00000000000 --- a/acceptance/bundle/open/test.toml +++ /dev/null @@ -1,2 +0,0 @@ -GOOS.windows = false -GOOS.linux = false diff --git a/acceptance/bundle/state/force_pull_commands/open b/acceptance/bundle/state/force_pull_commands/open deleted file mode 100755 index 5c6c78d6a78..00000000000 --- a/acceptance/bundle/state/force_pull_commands/open +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "I AM BROWSER" diff --git a/acceptance/bundle/state/force_pull_commands/out.test.toml b/acceptance/bundle/state/force_pull_commands/out.test.toml index 519954aedc9..f784a183258 100644 --- a/acceptance/bundle/state/force_pull_commands/out.test.toml +++ b/acceptance/bundle/state/force_pull_commands/out.test.toml @@ -1,5 +1,3 @@ Local = true Cloud = false -GOOS.linux = false -GOOS.windows = false EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/bundle/state/force_pull_commands/output.txt b/acceptance/bundle/state/force_pull_commands/output.txt index a2f90109185..10560af0965 100644 --- a/acceptance/bundle/state/force_pull_commands/output.txt +++ b/acceptance/bundle/state/force_pull_commands/output.txt @@ -5,7 +5,7 @@ Deploying resources... Updating deployment state... Deployment complete! -=== Modify PATH so that real open is not run +=== Use a fake browser that just prints the URL it would have opened === bundle summary without --force-pull: no remote state read >>> [CLI] bundle summary @@ -22,13 +22,11 @@ Deployment complete! >>> [CLI] bundle open foo Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID] -Error: exec: "open": cannot run executable found relative to current directory === bundle open --force-pull: remote state read >>> [CLI] bundle open foo --force-pull Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID] -Error: exec: "open": cannot run executable found relative to current directory { "method": "GET", "path": "/api/2.0/workspace-files/Workspace/Users/[USERNAME]/.bundle/force-pull-commands/default/state/STATE_FILENAME" diff --git a/acceptance/bundle/state/force_pull_commands/script b/acceptance/bundle/state/force_pull_commands/script index bea7852ed8c..488a260e2ff 100644 --- a/acceptance/bundle/state/force_pull_commands/script +++ b/acceptance/bundle/state/force_pull_commands/script @@ -1,8 +1,8 @@ trace $CLI bundle deploy > /dev/null rm -f out.requests.txt -title "Modify PATH so that real open is not run" -export PATH=.:$PATH +title "Use a fake browser that just prints the URL it would have opened" +export BROWSER="echo_browser.py" # touch out.requests.txt before each print_requests.py call: the commands without # --force-pull make zero HTTP requests, so the file is never created and @@ -19,11 +19,11 @@ touch out.requests.txt print_requests.py --get //workspace-files/ title "bundle open without --force-pull: no remote state read\n" -musterr trace $CLI bundle open foo > /dev/null +trace $CLI bundle open foo > /dev/null touch out.requests.txt print_requests.py --get //workspace-files/ title "bundle open --force-pull: remote state read\n" -musterr trace $CLI bundle open foo --force-pull > /dev/null +trace $CLI bundle open foo --force-pull > /dev/null touch out.requests.txt print_requests.py --get //workspace-files/ diff --git a/acceptance/bundle/state/force_pull_commands/test.toml b/acceptance/bundle/state/force_pull_commands/test.toml index 1a1df4f5880..f5306da0126 100644 --- a/acceptance/bundle/state/force_pull_commands/test.toml +++ b/acceptance/bundle/state/force_pull_commands/test.toml @@ -2,11 +2,6 @@ Local = true Cloud = false RecordRequests = true -# bundle open opens a browser; restrict to darwin to get stable output -# (mirrors acceptance/bundle/open/test.toml). -GOOS.windows = false -GOOS.linux = false - Ignore = [".databricks"] [EnvMatrix]