@@ -60,24 +60,6 @@ const parentBody = {
60
60
import(process.env.DEP_FILE)
61
61
` ,
62
62
} ;
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
- ` ;
81
63
82
64
let nextTestId = 1 ;
83
65
function newTestId ( ) {
@@ -100,12 +82,11 @@ function drainQueue() {
100
82
if ( toSpawn . length ) {
101
83
const config = toSpawn . shift ( ) ;
102
84
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,
109
90
parentPath,
110
91
depPath,
111
92
} = config ;
@@ -118,7 +99,7 @@ function drainQueue() {
118
99
tmpdir . path ,
119
100
`deletable-policy-${ testId } .json`
120
101
) ;
121
- const cliPolicy = willDeletePolicy ? tmpPolicyPath : policyPath ;
102
+
122
103
fs . rmSync ( configDirPath , { maxRetries : 3 , recursive : true , force : true } ) ;
123
104
fs . mkdirSync ( configDirPath , { recursive : true } ) ;
124
105
const manifest = {
@@ -140,15 +121,15 @@ function drainQueue() {
140
121
}
141
122
const manifestBody = JSON . stringify ( manifest ) ;
142
123
fs . writeFileSync ( manifestPath , manifestBody ) ;
143
- if ( cliPolicy === tmpPolicyPath ) {
124
+ if ( policyPath === tmpPolicyPath ) {
144
125
fs . writeFileSync ( tmpPolicyPath , manifestBody ) ;
145
126
}
146
127
const spawnArgs = [
147
128
process . execPath ,
148
129
[
149
130
'--unhandled-rejections=strict' ,
150
131
'--experimental-policy' ,
151
- cliPolicy ,
132
+ policyPath ,
152
133
...preloads . flatMap ( ( m ) => [ '-r' , m ] ) ,
153
134
entryPath ,
154
135
'--' ,
@@ -255,7 +236,6 @@ function fileExtensionFormat(extension, packageType) {
255
236
throw new Error ( 'unknown format ' + extension ) ;
256
237
}
257
238
for ( const permutation of permutations ( {
258
- entry : [ 'worker' , 'parent' , 'dep' ] ,
259
239
preloads : [ [ ] , [ 'parent' ] , [ 'dep' ] ] ,
260
240
onError : [ 'log' , 'exit' ] ,
261
241
parentExtension : [ '.js' , '.mjs' , '.cjs' ] ,
@@ -282,14 +262,9 @@ for (const permutation of permutations({
282
262
continue ;
283
263
}
284
264
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
+
291
266
const packageJSON = {
292
- main : entryPath ,
267
+ main : depPath ,
293
268
type : permutation . packageType ,
294
269
} ;
295
270
if ( permutation . packageType === 'no-field' ) {
@@ -314,8 +289,7 @@ for (const permutation of permutations({
314
289
if ( parentFormat !== 'commonjs' ) {
315
290
permutation . preloads = permutation . preloads . filter ( ( _ ) => _ !== 'parent' ) ;
316
291
}
317
- const hasParent =
318
- permutation . entry !== 'dep' || permutation . preloads . includes ( 'parent' ) ;
292
+ const hasParent = permutation . preloads . includes ( 'parent' ) ;
319
293
if ( hasParent ) {
320
294
resources [ parentPath ] = {
321
295
body : parentBody [ parentFormat ] ,
@@ -332,12 +306,7 @@ for (const permutation of permutations({
332
306
throw new Error ( 'unreachable' ) ;
333
307
}
334
308
}
335
- if ( permutation . entry === 'worker' ) {
336
- resources [ workerSpawnerPath ] = {
337
- body : workerSpawningBody ,
338
- integrities : hash ( 'sha256' , workerSpawningBody ) ,
339
- } ;
340
- }
309
+
341
310
if ( permutation . packageType !== 'no-package-json' ) {
342
311
let packageBody = JSON . stringify ( packageJSON , null , 2 ) ;
343
312
let packageIntegrities = hash ( 'sha256' , packageBody ) ;
@@ -364,18 +333,15 @@ for (const permutation of permutations({
364
333
integrities : packageIntegrities ,
365
334
} ;
366
335
}
367
- const willDeletePolicy = permutation . entry === 'worker' ;
336
+
368
337
if ( permutation . onError === 'log' ) {
369
338
shouldSucceed = true ;
370
339
}
371
340
tests . add (
372
341
JSON . stringify ( {
373
- // hasParent,
374
- // original: permutation,
375
342
onError : permutation . onError ,
376
343
shouldSucceed,
377
- entryPath,
378
- willDeletePolicy,
344
+ entryPath : depPath ,
379
345
preloads : permutation . preloads
380
346
. map ( ( _ ) => {
381
347
return {
0 commit comments