curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #03314
[Merge] ~dbungert/curtin:integration-run-bm-debug into curtin:master
Dan Bungert has proposed merging ~dbungert/curtin:integration-run-bm-debug into curtin:master.
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.
Requested reviews:
curtin developers (curtin-dev)
For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/460790
--
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:integration-run-bm-debug into curtin:master.
diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
index ec9b33c..54251ee 100644
--- a/tests/integration/test_block_meta.py
+++ b/tests/integration/test_block_meta.py
@@ -10,6 +10,7 @@ from pathlib import Path
import re
import sys
from typing import Optional
+import tempfile
from unittest import skipIf
import yaml
@@ -267,7 +268,37 @@ class TestBlockMeta(IntegrationTestCase):
'-c', config_path, 'block-meta', '--testmode', 'custom',
*args,
]
- util.subp(cmd, env=cmd_env, **kwargs)
+
+ # Set debug=True to halt the integration test and run curtin manually,
+ # with the integration tests having setup the environment for you.
+ # To see the script name run with "pytest-3 -s", or look at fp.name.
+ if not kwargs.pop('debug', False):
+ util.subp(cmd, env=cmd_env, **kwargs)
+ return
+
+ env = cmd_env.copy()
+ env.update(PYTHONPATH=os.getcwd())
+ import pprint
+ pp = pprint.PrettyPrinter(indent=4)
+ code = '''\
+#!/usr/bin/python3
+import subprocess
+cmd = {cmd}
+env = {env}
+subprocess.run(cmd, env=env)
+'''.format(cmd=pp.pformat(cmd), env=pp.pformat(env))
+
+ opts = dict(mode='w', delete=False, suffix='.py')
+ with tempfile.NamedTemporaryFile(**opts) as fp:
+ fp.write(code)
+ try:
+ os.chmod(fp.name, 0o700)
+ print('\nThe integration test is paused.')
+ print('Use script {} to run curtin manually.'.format(fp.name))
+ import pdb
+ pdb.set_trace()
+ finally:
+ os.unlink(fp.name)
def _test_default_offsets(self, ptable, version, sector_size=512):
psize = 40 << 20
Follow ups