File tree Expand file tree Collapse file tree
bundle/state/state_present Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 must_find .append (arg )
1111
1212found = set ()
13+ failed = False
1314
1415for line in sys .stdin :
1516 sys .stdout .write (line )
1920 for t in must_not_find :
2021 if t in line :
2122 sys .stderr .write (f"contains error: { t !r} was not expected: { line .strip ()!r} \n " )
23+ failed = True
2224
2325sys .stdout .flush ()
2426
2527not_found = set (must_find ) - found
2628for item in sorted (not_found ):
2729 sys .stderr .write (f"contains error: { item !r} not found in the output.\n " )
30+ failed = True
31+
32+ # Exit non-zero so a failed assertion aborts the script (set -e -o pipefail)
33+ # instead of silently baking the error line into the expected output.
34+ if failed :
35+ sys .exit (1 )
Original file line number Diff line number Diff line change @@ -71,7 +71,6 @@ Deployment complete!
7171>>> print_state.py
72723
737313
74- contains error: '11' not found in the output.
7574
7675>>> DATABRICKS_BUNDLE_ENGINE=terraform [CLI] bundle deploy
7776Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
@@ -92,7 +91,6 @@ Deployment complete!
9291>>> print_state.py
93923
949313
95- contains error: '12' not found in the output.
9694
9795>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states
9896[TEST_TMP_DIR]/.databricks/bundle/default/terraform/terraform.tfstate: local terraform state serial=3 lineage="test-lineage"
Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle destroy --auto-approve
2929rm out.requests.txt
3030trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle deploy
3131trace print_requests.py //api/2.1/unity-catalog/schemas | jq '.headers["User-Agent"][0]' | contains.py 'engine/direct' '!terraform' '!tf-provider'
32- trace print_state.py | jq .serial | contains.py "11 "
32+ trace print_state.py | jq .serial | contains.py "13 "
3333
3434trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle deploy
3535#trace print_requests.py --get //api/2.1/unity-catalog/schemas | jq '.headers["User-Agent"][0]' | contains.py 'engine/direct' '!terraform' '!tf-provider'
3636
3737trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle deploy
3838trace print_requests.py --get //api/2.1/unity-catalog/schemas | jq '.headers["User-Agent"][0]' | contains.py 'engine/direct' '!terraform' '!tf-provider'
39- trace print_state.py | jq .serial | contains.py "12 "
39+ trace print_state.py | jq .serial | contains.py "13 "
4040
4141trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle debug states
4242trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle debug states --force-pull
Original file line number Diff line number Diff line change 44Hello world
55contains error: 'not_found' not found in the output.
66
7+ Exit code: 1
8+
79=== This should complain about not_found not found
810>>> musterr python3 ./failure.py
911Failed script
1012contains error: 'not_found' not found in the output.
1113
14+ Exit code: 1
15+
1216=== This should not complain
1317>>> python3 ./success.py
1418Hello world
@@ -22,6 +26,8 @@ Failed script
2226Hello world
2327contains error: 'Hello' was not expected: 'Hello world'
2428
29+ Exit code: 1
30+
2531=== This should not complain
2632>>> python3 ./success.py
2733Hello world
Original file line number Diff line number Diff line change 11title "This should complain about not_found not found"
2- trace python3 ./success.py | contains.py not_found
2+ trace python3 ./success.py | errcode contains.py not_found
33
44title "This should complain about not_found not found"
5- trace musterr python3 ./failure.py | contains.py not_found
5+ trace musterr python3 ./failure.py | errcode contains.py not_found
66
77title "This should not complain"
88trace python3 ./success.py | contains.py world Hello
@@ -11,7 +11,7 @@ title "This should not complain"
1111trace musterr python3 ./failure.py | contains.py Failed
1212
1313title "This should complain about Hello present in output"
14- trace python3 ./success.py | contains.py !Hello
14+ trace python3 ./success.py | errcode contains.py !Hello
1515
1616title "This should not complain"
1717trace python3 ./success.py | contains.py !not_found
You can’t perform that action at this time.
0 commit comments