Skip to content

Commit 62d4391

Browse files
authored
fix: improve Windows compatibility in tests (Fission-AI#646)
- Replace Unix 'cat' command with fs.readFile in spec.test.ts - Replace 'mkdir -p' and 'bash' commands with fs.mkdir/writeFile in validate.enriched-output.test.ts - Skip symlink test on Windows (requires admin privileges) in file-system.test.ts
1 parent 4573c28 commit 62d4391

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

test/commands/spec.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The system SHALL process credit card payments securely`;
5555
});
5656

5757
describe('spec show', () => {
58-
it('should display spec in text format', () => {
58+
it('should display spec in text format', async () => {
5959
const originalCwd = process.cwd();
6060
try {
6161
process.chdir(testDir);
@@ -64,7 +64,7 @@ The system SHALL process credit card payments securely`;
6464
});
6565

6666
// Raw passthrough should match spec.md content
67-
const raw = execSync(`cat ${path.join(specsDir, 'auth', 'spec.md')}`, { encoding: 'utf-8' });
67+
const raw = await fs.readFile(path.join(specsDir, 'auth', 'spec.md'), 'utf-8');
6868
expect(output.trim()).toBe(raw.trim());
6969
} finally {
7070
process.chdir(originalCwd);

test/commands/validate.enriched-output.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ describe('validate command enriched human output', () => {
1818
await fs.rm(testDir, { recursive: true, force: true });
1919
});
2020

21-
it('prints Next steps footer and guidance on invalid change', () => {
21+
it('prints Next steps footer and guidance on invalid change', async () => {
2222
const changeContent = `# Test Change\n\n## Why\nThis is a sufficiently long explanation to pass the why length requirement for validation purposes.\n\n## What Changes\nThere are changes proposed, but no delta specs provided yet.`;
2323
const changeId = 'c-next-steps';
2424
const changePath = path.join(changesDir, changeId);
25-
execSync(`mkdir -p ${changePath}`);
26-
execSync(`bash -lc "cat > ${path.join(changePath, 'proposal.md')} <<'EOF'\n${changeContent}\nEOF"`);
25+
await fs.mkdir(changePath, { recursive: true });
26+
await fs.writeFile(path.join(changePath, 'proposal.md'), changeContent);
2727

2828
const originalCwd = process.cwd();
2929
try {

test/utils/file-system.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ describe('FileSystemUtils', () => {
237237
expect(canWrite).toBe(false);
238238
});
239239

240-
it('should follow symbolic links to files', async () => {
240+
// Skip on Windows: creating symlinks requires elevated privileges or Developer Mode
241+
it.skipIf(process.platform === 'win32')('should follow symbolic links to files', async () => {
241242
const realFile = path.join(testDir, 'real-file.txt');
242243
const linkFile = path.join(testDir, 'link-file.txt');
243244
await fs.writeFile(realFile, 'content');

0 commit comments

Comments
 (0)