conftest.py
python
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12
Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71…
Human
minor
⚠ breaking
9 days ago
| 1 | from pathlib import Path |
| 2 | import json |
| 3 | import os |
| 4 | import subprocess |
| 5 | |
| 6 | import pytest |
| 7 | |
| 8 | KIT = Path(__file__).resolve().parents[2] |
| 9 | OK = KIT / 'cli/ok' |
| 10 | |
| 11 | |
| 12 | def command(*args, cwd=None, env=None, executable=OK, input=None): |
| 13 | return subprocess.run([str(executable), *map(str, args)], cwd=cwd or KIT, |
| 14 | env=dict(os.environ, **(env or {})), input=input, |
| 15 | capture_output=True, text=True, timeout=20) |
| 16 | |
| 17 | |
| 18 | def seed(path): |
| 19 | path.mkdir() |
| 20 | for args in (['init', '-b', 'main'], ['config', 'user.name', 'Fixture'], |
| 21 | ['config', 'user.email', '[email protected]'], |
| 22 | ['-c', 'core.hooksPath=/dev/null', 'commit', '--allow-empty', '-m', 'seed']): |
| 23 | subprocess.run(['/usr/bin/git', '-C', str(path), *args], check=True, capture_output=True) |
| 24 | return path.resolve() |
| 25 | |
| 26 | |
| 27 | @pytest.fixture |
| 28 | def repo(tmp_path): |
| 29 | root = seed(tmp_path / 'similar-kit') |
| 30 | result = command('-C', root, 'init', '--hooks') |
| 31 | assert result.returncode == 0, result.stderr |
| 32 | return root |
| 33 | |
| 34 | |
| 35 | @pytest.fixture |
| 36 | def pair(repo, tmp_path): |
| 37 | other = seed(tmp_path / 'similar-kit-copy') |
| 38 | result = command('-C', other, 'init', '--hooks') |
| 39 | assert result.returncode == 0, result.stderr |
| 40 | for root in (repo, other): |
| 41 | write_action(root, 'Unique content for ' + root.name + '\n') |
| 42 | return repo, other |
| 43 | |
| 44 | |
| 45 | def status(root): |
| 46 | result = command('-C', root, 'status', '--json') |
| 47 | assert result.returncode == 0, result.stderr + result.stdout |
| 48 | return json.loads(result.stdout) |
| 49 | |
| 50 | |
| 51 | def write_action(root, prompt, **overrides): |
| 52 | state = status(root) |
| 53 | (root / 'prompt.txt').write_text(prompt) |
| 54 | values = dict(repo_id=state['repository']['id'], branch='main', lane='product', |
| 55 | model='GPT-6 Astra', action_id='SAME-ACTION', action_kind='implement', |
| 56 | expect_next=state['next_sha256'], prompt_file='prompt.txt') |
| 57 | values.update(overrides) |
| 58 | args = [x for key, val in values.items() for x in ('--' + key.replace('_', '-'), val)] |
| 59 | result = command('-C', root, 'next-write', *args) |
| 60 | if not overrides: |
| 61 | assert result.returncode == 0, result.stderr |
| 62 | return result |
File History
1 commit
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12
Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71…
Human
minor
⚠
9 days ago