Skip to content

Commit bde5070

Browse files
johnlindquistclaude
andcommitted
fix: use temporary directories for all test files to prevent CI conflicts
Set KIT and KENV environment variables to use temporary directories in tests to avoid conflicts with user's home directory on CI systems. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7c5ea7c commit bde5070

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/api/kit.longrunning.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ import ava from 'ava'
22
import slugify from 'slugify'
33
import { getProcessedScripts } from './kit.js'
44
import { Script } from '../types/core.js'
5-
import { kenvPath } from '../core/utils.js'
5+
import { kenvPath, kitPath } from '../core/utils.js'
66
import { ensureDir, outputFile, remove } from 'fs-extra'
77
import { join } from 'path'
8+
import tmp from 'tmp-promise'
9+
10+
// Set up test environment with temporary directories
11+
const tmpDir = tmp.dirSync({ unsafeCleanup: true })
12+
process.env.KENV = join(tmpDir.name, '.kenv')
13+
process.env.KIT = join(tmpDir.name, '.kit')
14+
15+
// Ensure required directories exist
16+
await ensureDir(kenvPath())
17+
await ensureDir(kitPath())
18+
await ensureDir(kitPath('db'))
819

920
ava('getProcessedScripts preserves longRunning property', async (t) => {
1021
const testScriptName = 'Test Longrunning Script'

src/api/npm.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { kenvPath } from "../core/utils.js"
1414

1515
// biome-ignore lint/suspicious/useAwait: <explanation>
1616
await tmp.withDir(async (dir) => {
17-
process.env.KENV = dir.path
18-
process.env.KIT_CONTEXT = "workflow"
1917
process.env.KENV = path.resolve(dir.path, ".kenv")
18+
process.env.KIT = path.resolve(dir.path, ".kit")
19+
process.env.KIT_CONTEXT = "workflow"
2020

2121
ava.beforeEach(async (t) => {
2222
global.kitScript = `${randomUUID()}.js`

0 commit comments

Comments
 (0)