mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 18:33:28 +08:00
Fix Windows CI test failures - add platform checks and USERPROFILE support
Co-authored-by: pangerlkr <73515951+pangerlkr@users.noreply.github.com>
This commit is contained in:
@@ -2364,6 +2364,7 @@ file.ts
|
|||||||
if (test('getSessionById matches old format YYYY-MM-DD-session.tmp via noIdMatch path', () => {
|
if (test('getSessionById matches old format YYYY-MM-DD-session.tmp via noIdMatch path', () => {
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r122-old-format-'));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r122-old-format-'));
|
||||||
const origHome = process.env.HOME;
|
const origHome = process.env.HOME;
|
||||||
|
const origUserProfile = process.env.USERPROFILE;
|
||||||
const origDir = process.env.CLAUDE_DIR;
|
const origDir = process.env.CLAUDE_DIR;
|
||||||
try {
|
try {
|
||||||
// Set up isolated environment
|
// Set up isolated environment
|
||||||
@@ -2371,6 +2372,7 @@ file.ts
|
|||||||
const sessionsDir = path.join(claudeDir, 'sessions');
|
const sessionsDir = path.join(claudeDir, 'sessions');
|
||||||
fs.mkdirSync(sessionsDir, { recursive: true });
|
fs.mkdirSync(sessionsDir, { recursive: true });
|
||||||
process.env.HOME = tmpDir;
|
process.env.HOME = tmpDir;
|
||||||
|
process.env.USERPROFILE = tmpDir; // Windows: os.homedir() uses USERPROFILE
|
||||||
delete process.env.CLAUDE_DIR;
|
delete process.env.CLAUDE_DIR;
|
||||||
|
|
||||||
// Clear require cache for fresh module with new HOME
|
// Clear require cache for fresh module with new HOME
|
||||||
@@ -2396,6 +2398,8 @@ file.ts
|
|||||||
'Non-matching date should return null');
|
'Non-matching date should return null');
|
||||||
} finally {
|
} finally {
|
||||||
process.env.HOME = origHome;
|
process.env.HOME = origHome;
|
||||||
|
if (origUserProfile !== undefined) process.env.USERPROFILE = origUserProfile;
|
||||||
|
else delete process.env.USERPROFILE;
|
||||||
if (origDir) process.env.CLAUDE_DIR = origDir;
|
if (origDir) process.env.CLAUDE_DIR = origDir;
|
||||||
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
||||||
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
||||||
@@ -2485,6 +2489,7 @@ file.ts
|
|||||||
// "2026/01/15" or "Jan 15 2026" will never match, silently returning empty.
|
// "2026/01/15" or "Jan 15 2026" will never match, silently returning empty.
|
||||||
// No validation or normalization occurs on the date parameter.
|
// No validation or normalization occurs on the date parameter.
|
||||||
const origHome = process.env.HOME;
|
const origHome = process.env.HOME;
|
||||||
|
const origUserProfile = process.env.USERPROFILE;
|
||||||
const origDir = process.env.CLAUDE_DIR;
|
const origDir = process.env.CLAUDE_DIR;
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r124-date-format-'));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r124-date-format-'));
|
||||||
const homeDir = path.join(tmpDir, 'home');
|
const homeDir = path.join(tmpDir, 'home');
|
||||||
@@ -2492,6 +2497,7 @@ file.ts
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
process.env.HOME = homeDir;
|
process.env.HOME = homeDir;
|
||||||
|
process.env.USERPROFILE = homeDir; // Windows: os.homedir() uses USERPROFILE
|
||||||
delete process.env.CLAUDE_DIR;
|
delete process.env.CLAUDE_DIR;
|
||||||
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
||||||
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
||||||
@@ -2530,6 +2536,8 @@ file.ts
|
|||||||
'null date skips filter and returns all sessions');
|
'null date skips filter and returns all sessions');
|
||||||
} finally {
|
} finally {
|
||||||
process.env.HOME = origHome;
|
process.env.HOME = origHome;
|
||||||
|
if (origUserProfile !== undefined) process.env.USERPROFILE = origUserProfile;
|
||||||
|
else delete process.env.USERPROFILE;
|
||||||
if (origDir) process.env.CLAUDE_DIR = origDir;
|
if (origDir) process.env.CLAUDE_DIR = origDir;
|
||||||
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
delete require.cache[require.resolve('../../scripts/lib/utils')];
|
||||||
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
delete require.cache[require.resolve('../../scripts/lib/session-manager')];
|
||||||
|
|||||||
@@ -836,7 +836,8 @@ function runTests() {
|
|||||||
console.log('\nrunCommand Edge Cases:');
|
console.log('\nrunCommand Edge Cases:');
|
||||||
|
|
||||||
if (test('runCommand returns trimmed output', () => {
|
if (test('runCommand returns trimmed output', () => {
|
||||||
const result = utils.runCommand('echo " hello "');
|
// Windows echo includes quotes in output, use node to ensure consistent behavior
|
||||||
|
const result = utils.runCommand('node -e "process.stdout.write(\' hello \')"');
|
||||||
assert.strictEqual(result.success, true);
|
assert.strictEqual(result.success, true);
|
||||||
assert.strictEqual(result.output, 'hello', 'Should trim leading/trailing whitespace');
|
assert.strictEqual(result.output, 'hello', 'Should trim leading/trailing whitespace');
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
@@ -884,6 +885,10 @@ function runTests() {
|
|||||||
console.log('\nreadStdinJson maxSize truncation:');
|
console.log('\nreadStdinJson maxSize truncation:');
|
||||||
|
|
||||||
if (test('readStdinJson maxSize stops accumulating after threshold (chunk-level guard)', () => {
|
if (test('readStdinJson maxSize stops accumulating after threshold (chunk-level guard)', () => {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
console.log(' (skipped — stdin chunking behavior differs on Windows)');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const { execFileSync } = require('child_process');
|
const { execFileSync } = require('child_process');
|
||||||
// maxSize is a chunk-level guard: once data.length >= maxSize, no MORE chunks are added.
|
// maxSize is a chunk-level guard: once data.length >= maxSize, no MORE chunks are added.
|
||||||
// A single small chunk that arrives when data.length < maxSize is added in full.
|
// A single small chunk that arrives when data.length < maxSize is added in full.
|
||||||
@@ -1678,6 +1683,10 @@ function runTests() {
|
|||||||
// ── Round 110: findFiles root directory unreadable — silent empty return (not throw) ──
|
// ── Round 110: findFiles root directory unreadable — silent empty return (not throw) ──
|
||||||
console.log('\nRound 110: findFiles (root directory unreadable — EACCES on readdirSync caught silently):');
|
console.log('\nRound 110: findFiles (root directory unreadable — EACCES on readdirSync caught silently):');
|
||||||
if (test('findFiles returns empty array when root directory exists but is unreadable', () => {
|
if (test('findFiles returns empty array when root directory exists but is unreadable', () => {
|
||||||
|
if (process.platform === 'win32' || process.getuid?.() === 0) {
|
||||||
|
console.log(' (skipped — chmod ineffective on Windows/root)');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const tmpDir = fs.mkdtempSync(path.join(utils.getTempDir(), 'r110-unreadable-root-'));
|
const tmpDir = fs.mkdtempSync(path.join(utils.getTempDir(), 'r110-unreadable-root-'));
|
||||||
const unreadableDir = path.join(tmpDir, 'no-read');
|
const unreadableDir = path.join(tmpDir, 'no-read');
|
||||||
fs.mkdirSync(unreadableDir);
|
fs.mkdirSync(unreadableDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user