mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: normalize windows bash test harness
This commit is contained in:
@@ -12,7 +12,7 @@ const assert = require('assert');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const { execSync } = require('child_process');
|
const { execFileSync, execSync } = require('child_process');
|
||||||
|
|
||||||
let passed = 0;
|
let passed = 0;
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
@@ -52,7 +52,7 @@ function toBashPath(filePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runBash(command, options = {}) {
|
function runBash(command, options = {}) {
|
||||||
return execSync(`bash -lc '${command.replace(/'/g, "'\\''")}'`, options).toString().trim();
|
return execFileSync('bash', ['-lc', command], options).toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const repoRoot = path.resolve(__dirname, '..', '..');
|
const repoRoot = path.resolve(__dirname, '..', '..');
|
||||||
@@ -209,7 +209,7 @@ test('detect-project.sh sets PROJECT_NAME and non-global PROJECT_ID for worktree
|
|||||||
echo "PROJECT_ID=\${PROJECT_ID}"
|
echo "PROJECT_ID=\${PROJECT_ID}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const result = execSync(`bash -lc '${script.replace(/'/g, "'\\''")}'`, {
|
const result = execFileSync('bash', ['-lc', script], {
|
||||||
cwd: worktreeDir,
|
cwd: worktreeDir,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
env: {
|
env: {
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ function toBashPath(filePath) {
|
|||||||
.replace(/\\/g, '/');
|
.replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fromBashPath(filePath) {
|
||||||
|
if (process.platform !== 'win32') {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = String(filePath).match(/^\/([A-Za-z])\/(.*)$/);
|
||||||
|
if (!match) {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${match[1].toUpperCase()}:\\${match[2].replace(/\//g, '\\')}`;
|
||||||
|
}
|
||||||
|
|
||||||
function sleepMs(ms) {
|
function sleepMs(ms) {
|
||||||
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
||||||
}
|
}
|
||||||
@@ -2343,8 +2356,9 @@ async function runTests() {
|
|||||||
assert.strictEqual(code, 0, `detect-project should source cleanly, stderr: ${stderr}`);
|
assert.strictEqual(code, 0, `detect-project should source cleanly, stderr: ${stderr}`);
|
||||||
|
|
||||||
const [projectId, projectDir] = stdout.trim().split(/\r?\n/);
|
const [projectId, projectDir] = stdout.trim().split(/\r?\n/);
|
||||||
|
const nativeProjectDir = fromBashPath(projectDir);
|
||||||
const registryPath = path.join(homeDir, '.claude', 'homunculus', 'projects.json');
|
const registryPath = path.join(homeDir, '.claude', 'homunculus', 'projects.json');
|
||||||
const projectMetadataPath = path.join(projectDir, 'project.json');
|
const projectMetadataPath = path.join(nativeProjectDir, 'project.json');
|
||||||
|
|
||||||
assert.ok(projectId, 'detect-project should emit a project id');
|
assert.ok(projectId, 'detect-project should emit a project id');
|
||||||
assert.ok(fs.existsSync(registryPath), 'projects.json should be created');
|
assert.ok(fs.existsSync(registryPath), 'projects.json should be created');
|
||||||
@@ -2352,11 +2366,12 @@ async function runTests() {
|
|||||||
|
|
||||||
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
||||||
const metadata = JSON.parse(fs.readFileSync(projectMetadataPath, 'utf8'));
|
const metadata = JSON.parse(fs.readFileSync(projectMetadataPath, 'utf8'));
|
||||||
|
const nativeMetadataRoot = fromBashPath(metadata.root);
|
||||||
|
|
||||||
assert.ok(registry[projectId], 'registry should contain the detected project');
|
assert.ok(registry[projectId], 'registry should contain the detected project');
|
||||||
assert.strictEqual(metadata.id, projectId, 'project.json should include the detected id');
|
assert.strictEqual(metadata.id, projectId, 'project.json should include the detected id');
|
||||||
assert.strictEqual(metadata.name, path.basename(repoDir), 'project.json should include the repo name');
|
assert.strictEqual(metadata.name, path.basename(repoDir), 'project.json should include the repo name');
|
||||||
assert.strictEqual(fs.realpathSync(metadata.root), fs.realpathSync(repoDir), 'project.json should include the repo root');
|
assert.strictEqual(fs.realpathSync(nativeMetadataRoot), fs.realpathSync(repoDir), 'project.json should include the repo root');
|
||||||
assert.strictEqual(metadata.remote, 'https://github.com/example/ecc-test.git', 'project.json should include the sanitized remote');
|
assert.strictEqual(metadata.remote, 'https://github.com/example/ecc-test.git', 'project.json should include the sanitized remote');
|
||||||
assert.ok(metadata.created_at, 'project.json should include created_at');
|
assert.ok(metadata.created_at, 'project.json should include created_at');
|
||||||
assert.ok(metadata.last_seen, 'project.json should include last_seen');
|
assert.ok(metadata.last_seen, 'project.json should include last_seen');
|
||||||
|
|||||||
Reference in New Issue
Block a user