Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions acceptance/bin/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Finds all files within current directory matching regex. The output is sorted and slashes are always forward.

If --expect N is provided, the number of matches must be N or error is printed.
If --dirs is provided, directories are matched and printed too (default: files only).
"""

import argparse
Expand All @@ -14,14 +15,16 @@
parser = argparse.ArgumentParser()
parser.add_argument("regex")
parser.add_argument("--expect", type=int)
parser.add_argument("--dirs", action="store_true")
args = parser.parse_args()

regex = re.compile(args.regex)
result = []

for root, _dirs, files in os.walk("."):
for filename in files:
path = os.path.join(root, filename).replace("\\", "/")
for root, dirs, files in os.walk("."):
names = files + dirs if args.dirs else files
for name in names:
path = os.path.join(root, name).replace("\\", "/")
path = path.removeprefix("./")
if regex.search(path):
result.append(path)
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/destroy/jobs-and-pipeline/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Exit code: 1

=== Assert destroy leaves the bundle state dir clean:

>>> find .databricks -name terraform -prune -o -print
>>> find.py --dirs ^\.databricks(/|$)
.databricks
.databricks/.gitignore
.databricks/bundle
Expand Down
7 changes: 2 additions & 5 deletions acceptance/bundle/destroy/jobs-and-pipeline/script
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ cleanup() {
errcode $CLI jobs get "${JOB_ID}" 2>&1

# Print the whole state tree so a lingering snapshot file or an empty scaffolding
# dir (e.g. sync-snapshots/ or .internal/) both show up. The terraform engine dir is
# pruned: its contents differ by engine and embed the provider version and OS/arch,
# which would make the golden fragile. The bundle scaffolding we care about lives
# directly under the target dir, so it is still covered.
# dir (e.g. sync-snapshots/ or .internal/) both show up.
title "Assert destroy leaves the bundle state dir clean:\n"
trace find .databricks -name terraform -prune -o -print | sort
trace find.py --dirs '^\.databricks(/|$)'

title "Assert bundle deployment path is deleted"
trace errcode $CLI workspace get-status "${DEPLOYMENT_PATH}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Destroy: 1 deleted

=== and leaves the bundle state dir clean, with no empty scaffolding directories:

>>> find .databricks -name terraform -prune -o -print
>>> find.py --dirs ^\.databricks(/|$)
.databricks
.databricks/.gitignore
.databricks/bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ trace $CLI bundle destroy --auto-approve
title "A clean destroy removes the local state file, so no stale lineage is left behind:\n"
trace find.py '^.databricks/bundle/default/(resources.json|terraform/terraform.tfstate)$' --expect 0

# Print the whole state tree so any empty scaffolding dir or stray file shows up. The
# terraform engine dir is pruned: its contents differ by engine and embed the provider
# version and OS/arch, which would make the golden fragile (the state file it holds is
# already asserted gone above). The bundle scaffolding we care about lives directly
# under the target dir, so it is still covered.
# Print the whole state tree so any empty scaffolding dir or stray file shows up.
title "and leaves the bundle state dir clean, with no empty scaffolding directories:\n"
trace find .databricks -name terraform -prune -o -print | sort
trace find.py --dirs '^\.databricks(/|$)'

# Wipe whatever remains so the next deploy behaves like a fresh machine.
rm -rf .databricks
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/generate/job_nested_notebooks/script
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ test ! -f src/my_notebook.py && echo "src/my_notebook.py removed" || echo "src/m
test ! -f src/other_notebook.py && echo "src/other_notebook.py removed" || echo "src/other_notebook.py still exists"

echo "=== new nested files ==="
find src -type f | sort
find.py '^src/'
Loading