diff --git a/acceptance/bin/find.py b/acceptance/bin/find.py index 61ad752fdc7..896bcef98c4 100755 --- a/acceptance/bin/find.py +++ b/acceptance/bin/find.py @@ -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 @@ -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) diff --git a/acceptance/bundle/destroy/jobs-and-pipeline/output.txt b/acceptance/bundle/destroy/jobs-and-pipeline/output.txt index ac68178a52b..68f1bc5e824 100644 --- a/acceptance/bundle/destroy/jobs-and-pipeline/output.txt +++ b/acceptance/bundle/destroy/jobs-and-pipeline/output.txt @@ -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 diff --git a/acceptance/bundle/destroy/jobs-and-pipeline/script b/acceptance/bundle/destroy/jobs-and-pipeline/script index 3d958e0c4a2..3ed9aaf3a01 100644 --- a/acceptance/bundle/destroy/jobs-and-pipeline/script +++ b/acceptance/bundle/destroy/jobs-and-pipeline/script @@ -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}" diff --git a/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/output.txt b/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/output.txt index 849e97605a2..adf46f5a721 100644 --- a/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/output.txt +++ b/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/output.txt @@ -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 diff --git a/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/script b/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/script index f8139fab31e..349bd172988 100644 --- a/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/script +++ b/acceptance/bundle/destroy/lineage-mismatch-after-redeploy/script @@ -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 diff --git a/acceptance/bundle/generate/job_nested_notebooks/script b/acceptance/bundle/generate/job_nested_notebooks/script index a52154efbb0..e7ce4f18126 100644 --- a/acceptance/bundle/generate/job_nested_notebooks/script +++ b/acceptance/bundle/generate/job_nested_notebooks/script @@ -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/'