Skip to content

Commit 7edaa1f

Browse files
committed
As @jameshcorbett suggests, the problem is better fixed in ci_runner.py
1 parent 939047f commit 7edaa1f

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

tests/ci_runner.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ def run(*args: str, cwd: Optional[str] = None) -> str:
5959
return p.stdout
6060

6161

62-
def get_conf(conf: Dict[str, str], name: str) -> str:
62+
def get_conf(conf: Dict[str, str], name: str, default: Optional[str] = None) -> str:
6363
if name not in conf:
64-
raise KeyError('Missing configuration option "%s"' % name)
64+
if default is not None:
65+
return default
66+
else:
67+
raise KeyError('Missing configuration option "%s"' % name)
6568
return conf[name]
6669

6770

@@ -118,7 +121,7 @@ def run_branch_tests(conf: Dict[str, str], dir: Path, run_id: str, clone: bool =
118121
args.append('--branch-name-override')
119122
args.append(fake_branch_name)
120123
for opt in ['maintainer_email', 'executors', 'server_url', 'key', 'max_age',
121-
'custom_attributes', 'minimal_uploads']:
124+
'custom_attributes']:
122125
try:
123126
val = get_conf(conf, opt)
124127
args.append('--' + opt.replace('_', '-'))
@@ -128,6 +131,11 @@ def run_branch_tests(conf: Dict[str, str], dir: Path, run_id: str, clone: bool =
128131
# old test cycles from working, if their configs don't contain
129132
# the new options
130133
pass
134+
135+
val = get_conf(conf, 'minimal_uploads', 'false')
136+
if val == 'true':
137+
args.append('--minimal-uploads')
138+
131139
cwd = (dir / 'code') if clone else Path('.')
132140
env = dict(os.environ)
133141
env['PYTHONPATH'] = str(Path('.').resolve() / '.packages') \
@@ -175,7 +183,7 @@ def patch_file(file_name: str) -> None:
175183
# when invoking a subprocess, bash stores the location where
176184
# it's supposed to continue parsing from, so it's a good idea
177185
# to to not move things around
178-
line = line.replace(OLD_REPO, NEW_REPO)[:-1] + ' \n'
186+
line = line.rstrip('\n').replace(OLD_REPO, NEW_REPO) + ' \n'
179187
outf.write(line)
180188
os.chmod(file_name + '._new_', os.stat(file_name).st_mode)
181189
os.rename(file_name + '._new_', file_name)

tests/conftest.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def pytest_addoption(parser):
6666
help='Pretend that the current git branch is this value.')
6767
parser.addoption('--custom-attributes', action='store', default=None,
6868
help='A set of custom attributes to pass to jobs.')
69-
parser.addoption('--minimal-uploads', action='store', default=False,
69+
parser.addoption('--minimal-uploads', action='store_true', default=False,
7070
help='Enables minimal uploads mode, which restricts the information that '
7171
'is uploaded to the test aggregation server. ')
7272

@@ -270,10 +270,6 @@ def _get_id(config):
270270
raise ValueError('Invalid value for --id argument: "%s"' % id)
271271

272272

273-
def _get_bool_option(config, name, default='false'):
274-
return config.getoption(name, default=default).lower() == 'true'
275-
276-
277273
def _run(*args) -> str:
278274
process = subprocess.run(args, check=False, text=True,
279275
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -479,7 +475,7 @@ def _mk_test_fname(data):
479475

480476

481477
def _save_or_upload(config, data):
482-
minimal = _get_bool_option(config, 'minimal_uploads')
478+
minimal = config.getoption('minimal_uploads')
483479
save = config.getoption('save_results')
484480
upload = config.getoption('upload_results')
485481
if upload and minimal:
@@ -566,7 +562,7 @@ def _upload_report(config, data):
566562
env = config.option.environment
567563

568564
url = config.getoption('server_url')
569-
minimal = _get_bool_option(config, 'minimal_uploads')
565+
minimal = config.getoption('minimal_uploads')
570566
if minimal:
571567
data = _sanitize(data)
572568
resp = requests.post('%s/result' % url, json={'id': env['config']['id'],

0 commit comments

Comments
 (0)