Merge ~dbungert/curtin:integration-run-bm-debug into curtin:master

Proposed by Dan Bungert
Status: Needs review
Proposed branch: ~dbungert/curtin:integration-run-bm-debug
Merge into: curtin:master
Diff against target: 51 lines (+32/-1)
1 file modified
tests/integration/test_block_meta.py (+32/-1)
Reviewer Review Type Date Requested Status
Chris Peterson Approve
Server Team CI bot continuous-integration Approve
Olivier Gayot Pending
curtin developers Pending
Review via email: mp+460790@code.launchpad.net

Commit message

integration: add run_bm(..., debug=True) helper

The debug argument for run_bm allows for running curtin outside of the
integration test itself, but with all the setup being done for you by
the integration test. This means that custom tweaks can be done to the
curtin code before running, setting breakpoints, etc.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Peterson (cpete) wrote :

Very nice! One question about the kwargs bit but I looked through all the calls to run_bm and it doesn't look like it's really used anyways.

review: Approve

Unmerged commits

942bb97... by Dan Bungert

integration: add run_bm(..., debug=True) helper

The debug argument for run_bm allows for running curtin outside of the
integration test itself, but with all the setup being done for you by
the integration test. This means that custom tweaks can be done to the
curtin code before running, setting breakpoints, etc.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
index 2fc7c7d..1867f63 100644
--- a/tests/integration/test_block_meta.py
+++ b/tests/integration/test_block_meta.py
@@ -10,6 +10,7 @@ from pathlib import Path
10import re10import re
11import sys11import sys
12from typing import Optional12from typing import Optional
13import tempfile
13from unittest import skipIf14from unittest import skipIf
14import yaml15import yaml
1516
@@ -267,7 +268,37 @@ class TestBlockMeta(IntegrationTestCase):
267 '-c', config_path, 'block-meta', '--testmode', 'custom',268 '-c', config_path, 'block-meta', '--testmode', 'custom',
268 *args,269 *args,
269 ]270 ]
270 util.subp(cmd, env=cmd_env, **kwargs)271
272 # Set debug=True to halt the integration test and run curtin manually,
273 # with the integration tests having setup the environment for you.
274 # To see the script name run with "pytest-3 -s", or look at fp.name.
275 if not kwargs.pop('debug', False):
276 util.subp(cmd, env=cmd_env, **kwargs)
277 return
278
279 env = cmd_env.copy()
280 env.update(PYTHONPATH=os.getcwd())
281 import pprint
282 pp = pprint.PrettyPrinter(indent=4)
283 code = '''\
284#!/usr/bin/python3
285import subprocess
286cmd = {cmd}
287env = {env}
288subprocess.run(cmd, env=env)
289'''.format(cmd=pp.pformat(cmd), env=pp.pformat(env))
290
291 opts = dict(mode='w', delete=False, suffix='.py')
292 with tempfile.NamedTemporaryFile(**opts) as fp:
293 fp.write(code)
294 try:
295 os.chmod(fp.name, 0o700)
296 print('\nThe integration test is paused.')
297 print('Use script {} to run curtin manually.'.format(fp.name))
298 import pdb
299 pdb.set_trace()
300 finally:
301 os.unlink(fp.name)
271302
272 def _test_default_offsets(self, ptable, version, sector_size=512):303 def _test_default_offsets(self, ptable, version, sector_size=512):
273 psize = 40 << 20304 psize = 40 << 20

Subscribers

People subscribed via source and target branches