2"""Compare partial API path analysis with real Ford-style todo marks under eval."""
4from pathlib import Path
11root = Path(__file__).resolve().parent.parent
12parser = argparse.ArgumentParser(description=__doc__)
13parser.add_argument('--lib', default=str(root / 'jibb-dev/lib/jibb.hoon'))
14parser.add_argument('--update', action='store_true')
15args = parser.parse_args()
16fixture = root / 'tests/type-api-paths'
17names = {'sur': 'todo-sur', 'action': 'todo-action', 'todos': 'todos',
18 'update': 'todo-update', 'item': 'todo-item', 'api': 'api',
19 'missing-decl': 'missing-decl', 'value-clash': 'value-clash',
20 'poke-clash': 'poke-clash', 'scry': 'scry', 'scry-bad': 'scry-bad'}
21reader = (root / 'jibb-dev/lib/jibb-import.hoon').read_text()
22tests = (root / 'tests/lib/jibb-api-paths.hoon').read_text()
23tests = tests[tests.index('\n|%\n') + 1:]
24expression = ('=/ jibb .\n=/ jibb-import\n' + reader + '\n' +
25 ''.join('=/ ' + name + '=wain (to-wain:format ' + name + '-text)\n' for name in names) +
26 '=/ expected=wain ~\n=/ bridge\n' + tests +
27 '\n(of-wain:format (fixture-output:bridge prelude internal ' +
28 ' '.join(name + '-text' for name in names) + '))\n')
29with tempfile.TemporaryDirectory(prefix='jibb-type-api-paths-') as tmp:
30 program = Path(tmp) / 'bridge.hoon'
31 program.write_text(expression)
32 command = [str(root / 'tools/hoon'), '--lib', args.lib, '--raw', '-f', str(program),
33 '--cord', 'prelude=' + str(root / 'jibb-dev/lib/jibb/prelude.jibb'),
34 '--cord', 'internal=' + str(root / 'jibb-dev/lib/jibb/internal.jibb')]
35 for name, filename in names.items():
36 command += ['--cord', name + '-text=' + str(fixture / (filename + '.txt'))]
37 result = subprocess.run(command, stdout=subprocess.PIPE)
39 sys.exit(result.returncode)
40expected_path = fixture / 'expected.txt'
42 expected_path.write_bytes(result.stdout)
43 print('updated partial API path analysis golden')
45expected = expected_path.read_bytes()
46if result.stdout != expected:
47 sys.stderr.writelines(difflib.unified_diff(
48 expected.decode().splitlines(keepends=True),
49 result.stdout.decode().splitlines(keepends=True),
50 fromfile='expected.txt', tofile='actual paths'))
52print('partial API path analysis golden passed')
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list