@@ -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() {
10082if ( toSpawn . length ) {
10183const config = toSpawn . shift ( ) ;
10284const {
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() {
11899tmpdir . path ,
119100`deletable-policy-${ testId } .json`
120101) ;
121- const cliPolicy = willDeletePolicy ? tmpPolicyPath : policyPath ;
102+
122103fs . rmSync ( configDirPath , { maxRetries : 3 , recursive : true , force : true } ) ;
123104fs . mkdirSync ( configDirPath , { recursive : true } ) ;
124105const manifest = {
@@ -140,15 +121,15 @@ function drainQueue() {
140121}
141122const manifestBody = JSON . stringify ( manifest ) ;
142123fs . writeFileSync ( manifestPath , manifestBody ) ;
143- if ( cliPolicy === tmpPolicyPath ) {
124+ if ( policyPath === tmpPolicyPath ) {
144125fs . writeFileSync ( tmpPolicyPath , manifestBody ) ;
145126}
146127const spawnArgs = [
147128process . execPath ,
148129[
149130'--unhandled-rejections=strict' ,
150131'--experimental-policy' ,
151- cliPolicy ,
132+ policyPath ,
152133 ...preloads . flatMap ( ( m ) => [ '-r' , m ] ) ,
153134entryPath ,
154135'--' ,
@@ -255,7 +236,6 @@ function fileExtensionFormat(extension, packageType) {
255236throw new Error ( 'unknown format ' + extension ) ;
256237}
257238for ( const permutation of permutations ( {
258- entry : [ 'worker' , 'parent' , 'dep' ] ,
259239preloads : [ [ ] , [ 'parent' ] , [ 'dep' ] ] ,
260240onError : [ 'log' , 'exit' ] ,
261241parentExtension : [ '.js' , '.mjs' , '.cjs' ] ,
@@ -282,14 +262,9 @@ for (const permutation of permutations({
282262continue ;
283263}
284264const 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+
291266const packageJSON = {
292- main : entryPath ,
267+ main : depPath ,
293268type : permutation . packageType ,
294269} ;
295270if ( permutation . packageType === 'no-field' ) {
@@ -314,8 +289,7 @@ for (const permutation of permutations({
314289if ( parentFormat !== 'commonjs' ) {
315290permutation . preloads = permutation . preloads . filter ( ( _ ) => _ !== 'parent' ) ;
316291}
317- const hasParent =
318- permutation . entry !== 'dep' || permutation . preloads . includes ( 'parent' ) ;
292+ const hasParent = permutation . preloads . includes ( 'parent' ) ;
319293if ( hasParent ) {
320294resources [ parentPath ] = {
321295body : parentBody [ parentFormat ] ,
@@ -332,12 +306,7 @@ for (const permutation of permutations({
332306throw new Error ( 'unreachable' ) ;
333307}
334308}
335- if ( permutation . entry === 'worker' ) {
336- resources [ workerSpawnerPath ] = {
337- body : workerSpawningBody ,
338- integrities : hash ( 'sha256' , workerSpawningBody ) ,
339- } ;
340- }
309+
341310if ( permutation . packageType !== 'no-package-json' ) {
342311let packageBody = JSON . stringify ( packageJSON , null , 2 ) ;
343312let packageIntegrities = hash ( 'sha256' , packageBody ) ;
@@ -364,18 +333,15 @@ for (const permutation of permutations({
364333integrities : packageIntegrities ,
365334} ;
366335}
367- const willDeletePolicy = permutation . entry === 'worker' ;
336+
368337if ( permutation . onError === 'log' ) {
369338shouldSucceed = true ;
370339}
371340tests . add (
372341JSON . stringify ( {
373- // hasParent,
374- // original: permutation,
375342onError : permutation . onError ,
376343 shouldSucceed,
377- entryPath,
378- willDeletePolicy,
344+ entryPath : depPath ,
379345preloads : permutation . preloads
380346. map ( ( _ ) => {
381347return {
0 commit comments