@@ -116,11 +116,11 @@ describe("report-test-temp-creations", () => {
116116
117117 it ( "reports repository-observed mkdtemp call forms" , ( ) => {
118118 const sources = [
119- ' const root = await fs.promises.mkdtemp(path.join(os.tmpdir(), "case-"));',
120- ' const root = await fs.mkdtemp(path.join(os.tmpdir(), "case-"));',
121- ' const root = await fsPromises.mkdtemp("/tmp/openclaw-case-");',
122- ' const root = await mkdtemp(path.join(tmpdir(), "case-"));',
123- ' const root = mkdtempSync (join(tmpdir(), "case-"));',
119+ [ " const root = await fs.promises." , " mkdtemp" , ' (path.join(os.tmpdir(), "case-"));'] . join ( "" ) ,
120+ [ " const root = await fs." , " mkdtemp" , ' (path.join(os.tmpdir(), "case-"));'] . join ( "" ) ,
121+ [ " const root = await fsPromises." , " mkdtemp" , ' ("/tmp/openclaw-case-");'] . join ( "" ) ,
122+ [ " const root = await " , " mkdtemp" , ' (path.join(tmpdir(), "case-"));'] . join ( "" ) ,
123+ [ " const root = " , "mkdtemp" , 'Sync (join(tmpdir(), "case-"));'] . join ( "" ) ,
124124 ] ;
125125 const diff = [
126126 "diff --git a/test/scripts/temp-patterns.test.ts b/test/scripts/temp-patterns.test.ts" ,
@@ -394,6 +394,72 @@ describe("report-test-temp-creations", () => {
394394 ) ;
395395 } ) ;
396396
397+ it ( "reads staged source for manual helper scans" , ( ) => {
398+ const root = tempDirs . make ( "openclaw-temp-report-staged-source-" ) ;
399+ const env = createNestedGitEnv ( ) ;
400+ execFileSync ( "git" , [ "init" , "-q" , "--initial-branch=main" ] , { cwd : root , env } ) ;
401+ execFileSync (
402+ "git" ,
403+ [
404+ "-c" ,
405+ 406+ "-c" ,
407+ "user.name=Test User" ,
408+ "commit" ,
409+ "--allow-empty" ,
410+ "-q" ,
411+ "-m" ,
412+ "initial" ,
413+ ] ,
414+ { cwd : root , env } ,
415+ ) ;
416+
417+ fs . mkdirSync ( path . join ( root , "test" , "scripts" ) , { recursive : true } ) ;
418+ const stagedManualFile = path . join ( root , "test" , "scripts" , "staged-manual.test.ts" ) ;
419+ const stagedAutoFile = path . join ( root , "test" , "scripts" , "staged-auto.test.ts" ) ;
420+ const manualSource = [
421+ 'import { makeTempDir } from "../helpers/temp-dir.js";' ,
422+ "const tempDirs = new Set<string>();" ,
423+ 'const workspace = makeTempDir(tempDirs, "case-");' ,
424+ ] . join ( "\n" ) ;
425+ const autoSource = [
426+ 'import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";' ,
427+ "const tempDirs = useAutoCleanupTempDirTracker();" ,
428+ 'const workspace = tempDirs.make("case-");' ,
429+ ] . join ( "\n" ) ;
430+ fs . writeFileSync ( stagedManualFile , `${ manualSource } \n` , "utf8" ) ;
431+ fs . writeFileSync ( stagedAutoFile , `${ autoSource } \n` , "utf8" ) ;
432+ execFileSync ( "git" , [ "add" , "test/scripts" ] , { cwd : root , env } ) ;
433+ fs . writeFileSync ( stagedManualFile , `${ autoSource } \n` , "utf8" ) ;
434+ fs . writeFileSync ( stagedAutoFile , `${ manualSource } \n` , "utf8" ) ;
435+
436+ const result = spawnSync (
437+ process . execPath ,
438+ [ path . join ( repoRoot , "scripts" , "report-test-temp-creations.mjs" ) , "--staged" , "--json" ] ,
439+ {
440+ cwd : root ,
441+ encoding : "utf8" ,
442+ env,
443+ } ,
444+ ) ;
445+
446+ expect ( result . status ) . toBe ( 0 ) ;
447+ expect ( JSON . parse ( result . stdout ) ) . toEqual ( [
448+ {
449+ file : "test/scripts/staged-manual.test.ts" ,
450+ line : 1 ,
451+ reason : "new manual temp-dir helper import" ,
452+ source : 'import { makeTempDir } from "../helpers/temp-dir.js";' ,
453+ } ,
454+ {
455+ file : "test/scripts/staged-manual.test.ts" ,
456+ line : 3 ,
457+ reason : "new manual temp-dir helper usage" ,
458+ source : 'const workspace = makeTempDir(tempDirs, "case-");' ,
459+ } ,
460+ ] ) ;
461+ } ) ;
462+
397463 it ( "exits non-zero for staged findings when requested" , ( ) => {
398464 const root = tempDirs . make ( "openclaw-temp-report-" ) ;
399465 const env = createNestedGitEnv ( ) ;
0 commit comments