@@ -60,24 +60,6 @@ const parentBody = {
6060 import(process.env.DEP_FILE)
6161 ` ,
6262} ;
63- const workerSpawningBody = `
64- const path = require('path');
65- const { Worker } = require('worker_threads');
66- if (!process.env.PARENT_FILE) {
67- console.error(
68- 'missing required PARENT_FILE env to determine worker entry point'
69- );
70- process.exit(33);
71- }
72- if (!process.env.DELETABLE_POLICY_FILE) {
73- console.error(
74- 'missing required DELETABLE_POLICY_FILE env to check reloading'
75- );
76- process.exit(33);
77- }
78- const w = new Worker(path.resolve(process.env.PARENT_FILE));
79- w.on('exit', (status) => process.exit(status === 0 ? 0 : 1));
80- ` ;
8163
8264let nextTestId = 1 ;
8365function newTestId ( ) {
@@ -100,12 +82,11 @@ function drainQueue() {
10082 if ( toSpawn . length ) {
10183 const config = toSpawn . shift ( ) ;
10284 const {
103- shouldSucceed, // = (() => { throw new Error('required')})(),
104- preloads, // = (() =>{ throw new Error('required')})(),
105- entryPath, // = (() => { throw new Error('required')})(),
106- willDeletePolicy, // = (() => { throw new Error('required')})(),
107- onError, // = (() => { throw new Error('required')})(),
108- resources, // = (() => { throw new Error('required')})(),
85+ shouldSucceed,
86+ preloads,
87+ entryPath,
88+ onError,
89+ resources,
10990 parentPath,
11091 depPath,
11192 } = config ;
@@ -118,7 +99,7 @@ function drainQueue() {
11899 tmpdir . path ,
119100 `deletable-policy-${ testId } .json`
120101 ) ;
121- const cliPolicy = willDeletePolicy ? tmpPolicyPath : policyPath ;
102+
122103 fs . rmSync ( configDirPath , { maxRetries : 3 , recursive : true , force : true } ) ;
123104 fs . mkdirSync ( configDirPath , { recursive : true } ) ;
124105 const manifest = {
@@ -140,15 +121,15 @@ function drainQueue() {
140121 }
141122 const manifestBody = JSON . stringify ( manifest ) ;
142123 fs . writeFileSync ( manifestPath , manifestBody ) ;
143- if ( cliPolicy === tmpPolicyPath ) {
124+ if ( policyPath === tmpPolicyPath ) {
144125 fs . writeFileSync ( tmpPolicyPath , manifestBody ) ;
145126 }
146127 const spawnArgs = [
147128 process . execPath ,
148129 [
149130 '--unhandled-rejections=strict' ,
150131 '--experimental-policy' ,
151- cliPolicy ,
132+ policyPath ,
152133 ...preloads . flatMap ( ( m ) => [ '-r' , m ] ) ,
153134 entryPath ,
154135 '--' ,
@@ -255,7 +236,6 @@ function fileExtensionFormat(extension, packageType) {
255236 throw new Error ( 'unknown format ' + extension ) ;
256237}
257238for ( const permutation of permutations ( {
258- entry : [ 'worker' , 'parent' , 'dep' ] ,
259239 preloads : [ [ ] , [ 'parent' ] , [ 'dep' ] ] ,
260240 onError : [ 'log' , 'exit' ] ,
261241 parentExtension : [ '.js' , '.mjs' , '.cjs' ] ,
@@ -282,14 +262,9 @@ for (const permutation of permutations({
282262 continue ;
283263 }
284264 const depPath = `./dep${ permutation . depExtension } ` ;
285- const workerSpawnerPath = './worker-spawner.cjs' ;
286- const entryPath = {
287- dep : depPath ,
288- parent : parentPath ,
289- worker : workerSpawnerPath ,
290- } [ permutation . entry ] ;
265+
291266 const packageJSON = {
292- main : entryPath ,
267+ main : depPath ,
293268 type : permutation . packageType ,
294269 } ;
295270 if ( permutation . packageType === 'no-field' ) {
@@ -314,8 +289,7 @@ for (const permutation of permutations({
314289 if ( parentFormat !== 'commonjs' ) {
315290 permutation . preloads = permutation . preloads . filter ( ( _ ) => _ !== 'parent' ) ;
316291 }
317- const hasParent =
318- permutation . entry !== 'dep' || permutation . preloads . includes ( 'parent' ) ;
292+ const hasParent = permutation . preloads . includes ( 'parent' ) ;
319293 if ( hasParent ) {
320294 resources [ parentPath ] = {
321295 body : parentBody [ parentFormat ] ,
@@ -332,12 +306,7 @@ for (const permutation of permutations({
332306 throw new Error ( 'unreachable' ) ;
333307 }
334308 }
335- if ( permutation . entry === 'worker' ) {
336- resources [ workerSpawnerPath ] = {
337- body : workerSpawningBody ,
338- integrities : hash ( 'sha256' , workerSpawningBody ) ,
339- } ;
340- }
309+
341310 if ( permutation . packageType !== 'no-package-json' ) {
342311 let packageBody = JSON . stringify ( packageJSON , null , 2 ) ;
343312 let packageIntegrities = hash ( 'sha256' , packageBody ) ;
@@ -364,18 +333,15 @@ for (const permutation of permutations({
364333 integrities : packageIntegrities ,
365334 } ;
366335 }
367- const willDeletePolicy = permutation . entry === 'worker' ;
336+
368337 if ( permutation . onError === 'log' ) {
369338 shouldSucceed = true ;
370339 }
371340 tests . add (
372341 JSON . stringify ( {
373- // hasParent,
374- // original: permutation,
375342 onError : permutation . onError ,
376343 shouldSucceed,
377- entryPath,
378- willDeletePolicy,
344+ entryPath : depPath ,
379345 preloads : permutation . preloads
380346 . map ( ( _ ) => {
381347 return {
0 commit comments