Skip to content

Commit 5e35aa7

Browse files
mihailtclaude
andcommitted
test(search): the long-line, answers and error-output tests make their folder with createTempDir()
Each made its temporary folder by hand and resolved its real path itself (macOS's temporary folder is behind a link, and the server works with real paths). createTempDir() does the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 9c3fae1 commit 5e35aa7

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎test/test-search-answers-unchanged.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
*/
1212
import assert from 'assert';
1313
import fs from 'fs';
14-
import os from 'os';
1514
import path from 'path';
1615
import { connectToServer, readSearchAnswer, closeClient } from './helpers/mcp-client.js';
1716
import { runIfMain } from './helpers/run-if-main.js';
17+
import { createTempDir } from './helpers/test-env.js';
1818

1919
const MB = 1024 * 1024;
2020
const PATTERN = 'needle\\w*';
@@ -171,7 +171,7 @@ async function checkNonUtf8Match(client, dir) {
171171
}
172172

173173
export default async function runTests() {
174-
const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'dc-search-answers-')));
174+
const dir = createTempDir('dc-search-answers-');
175175
fs.writeFileSync(path.join(dir, 'guard.js'), `${LINES.join('\n')}\n`);
176176

177177
const cases = [

‎test/test-search-error-output.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
*/
88
import assert from 'assert';
99
import fs from 'fs';
10-
import os from 'os';
1110
import path from 'path';
1211
import { searchManager } from '../dist/search-manager.js';
1312
import { configManager } from '../dist/config-manager.js';
1413
import { handleStartSearch } from '../dist/handlers/search-handlers.js';
1514
import { runIfMain } from './helpers/run-if-main.js';
15+
import { createTempDir } from './helpers/test-env.js';
1616

1717
const MAX_KEPT_CHARS = 64 * 1024;
1818

1919
export default async function runTests() {
2020
const originalConfig = await configManager.getConfig();
21-
const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'dc-search-errors-')));
21+
const dir = createTempDir('dc-search-errors-');
2222
fs.writeFileSync(path.join(dir, 'a.txt'), 'text\n');
2323
await configManager.setValue('allowedDirectories', [dir]);
2424
let sessionId;

‎test/test-search-long-lines.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import assert from 'assert';
1616
import { constants } from 'buffer';
1717
import fs from 'fs';
18-
import os from 'os';
1918
import path from 'path';
2019
import v8 from 'v8';
2120
import vm from 'vm';
@@ -25,6 +24,7 @@ import { configManager } from '../dist/config-manager.js';
2524
import { startSearchAndWait } from './helpers/search.js';
2625
import { connectToServer, readSearchAnswer, closeClient } from './helpers/mcp-client.js';
2726
import { runIfMain } from './helpers/run-if-main.js';
27+
import { createTempDir } from './helpers/test-env.js';
2828

2929
v8.setFlagsFromString('--expose-gc');
3030
const gc = vm.runInNewContext('gc');
@@ -150,7 +150,7 @@ export default async function runTests() {
150150
const failures = [];
151151
try {
152152
for (const [name, run] of cases) {
153-
const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'dc-search-long-lines-')));
153+
const dir = createTempDir('dc-search-long-lines-');
154154
try {
155155
await configManager.setValue('allowedDirectories', [dir]);
156156
await run(dir);

0 commit comments

Comments
 (0)