Skip to content

Commit 20b9b9e

Browse files
staredclaude
andcommitted
Fix test directory creation: ensure test-output exists before writing
Root cause: The ./test-output/ directory is gitignored, so it doesn't exist in fresh GitHub Actions checkouts. Tests were trying to write to this directory without creating it first, causing ENOENT errors. Solution: Add mkdirSync('./test-output', { recursive: true }) before each writeFileSync call in all affected test files. Changes: - test-latex-export-real.ts: Import mkdirSync, create dir before write - test-latex-export-maxwell.ts: Import mkdirSync, create dir before write - test-beamer-export.ts: Import mkdirSync, create dir before write - test-beamer-export-maxwell.ts: Import mkdirSync, create dir before write - test-typst-export.ts: Import mkdirSync, create dir before write The { recursive: true } flag means: ✓ No error if directory already exists ✓ Creates parent directories if needed ✓ Makes tests self-sufficient and runnable anywhere Verification: - Deleted local test-output/ directory - Ran all 5 test scripts - All passed and created files successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 99dfc0a commit 20b9b9e

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

test-beamer-export-maxwell.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { parseContent } from './src/parser';
33
import { exportToBeamer } from './src/exporter';
44
import type { ColorScheme } from './src/exporter';
5-
import { writeFileSync, readFileSync } from 'fs';
5+
import { writeFileSync, readFileSync, mkdirSync } from 'fs';
66

77
// Test color scheme - Maxwell has 10 terms
88
const colorScheme: ColorScheme = {
@@ -66,6 +66,7 @@ async function testBeamerExport() {
6666

6767
// Write to file for manual inspection
6868
const outputPath = './test-output/test-maxwell-beamer.tex';
69+
mkdirSync('./test-output', { recursive: true });
6970
writeFileSync(outputPath, beamer);
7071
console.log(`Beamer output written to: ${outputPath}`);
7172
console.log('Compile with: pdflatex ./test-output/test-maxwell-beamer.tex');

test-beamer-export.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { parseContent } from './src/parser';
33
import { exportToBeamer } from './src/exporter';
44
import type { ColorScheme } from './src/exporter';
5-
import { writeFileSync, readFileSync } from 'fs';
5+
import { writeFileSync, readFileSync, mkdirSync } from 'fs';
66

77
// Test color scheme
88
const colorScheme: ColorScheme = {
@@ -70,6 +70,7 @@ async function testBeamerExport() {
7070

7171
// Write to file for manual inspection
7272
const outputPath = './test-output/test-euler-beamer.tex';
73+
mkdirSync('./test-output', { recursive: true });
7374
writeFileSync(outputPath, beamer);
7475
console.log(`Beamer output written to: ${outputPath}`);
7576
console.log('Compile with: pdflatex ./test-output/test-euler-beamer.tex');

test-latex-export-maxwell.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { parseContent } from './src/parser';
33
import { exportToLaTeX } from './src/exporter';
44
import type { ColorScheme } from './src/exporter';
5-
import { writeFileSync, readFileSync } from 'fs';
5+
import { writeFileSync, readFileSync, mkdirSync } from 'fs';
66

77
// Test color scheme - Maxwell has 10 terms
88
const colorScheme: ColorScheme = {
@@ -66,6 +66,7 @@ async function testLatexExport() {
6666

6767
// Write to file for manual inspection
6868
const outputPath = './test-output/test-maxwell.tex';
69+
mkdirSync('./test-output', { recursive: true });
6970
writeFileSync(outputPath, latex);
7071
console.log(`LaTeX output written to: ${outputPath}`);
7172
console.log('You can compile it with: pdflatex ./test-output/test-maxwell.tex\n');

test-latex-export-real.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { parseContent } from './src/parser';
33
import { exportToLaTeX } from './src/exporter';
44
import type { ColorScheme } from './src/exporter';
5-
import { writeFileSync, readFileSync } from 'fs';
5+
import { writeFileSync, readFileSync, mkdirSync } from 'fs';
66

77
// Test color scheme
88
const colorScheme: ColorScheme = {
@@ -66,6 +66,7 @@ async function testLatexExport() {
6666

6767
// Write to file for manual inspection
6868
const outputPath = './test-output/test-euler-export.tex';
69+
mkdirSync('./test-output', { recursive: true });
6970
writeFileSync(outputPath, latex);
7071
console.log(`LaTeX output written to: ${outputPath}`);
7172
console.log('You can compile it with: pdflatex ./test-output/test-euler-export.tex\n');

test-typst-export.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { parseContent } from './src/parser';
33
import { exportToTypst } from './src/exporter';
44
import type { ColorScheme } from './src/exporter';
5-
import { writeFileSync, readFileSync } from 'fs';
5+
import { writeFileSync, readFileSync, mkdirSync } from 'fs';
66

77
// Test color scheme
88
const colorScheme: ColorScheme = {
@@ -66,6 +66,7 @@ async function testTypstExport() {
6666

6767
// Write to file for manual inspection
6868
const outputPath = './test-output/test-euler.typ';
69+
mkdirSync('./test-output', { recursive: true });
6970
writeFileSync(outputPath, typst);
7071
console.log(`Typst output written to: ${outputPath}`);
7172
console.log('You can compile it with: typst compile ./test-output/test-euler.typ\n');

0 commit comments

Comments
 (0)