mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-10 22:43:40 +00:00
* fix(lbug): resolve non-ASCII paths to 8.3 short form on Windows (#1811) KuzuDB's native C++ layer uses ANSI file APIs (fopen) on Windows. When the repo path contains CJK or other non-ASCII characters, the UTF-8 bytes from Node.js are misinterpreted as the system's Active Code Page (e.g. GBK), producing a garbled path — "Error 3: The system cannot find the path specified." Add `toNativeSafePath()` which converts non-ASCII paths to their Windows 8.3 short-name form (all-ASCII) before passing them to the native layer. Applied to both the database open path and the COPY CSV paths. No-ops on non-Windows and on all-ASCII paths. Closes #1811 * test(lbug): add unit + integration tests for non-ASCII path handling (#1811) - Unit tests for toNativeSafePath: ASCII passthrough, non-Windows no-op, Windows short-path conversion, nonexistent-path fallback - Integration test: full initLbug + loadGraphToLbug round-trip with CJK characters in the storage path — runs on all platforms - Fix toNativeSafePath to reject cmd.exe output containing '?' chars (replacement for unrepresentable Unicode in the console code page) - Register integration test in vitest lbug-db project and cross-platform-tests.ts matrix * chore(autofix): apply prettier + eslint fixes via /autofix command * feat(lbug): junction fallback, tmpdir CSV staging, pool-adapter coverage (#1811) U1+U4: toNativeSafePath now tries 8.3 short path → NTFS junction fallback → diagnostic warning. Junctions target path.dirname(p) and reconstruct the leaf. Handles EEXIST races. Registers cleanup on exit/SIGTERM/SIGINT. Orphan scan on first call removes stale junctions from prior crashes. U2: loadGraphToLbug redirects csvDir to os.tmpdir() when storagePath contains non-ASCII on Windows, avoiding non-ASCII characters in COPY FROM paths entirely. U3: All 4 createLbugDatabase call sites in pool-adapter.ts now wrap dbPath with toNativeSafePath. * fix(test): fix CI failures from toNativeSafePath addition (#1811) - Fix lbug-non-ascii-path integration test: use CodeRelation (actual relationship table name) instead of CALLS - Add toNativeSafePath to lbug-config.js mocks in pool-wal-recovery and lbug-pool-win-fts-probe tests — pool-adapter now imports it * fix(lbug): sanitize path before cmd.exe shell expansion (CodeQL) Reject paths containing cmd.exe metacharacters (" % | & < > ^) before interpolating into the `for %I` short-path command. Prevents command injection via crafted path names. * fix(lbug): address code review findings in non-ASCII path implementation - U1: Use process.exit(0) on Windows instead of process.kill re-raise (SIGTERM forcefully kills on Windows, handlers never fire) - U2: Pass safePath to openWithLockRetry so sidecar sweep targets the path KuzuDB actually opened, not the original non-ASCII path - U3: Skip junction creation in worker threads (isMainThread guard) to prevent junction leaks from pool-adapter workers - U4: Replace existsSync with lstatSync in orphan scan to avoid 30s blocking on unreachable UNC network targets * chore(autofix): apply prettier + eslint fixes via /autofix command * fix(lbug): correct SIGTERM exit code and run Prettier (#1811) - Use exit code 143 (SIGTERM) / 130 (SIGINT) on Windows instead of 0 so termination is not masked as success - Run Prettier to fix formatting (CI Gate blocker) * fix(lbug): eliminate CodeQL command-injection taint in tryShortPath Pass the path via GITNEXUS_SP environment variable instead of interpolating it into the cmd.exe command string. The FOR loop reads %GITNEXUS_SP% from the environment, so the command text is entirely static — no user-controlled data in the shell command. Also removes CMD_UNSAFE_RE since the env var approach makes character-level sanitization unnecessary. --------- Co-authored-by: Test <test@example.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
136 lines
4.9 KiB
TypeScript
136 lines
4.9 KiB
TypeScript
/**
|
|
* Cross-platform test subset runner.
|
|
*
|
|
* Runs only the tests that exercise platform-sensitive behavior on
|
|
* Windows and macOS. The full suite runs on Ubuntu; this narrows the
|
|
* cross-platform matrix to tests that actually vary across OSes.
|
|
*
|
|
* Categories included:
|
|
* - Platform-specific logic (path.sep, process.platform guards)
|
|
* - Native addon loading (LadybugDB, tree-sitter)
|
|
* - Process spawning and shell behavior
|
|
* - Filesystem locking and temp-dir behavior
|
|
* - Worker threads (real, not mocked)
|
|
* - CLI end-to-end tests
|
|
*
|
|
* When adding a new test that uses platform-varying APIs (native addons,
|
|
* child_process with real spawning, filesystem locking, path.sep), add
|
|
* it to the appropriate section below.
|
|
*
|
|
* Usage:
|
|
* npx vitest run $(npx tsx scripts/cross-platform-tests.ts)
|
|
* # or via the package script:
|
|
* npm run test:cross-platform
|
|
*/
|
|
|
|
// Platform-specific logic tests — contain explicit process.platform guards
|
|
// or test behavior that differs across operating systems
|
|
const PLATFORM_LOGIC = [
|
|
'test/unit/setup.test.ts',
|
|
'test/unit/setup-jsonc.test.ts',
|
|
'test/unit/setup-codex.test.ts',
|
|
'test/unit/setup-antigravity.test.ts',
|
|
'test/unit/platform-capabilities.test.ts',
|
|
'test/unit/worker-pool-windows-quarantine.test.ts',
|
|
'test/unit/lbug-pool-win-fts-probe.test.ts',
|
|
'test/unit/repo-manager.test.ts',
|
|
'test/unit/repo-manager-finalize-invariant.test.ts',
|
|
'test/unit/hooks.test.ts',
|
|
'test/unit/cursor-hook.test.ts',
|
|
'test/unit/sidecar-recovery.test.ts',
|
|
'test/unit/pool-wal-recovery.test.ts',
|
|
'test/unit/detect-changes-worktree.test.ts',
|
|
'test/unit/eval-server-bind-restriction.test.ts',
|
|
'test/unit/ignore-service.test.ts',
|
|
'test/unit/group/bridge-db.test.ts',
|
|
'test/unit/group/bridge-db-edge.test.ts',
|
|
];
|
|
|
|
// Native LadybugDB integration tests — exercise the @ladybugdb/core
|
|
// N-API addon which has known platform-specific behavior (Windows
|
|
// file-lock lag after close, macOS N-API destructor segfaults)
|
|
const LBUG_NATIVE = [
|
|
'test/integration/lbug-core-adapter.test.ts',
|
|
'test/integration/lbug-vector-extension.test.ts',
|
|
'test/integration/lbug-pool.test.ts',
|
|
'test/integration/lbug-pool-stability.test.ts',
|
|
'test/integration/lbug-lock-retry.test.ts',
|
|
'test/integration/lbug-open-retry.test.ts',
|
|
'test/integration/lbug-close-handle-release.test.ts',
|
|
'test/integration/lbug-orphan-sidecar-recovery.test.ts',
|
|
'test/integration/lbug-readonly-init.test.ts',
|
|
'test/integration/lbug-non-ascii-path.test.ts',
|
|
'test/integration/local-backend.test.ts',
|
|
'test/integration/local-backend-calltool.test.ts',
|
|
'test/integration/search-core.test.ts',
|
|
'test/integration/search-pool.test.ts',
|
|
'test/integration/staleness-and-stability.test.ts',
|
|
'test/integration/analyze-wal-checkpoint-failure.test.ts',
|
|
];
|
|
|
|
// Process spawning and CLI tests — exercise child_process with real
|
|
// process spawning, which behaves differently across platforms (shell
|
|
// quoting, path resolution, signal handling)
|
|
const SPAWN_CLI = [
|
|
'test/integration/cli-e2e.test.ts',
|
|
'test/integration/hooks-e2e.test.ts',
|
|
'test/integration/skills-e2e.test.ts',
|
|
'test/integration/server-http-startup.test.ts',
|
|
'test/integration/mcp/server-startup.test.ts',
|
|
'test/integration/analyze-heap-oom-e2e.test.ts',
|
|
'test/integration/group/group-cli.test.ts',
|
|
'test/integration/cli/tool-no-index-stderr.test.ts',
|
|
'test/integration/setup-skills.test.ts',
|
|
'test/integration/setup-antigravity.test.ts',
|
|
'test/integration/antigravity-hook-e2e.test.ts',
|
|
'test/unit/local-cli-subprocess.test.ts',
|
|
];
|
|
|
|
// Worker threads tests — exercise real worker_threads which have
|
|
// platform-specific behavior (thread spawning, IPC, exit handling)
|
|
const WORKER_THREADS = [
|
|
'test/integration/worker-pool.test.ts',
|
|
'test/integration/parse-impl-quarantine-cache-skip.test.ts',
|
|
];
|
|
|
|
// Tree-sitter native addon smoke tests — verify that native grammars
|
|
// load correctly on each platform (binary compatibility, .node loading)
|
|
const NATIVE_ADDON_SMOKE = [
|
|
'test/integration/tree-sitter-languages.test.ts',
|
|
'test/integration/parsing.test.ts',
|
|
'test/integration/pipeline.test.ts',
|
|
'test/integration/pipeline-graph-golden.test.ts',
|
|
'test/unit/parser-loader.test.ts',
|
|
];
|
|
|
|
// Filesystem behavior tests — exercise operations that vary across
|
|
// platforms (CRLF, symlinks, permissions, temp dirs)
|
|
const FILESYSTEM = [
|
|
'test/integration/filesystem-walker.test.ts',
|
|
'test/integration/markdown-processor-crlf.test.ts',
|
|
'test/integration/ignore-and-skip-e2e.test.ts',
|
|
];
|
|
|
|
const ALL_CROSS_PLATFORM = [
|
|
...PLATFORM_LOGIC,
|
|
...LBUG_NATIVE,
|
|
...SPAWN_CLI,
|
|
...WORKER_THREADS,
|
|
...NATIVE_ADDON_SMOKE,
|
|
...FILESYSTEM,
|
|
];
|
|
|
|
// When invoked directly, print the file list for vitest consumption
|
|
if (process.argv[1]?.endsWith('cross-platform-tests.ts')) {
|
|
console.log(ALL_CROSS_PLATFORM.join('\n'));
|
|
}
|
|
|
|
export {
|
|
ALL_CROSS_PLATFORM,
|
|
PLATFORM_LOGIC,
|
|
LBUG_NATIVE,
|
|
SPAWN_CLI,
|
|
WORKER_THREADS,
|
|
NATIVE_ADDON_SMOKE,
|
|
FILESYSTEM,
|
|
};
|