mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-12-06 00:37:26 +00:00
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / Classify release event (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / ci (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
* test(java): compare overload resolution with javac in CI * test(conformance): share call resolution reports across tools * test(java): cover the overload conversion matrix with javac (#4057) Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com> * test(java): run Java-backed fixtures in dedicated CI shards * test(java): replace handwritten resolution cases with javac comparisons * test(java): compare lambda and receiver fixtures against javac * fix(ci): restore Java test evidence and use locked toolchain commands * test(skills): fail incomplete CLI generation checks (#4056) * test(java): compare method references with javac * fix(java): resolve qualified bases and static wildcard overloads * test(java): preserve declared dollar names in compiler comparisons * fix(java): preserve distinct call targets for colliding type names * fix(conformance): resolve private nested bases and retain overload selections * fix(java): distinguish variadic overloads in the published graph * fix(java): match javac for nested types, imports and initializer calls * Move Java fixture testing out of Vitest and into compiler conformance * Verify Java graph endpoints and leave call selection to javac * Match javac for annotated bases and legal static imports * Resolve nested Java member types and clean up failed conformance fixtures * Preserve qualified Java bases across unrelated static wildcard imports * test(java): run inline source fixtures in compiler conformance * test(conformance): check fetch callers, lexical bindings and cleanup * test(java): move virtual source and text fixtures into conformance * fix(java): resolve imported member types and qualified base collisions * Match javac constructor overloads and preserve Java conformance coverage * Compare recovered Java inheritance with javac in the conformance runner * Run the Java query compilation smoke test in native conformance * Clarify Java conformance expectations and check populated suites * Write javac conformance records as UTF-8 on Windows * Compile the Java conformance tools for SonarCloud analysis * Compare Java method implementation edges with javac * Resolve fixture writers and inherited Java methods in their lexical context * Resolve qualified Java bases through their accessible type members * Match local qualified Java bases and bounded varargs identities to javac * Match Java call resolution to javac across the conformance corpus Preserve generic declaration identity, follow nested call results, and type lambda aliases and enhanced-loop variables in their declaration scopes. Report proven JDK call targets without creating workspace edges. Compare every selected source and binary call against javac and remove the twelve mismatch lists. * Compare Java recovery targets as sets and check empty destination addresses Keep repeated uses of the same declaration equivalent across graph producers while detecting missing and extra targets. Check raw destination addresses and document the source and classpath inputs to the compiler comparison. * Avoid extra native parent walks while capturing Java call facts Index lambda origins by spelling before walking lexical scopes, and only check value shadowing for qualifiers rooted in an identifier. This restores the capture traversal budget for anonymous classes while preserving javac call targets. * Refresh the Java capture fingerprint for corrected fixture comments The module captures include the revised comments and the following declarations move to earlier lines. Both emitters produce the same 4,288 capture groups when given the same fixture revision. * Preserve Java conformance assertions and use trusted fixture paths Use explicit canonical sort orders, require missing evidence to fail assertions, and keep pending query results in the replay cache. Resolve the Git executable independently of the test repository and isolate the Spring workspace per test. * Resolve inherited Java members through the scoped superclass * Reuse validated analyzer build hashes for parser cache identity * Resolve SonarCloud findings in Java resolution and compiler conformance * Align Java compiler tool packages and pin benchmark baselines to the tested merge * Honor wildcard method families and fixture ownership in Java conformance * fix(java): resolve inherited and annotation member types against javac Keep workspace links tied to import declarations and compare Java varargs overloads through comments. Make generated-project selection, method metadata checks and Java fixture ownership explicit in conformance. * fix(java): resolve bounded and imported bases during dispatch Keep the type selected from a qualified heritage clause available during overload resolution. Compare annotated bounds, inherited static imports, and String.valueOf arguments directly with javac. Detect Java fixture paths on either side of a filesystem rename. * Conform Java method visibility and wildcard lambda bounds to javac Compare method access at source positions, recognize CommonJS fixture reads, and preserve diagnostics when native conformance setup fails. * Match javac for qualified member overloads and selective call diagnostics * Track reassigned Java fixture paths at their point of use * Respect Java visibility and Node path semantics in conformance checks * Align Java graph benchmarks with compiler-verified visibility * Record the public Java record accessor in the mixed-provider benchmark * Address remaining Java conformance analysis findings Keep repository import scans sequential, simplify Java header and overload resolution, and reuse Spring conformance measurements. Preserve compiler comparison assertions and emitted fixture contents. * Match javac on nested binary names, null factories and recovered calls Preserve the qualified annotation target in workspace links. Compare valid and invalid arguments separately so an attributed recovery symbol cannot mask a failed invocation. --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
161 lines
5.1 KiB
TypeScript
161 lines
5.1 KiB
TypeScript
/**
|
|
* Library and runtime receivers name the program boundary (#3498 triage).
|
|
*
|
|
* A call whose receiver is a host global (`document`), a stdlib import (`os`,
|
|
* `std`), a platform package root (`java.util`) or a value declared as a library
|
|
* type (`Dictionary<…>`) reaches code no index contains. Its drop is
|
|
* completeness, not uncertainty, so it must be recorded `external` — and the
|
|
* same spelling must keep hedging wherever the program binds the name itself.
|
|
*
|
|
* The classifier unit tests (`unresolved-receivers.test.ts`) pin the verdicts on
|
|
* real scope extraction. This exercises the wiring they deliberately skip: each
|
|
* provider's data reaching the pass through `runScopeResolution`, for every
|
|
* language that supplies it, in one multi-language repository.
|
|
*/
|
|
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import {
|
|
getResolutionOutcomes,
|
|
runPipelineFromRepo,
|
|
writeFixtureRepo,
|
|
type PipelineResult,
|
|
} from '../../integration/resolvers/helpers.js';
|
|
|
|
const FILES: Record<string, string> = {
|
|
'web/dom.ts': `export function attach(link: unknown): void {
|
|
document.body.appendChild(link);
|
|
}
|
|
|
|
export function navigate(path: string): void {
|
|
window.history.pushState(null, '', path);
|
|
}
|
|
|
|
export function decode(token: string): string {
|
|
return Buffer.from(token, 'base64').toString();
|
|
}
|
|
|
|
export function typedParameter(document: Doc): void {
|
|
document.body.render();
|
|
}
|
|
`,
|
|
'web/interop.js': `export function invoke() { window.app.interopSave(); }\n`,
|
|
'web/program.ts': `export class Service { interopSave(): void {} }\n`,
|
|
'web/env.ts': `export const API_BASE = process.env.API_BASE || '';
|
|
export const ENDPOINT = process.env.SERVICE_URL || '';
|
|
`,
|
|
'py/settings.py': `import os
|
|
from pathlib import Path
|
|
|
|
|
|
def configure():
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
|
|
|
|
|
def base_dir():
|
|
return Path(__file__).resolve()
|
|
|
|
|
|
def shadowed(os):
|
|
os.environ.update()
|
|
`,
|
|
'zig/src/sorter.zig': `const std = @import("std");
|
|
|
|
pub fn sortItems(items: []u32) void {
|
|
std.sort.pdq(u32, items, {}, lessThan);
|
|
}
|
|
|
|
fn lessThan(_: void, a: u32, b: u32) bool {
|
|
return a < b;
|
|
}
|
|
`,
|
|
|
|
'cs/App.cs': `using System.Collections.Generic;
|
|
|
|
namespace Demo
|
|
{
|
|
public class User { }
|
|
|
|
public class App
|
|
{
|
|
private Dictionary<string, User> data = new Dictionary<string, User>();
|
|
|
|
public void Greet()
|
|
{
|
|
System.Console.WriteLine("hello");
|
|
}
|
|
|
|
public void ReadKeys()
|
|
{
|
|
foreach (var key in this.data.Keys) { }
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
'kt/src/Worker.kt': `class Worker {
|
|
fun run() {
|
|
System.out.println("working")
|
|
}
|
|
}
|
|
`,
|
|
};
|
|
|
|
describe('Library and runtime receivers name the program boundary (#3498)', () => {
|
|
let repoDir: string;
|
|
let result: PipelineResult;
|
|
|
|
beforeAll(async () => {
|
|
repoDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gn-receiver-origin-library-'));
|
|
writeFixtureRepo(repoDir, FILES);
|
|
result = await runPipelineFromRepo(repoDir, () => {}, {});
|
|
}, 120000);
|
|
|
|
afterAll(() => {
|
|
if (repoDir !== undefined) fs.rmSync(repoDir, { recursive: true, force: true });
|
|
});
|
|
|
|
const dropsAt = (filePath: string, line: number, name: string) =>
|
|
getResolutionOutcomes(result).filter(
|
|
(outcome) =>
|
|
outcome.kind === 'suppressed' &&
|
|
outcome.reason === 'receiver-unresolved' &&
|
|
outcome.filePath === filePath &&
|
|
outcome.range.startLine === line &&
|
|
outcome.name === name,
|
|
);
|
|
|
|
it.each([
|
|
['a DOM global', 'web/dom.ts', 2, 'appendChild'],
|
|
['a browser global', 'web/dom.ts', 6, 'pushState'],
|
|
['the Node Buffer global', 'web/dom.ts', 10, 'toString'],
|
|
['the Node process global', 'web/env.ts', 2, 'SERVICE_URL'],
|
|
['a Python stdlib namespace import', 'py/settings.py', 6, 'setdefault'],
|
|
['a Python stdlib named import', 'py/settings.py', 10, 'resolve'],
|
|
['the Zig standard library', 'zig/src/sorter.zig', 4, 'pdq'],
|
|
|
|
['the C# System namespace', 'cs/App.cs', 13, 'WriteLine'],
|
|
['a C# field declared as a library type', 'cs/App.cs', 18, 'Keys'],
|
|
['Kotlin java.lang.System', 'kt/src/Worker.kt', 3, 'println'],
|
|
] as const)('records a drop rooted at %s as external', (_label, filePath, line, name) => {
|
|
const drops = dropsAt(filePath, line, name);
|
|
expect(drops.length).toBeGreaterThan(0);
|
|
expect(drops).toEqual(drops.map(() => expect.objectContaining({ receiverOrigin: 'external' })));
|
|
});
|
|
|
|
it.each([
|
|
['a TypeScript parameter named document', 'web/dom.ts', 14, 'render'],
|
|
['a Python parameter named os', 'py/settings.py', 14, 'update'],
|
|
['a same-named program declaration', 'web/env.ts', 1, 'API_BASE'],
|
|
[
|
|
'a TypeScript member used through a JavaScript library receiver',
|
|
'web/interop.js',
|
|
1,
|
|
'interopSave',
|
|
],
|
|
] as const)('keeps a drop on %s hedged', (_label, filePath, line, name) => {
|
|
const drops = dropsAt(filePath, line, name);
|
|
expect(drops.length).toBeGreaterThan(0);
|
|
expect(drops).not.toContainEqual(expect.objectContaining({ receiverOrigin: 'external' }));
|
|
});
|
|
});
|