@@ -63,32 +63,39 @@ describe("local-check-runtime", () => {
6363 ) . toBe ( localPath ) ;
6464 } ) ;
6565
66- it ( "links dependency-less worktrees to the selected checkout's modules" , ( ) => {
67- const primaryRoot = createTempDir ( "openclaw-primary-toolchain-" ) ;
68- const cwd = path . join ( primaryRoot , ".codex" , "worktrees" , "task" , "openclaw" ) ;
69- const commonDir = path . join ( primaryRoot , ".git" ) ;
70- const primaryTsgo = path . join ( primaryRoot , "node_modules" , ".bin" , "tsgo" ) ;
71- const primaryNodeModules = path . join ( primaryRoot , "node_modules" ) ;
72- const localNodeModules = path . join ( cwd , "node_modules" ) ;
73- fs . mkdirSync ( path . dirname ( primaryTsgo ) , { recursive : true } ) ;
74- fs . mkdirSync ( cwd , { recursive : true } ) ;
75-
76- expect (
77- ensureRepoToolNodeModulesLink ( primaryTsgo , {
66+ it . each ( [
67+ { platform : "linux" as const , linkType : "dir" } ,
68+ { platform : "win32" as const , linkType : "junction" } ,
69+ ] ) (
70+ "links dependency-less $platform worktrees to the selected checkout's modules" ,
71+ ( { platform, linkType } ) => {
72+ const primaryRoot = createTempDir ( "openclaw-primary-toolchain-" ) ;
73+ const cwd = path . join ( primaryRoot , ".codex" , "worktrees" , "task" , "openclaw" ) ;
74+ const commonDir = path . join ( primaryRoot , ".git" ) ;
75+ const primaryTsgo = path . join ( primaryRoot , "node_modules" , ".bin" , "tsgo" ) ;
76+ const primaryNodeModules = path . join ( primaryRoot , "node_modules" ) ;
77+ const localNodeModules = path . join ( cwd , "node_modules" ) ;
78+ fs . mkdirSync ( path . dirname ( primaryTsgo ) , { recursive : true } ) ;
79+ fs . mkdirSync ( cwd , { recursive : true } ) ;
80+ const linkTypes : Array < Parameters < typeof fs . symlinkSync > [ 2 ] > = [ ] ;
81+ const linkOptions = {
7882 cwd,
7983 resolveCommonDir : ( ) => commonDir ,
80- } ) ,
81- ) . toBe ( localNodeModules ) ;
82- expect ( fs . realpathSync ( localNodeModules ) ) . toBe ( fs . realpathSync ( primaryNodeModules ) ) ;
84+ platform,
85+ symlink : ( ...args : Parameters < typeof fs . symlinkSync > ) => {
86+ linkTypes . push ( args [ 2 ] ) ;
87+ fs . symlinkSync ( ...args ) ;
88+ } ,
89+ } ;
8390
84- // The stable link is idempotent for concurrent and later local runners.
85- expect (
86- ensureRepoToolNodeModulesLink ( primaryTsgo , {
87- cwd ,
88- resolveCommonDir : ( ) => commonDir ,
89- } ) ,
90- ) . toBe ( localNodeModules ) ;
91- } ) ;
91+ expect ( ensureRepoToolNodeModulesLink ( primaryTsgo , linkOptions ) ) . toBe ( localNodeModules ) ;
92+ expect ( fs . realpathSync ( localNodeModules ) ) . toBe ( fs . realpathSync ( primaryNodeModules ) ) ;
93+
94+ // The stable link is idempotent for concurrent and later local runners.
95+ expect ( ensureRepoToolNodeModulesLink ( primaryTsgo , linkOptions ) ) . toBe ( localNodeModules ) ;
96+ expect ( linkTypes ) . toEqual ( [ linkType ] ) ;
97+ } ,
98+ ) ;
9299
93100 it ( "leaves existing worktree node_modules directories locally owned" , ( ) => {
94101 const primaryRoot = createTempDir ( "openclaw-primary-toolchain-" ) ;
0 commit comments