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
1diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
2index 2fc7c7d..1867f63 100644
3--- a/tests/integration/test_block_meta.py
4+++ b/tests/integration/test_block_meta.py
5@@ -10,6 +10,7 @@ from pathlib import Path
6 import re
7 import sys
8 from typing import Optional
9+import tempfile
10 from unittest import skipIf
11 import yaml
12
13@@ -267,7 +268,37 @@ class TestBlockMeta(IntegrationTestCase):
14 '-c', config_path, 'block-meta', '--testmode', 'custom',
15 *args,
16 ]
17- util.subp(cmd, env=cmd_env, **kwargs)
18+
19+ # Set debug=True to halt the integration test and run curtin manually,
20+ # with the integration tests having setup the environment for you.
21+ # To see the script name run with "pytest-3 -s", or look at fp.name.
22+ if not kwargs.pop('debug', False):
23+ util.subp(cmd, env=cmd_env, **kwargs)
24+ return
25+
26+ env = cmd_env.copy()
27+ env.update(PYTHONPATH=os.getcwd())
28+ import pprint
29+ pp = pprint.PrettyPrinter(indent=4)
30+ code = '''\
31+#!/usr/bin/python3
32+import subprocess
33+cmd = {cmd}
34+env = {env}
35+subprocess.run(cmd, env=env)
36+'''.format(cmd=pp.pformat(cmd), env=pp.pformat(env))
37+
38+ opts = dict(mode='w', delete=False, suffix='.py')
39+ with tempfile.NamedTemporaryFile(**opts) as fp:
40+ fp.write(code)
41+ try:
42+ os.chmod(fp.name, 0o700)
43+ print('\nThe integration test is paused.')
44+ print('Use script {} to run curtin manually.'.format(fp.name))
45+ import pdb
46+ pdb.set_trace()
47+ finally:
48+ os.unlink(fp.name)
49
50 def _test_default_offsets(self, ptable, version, sector_size=512):
51 psize = 40 << 20

Subscribers

People subscribed via source and target branches