test(integration): extend prototype-method-resolution to cover both engines#1428
test(integration): extend prototype-method-resolution to cover both engines#1428carlos-alm wants to merge 5 commits into
Conversation
…ngines (#1421) Remove the WASM-only engine pin (added in #1400) and restructure the test to build the fixture with both engines in separate temp dirs. The native extractor already implements `match_js_prototype_methods` (landed in #1331); the pin was a temporary workaround until the binary could be verified. All 6 assertions (3 WASM + 3 native) pass with the locally compiled binary. Closes #1421
|
Claude finished @carlos-alm's task —— View job PR Review
Root Cause AnalysisProblem Being Solved: PR #1400 had pinned Why This Approach: Structurally mirrors the established dual-engine test pattern from Risk Assessment: Low. This is a pure test expansion — no production code changes. The only risk would be if the native extractor is not yet correct and the tests fail in CI. The PR description claims all 6 pass; CI will be the ground truth. Phase 2: Configuration Change DetectionNo linting rules, TypeScript flags, test timeouts, or build configuration were touched. No concerns. Phase 3: Test IntegrityThe assertions are at least as strict as before. The original test had 3 assertions for WASM; this PR keeps all 3 and adds 3 identical assertions for native. No assertion was softened, skipped, or made conditional. One minor observation: Line 52 — native engine not explicitly pinned: await buildGraph(tmpNative, { incremental: false, skipRegistry: true, engine: 'native' });This correctly passes Line 98 — WASM expect(edges.find((e) => e.tgt === 'Dog.bark')).toBeDefined();This only checks that some edge targets This is a minor quality point, not a blocker. Phase 4: Code QualityThe test is clean and follows the established pattern faithfully. The No concerns. Phase 5: Backlog Compliance
Final Assessment |
Greptile SummaryThis PR upgrades the
Confidence Score: 5/5Safe to merge — this is a well-scoped test-only change that removes a documented workaround and adds coverage for an engine that already ships the fix. The change touches only a single integration test file, adds no production code, and the dual-engine setup with parallel builds and tighter per-scope assertions is sound. The beforeAll/afterAll cleanup pattern is consistent with the rest of the test suite. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[beforeAll] --> B[mkdtempSync: cg-1317-wasm-]
A --> C[mkdtempSync: cg-1317-native-]
B --> D[writeFileSync proto.js]
C --> E[writeFileSync proto.js]
D --> F[Promise.all]
E --> F
F --> G[buildGraph tmpWasm - engine: wasm]
F --> H[buildGraph tmpNative - engine: native]
G --> I[WASM: graph.db]
H --> J[Native: graph.db]
I --> K[WASM: emits Dog.bark as method]
I --> L[WASM: d.bark → Dog.bark via proto.js scope]
I --> M[WASM: makeAndBark → Dog.bark inline-new]
J --> N[Native: emits Dog.bark as method]
J --> O[Native: d.bark → Dog.bark via proto.js scope]
J --> P[Native: makeAndBark → Dog.bark inline-new]
Reviews (6): Last reviewed commit: "Merge branch 'main' into fix/native-prot..." | Re-trigger Greptile |
| tmpWasm = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-wasm-')); | ||
| fs.writeFileSync(path.join(tmpWasm, 'proto.js'), FIXTURE_CODE); | ||
| await buildGraph(tmpWasm, { incremental: false, skipRegistry: true, engine: 'wasm' }); | ||
|
|
||
| tmpNative = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-native-')); | ||
| fs.writeFileSync(path.join(tmpNative, 'proto.js'), FIXTURE_CODE); | ||
| await buildGraph(tmpNative, { incremental: false, skipRegistry: true, engine: 'native' }); |
There was a problem hiding this comment.
The two
buildGraph calls in beforeAll run sequentially — the native build doesn't start until the WASM build finishes. Because both fixtures are written to separate temp dirs before either build begins, they can safely run in parallel with Promise.all, matching the pattern used in issue-1336-object-rest-param-resolution.test.ts. Parallelizing reduces total test-setup wall time.
| tmpWasm = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-wasm-')); | |
| fs.writeFileSync(path.join(tmpWasm, 'proto.js'), FIXTURE_CODE); | |
| await buildGraph(tmpWasm, { incremental: false, skipRegistry: true, engine: 'wasm' }); | |
| tmpNative = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-native-')); | |
| fs.writeFileSync(path.join(tmpNative, 'proto.js'), FIXTURE_CODE); | |
| await buildGraph(tmpNative, { incremental: false, skipRegistry: true, engine: 'native' }); | |
| tmpWasm = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-wasm-')); | |
| fs.writeFileSync(path.join(tmpWasm, 'proto.js'), FIXTURE_CODE); | |
| tmpNative = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1317-native-')); | |
| fs.writeFileSync(path.join(tmpNative, 'proto.js'), FIXTURE_CODE); | |
| await Promise.all([ | |
| buildGraph(tmpWasm, { incremental: false, skipRegistry: true, engine: 'wasm' }), | |
| buildGraph(tmpNative, { incremental: false, skipRegistry: true, engine: 'native' }), | |
| ]); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Done. Both buildGraph calls now run concurrently via Promise.all — the fixture files are written to their separate temp dirs before either build starts, so there is no shared state and the parallelization is safe. The d.bark() assertions have also been tightened to assert src === "proto.js" (the file-level scope node that owns the module-level call), matching the precision of the makeAndBark assertions.
…assertions (#1428) - Run both WASM and native buildGraph calls concurrently via Promise.all; fixtures are already written to separate dirs before either build starts - Pin d.bark() assertions to src === 'proto.js' (the file-level scope node) so the check no longer matches any edge that targets Dog.bark
|
Claude finished @carlos-alm's task —— View job Review complete
The file is already in its final form. Both suggestions from the Greptile review have been addressed:
Tightened The test is clean and matches the established dual-engine pattern. Nothing further needed. |
Summary
issue-1336-object-rest-param-resolution.test.tsmatch_js_prototype_methodsincrates/codegraph-core/src/extractors/javascript.rsTest plan
Dog.barkas a method definitiond.bark()toDog.barkvia typeMap receiver type(new Dog(...)).bark()inline-new receiver call toDog.barkDog.barkas a method definitiond.bark()toDog.barkvia typeMap receiver type(new Dog(...)).bark()inline-new receiver call toDog.barkCloses #1421