Index `first`, apply `change` to the files, sync, and compare with a fresh index of the result.
(first: Record<string, string>, change: (root: string) => void)
| 596 | |
| 597 | /** Index `first`, apply `change` to the files, sync, and compare with a fresh index of the result. */ |
| 598 | async function converges(first: Record<string, string>, change: (root: string) => void): Promise<{ synced: CodeGraph; root: string }> { |
| 599 | const { root, cg } = await indexed(first); |
| 600 | change(root); |
| 601 | await cg.sync(); |
| 602 | const fresh = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-parameter-flow-fresh-')); |
| 603 | roots.push(fresh); |
| 604 | fs.cpSync(root, fresh, { recursive: true, filter: (src) => !src.includes('.codegraph') }); |
| 605 | const rebuilt = await CodeGraph.init(fresh, { index: true }); |
| 606 | open.push(rebuilt); |
| 607 | expect(graphOf(cg)).toEqual(graphOf(rebuilt)); |
| 608 | return { synced: cg, root }; |
| 609 | } |
| 610 | |
| 611 | it('runs for a sync that touches the language, and no other', async () => { |
| 612 | const { root, cg } = await indexed({ ...BASE, 'lib/app.ts': 'export const a = 1;\n' }); |