@@ -51,8 +51,9 @@ async function fixture(mode: "source" | "package" | "external-plugin" = "source"
5151 } ,
5252 } ;
5353 await write ( packageRoot , "package.json" , sourcePackage ) ;
54- await write ( packageRoot , "openclaw.mjs" , 'import "./dist/entry.js";' ) ;
55- await fs . chmod ( path . join ( packageRoot , "openclaw.mjs" ) , 0o755 ) ;
54+ await fs . writeFile ( path . join ( packageRoot , "openclaw.mjs" ) , 'import "./dist/entry.js";' , {
55+ mode : 0o755 ,
56+ } ) ;
5657 await write ( packageRoot , "node-version.mjs" , "export const supported = true;" ) ;
5758 await write ( packageRoot , "scripts/preinstall.mjs" , "export {};\n" ) ;
5859 await write (
@@ -147,7 +148,14 @@ describe("node bootstrap distribution", () => {
147148 "runs an unpublished %s snapshot with its plugin and private JavaScript dependency" ,
148149 async ( mode ) => {
149150 const { root, packageRoot, provider, sourcePackage } = await fixture ( mode ) ;
150- const [ artifact , concurrent ] = await Promise . all ( [ provider . prepare ( ) , provider . prepare ( ) ] ) ;
151+ // Node's getter temporarily changes the process mask and races parallel file creation.
152+ const readUmask = vi . spyOn ( process , "umask" ) . mockImplementation ( ( ) => {
153+ throw new Error ( "Artifact preparation must not read or mutate the process umask" ) ;
154+ } ) ;
155+ const [ artifact , concurrent ] = await Promise . all ( [
156+ provider . prepare ( ) ,
157+ provider . prepare ( ) ,
158+ ] ) . finally ( ( ) => readUmask . mockRestore ( ) ) ;
151159 expect ( concurrent ) . toBe ( artifact ) ;
152160 expect ( artifact ) . toMatchObject ( {
153161 buildId,
@@ -176,8 +184,13 @@ describe("node bootstrap distribution", () => {
176184 ) . toBe ( false ) ;
177185 expect ( entries . some ( ( entry ) => entry . startsWith ( "package/dist/worker/" ) ) ) . toBe ( false ) ;
178186 if ( process . platform !== "win32" ) {
179- expect ( modes . get ( "package/openclaw.mjs" ) ) . toBe ( 0o755 & ~ process . umask ( ) ) ;
180- expect ( modes . get ( "package/dist/shared.js" ) ) . toBe ( 0o644 & ~ process . umask ( ) ) ;
187+ for ( const [ relative , requestedMode ] of [
188+ [ "openclaw.mjs" , 0o755 ] ,
189+ [ "dist/shared.js" , 0o644 ] ,
190+ ] as const ) {
191+ const sourceMode = ( await fs . stat ( path . join ( packageRoot , relative ) ) ) . mode ;
192+ expect ( modes . get ( `package/${ relative } ` ) ) . toBe ( sourceMode & requestedMode ) ;
193+ }
181194 }
182195 if ( mode === "external-plugin" ) {
183196 expect ( entries ) . not . toContain ( "package/dist/extensions/remote-runtime/index.js" ) ;
0 commit comments