test(release): run the publication tests through the gh that PATH resolves
The release_body fixture made shutil.which miss, so render-builds-table.py fell back to bare "gh" and the tests passed even with the PATH/PATHEXT lookup removed. No test covered that fix after test_tag_builds_summary.py was deleted on main. The fixture now resolves gh to a fake path, and the fake accepts only that path for both the view and the edit. A mutant that goes back to bare "gh" fails 9 of 18 tests, and so does one where only the edit uses bare "gh". The old fixture passed 18/18 on both. Found by the sol-loop review on #159146.
This commit is contained in:
@@ -25,17 +25,19 @@ _SPEC.loader.exec_module(rbt)
|
||||
def release_body(monkeypatch):
|
||||
state = {'body': '# Notes\n\n<!-- HERMES_BUILDS_TABLE -->\n\n## Changes\n- x\n', 'edits': []}
|
||||
|
||||
# gh as PATH and PATHEXT resolve it (gh.cmd on Windows); both calls must run that path.
|
||||
resolved = '/fake/bin/gh.cmd'
|
||||
|
||||
def gh(argv, **kwargs):
|
||||
if argv[:3] == ['gh', 'release', 'view']:
|
||||
if argv[:3] == [resolved, 'release', 'view']:
|
||||
return subprocess.CompletedProcess(argv, 0, json.dumps({'body': state['body']}), '')
|
||||
assert argv[:3] == ['gh', 'release', 'edit']
|
||||
assert argv[:3] == [resolved, 'release', 'edit']
|
||||
state['body'] = kwargs['input']
|
||||
state['edits'].append(state['body'])
|
||||
return subprocess.CompletedProcess(argv, 0, '', '')
|
||||
|
||||
monkeypatch.setattr(rbt.subprocess, 'run', gh)
|
||||
# The fake above is the gh; never resolve a host's real one.
|
||||
monkeypatch.setattr(rbt.shutil, 'which', lambda _name: None)
|
||||
monkeypatch.setattr(rbt.shutil, 'which', lambda name: resolved if name == 'gh' else None)
|
||||
return state
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user