File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change
1
+ import Tinypool from 'tinypool'
2
+
3
+ const pool = new Tinypool ( {
4
+ filename : new URL ( './tinypool-worker.mjs' , import . meta. url ) . href ,
5
+ } )
6
+
7
+ const result = await pool . run ( { a : 4 , b : 6 } )
8
+ // eslint-disable-next-line no-console
9
+ console . log ( 'result' , result )
10
+
11
+ // Make sure to destroy pool once it's not needed anymore
12
+ // This terminates all pool's idle workers
13
+ await pool . destroy ( )
Original file line number Diff line number Diff line change
1
+ export default ( { a, b } ) => {
2
+ return a + b
3
+ }
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ versions.forEach((version) => {
67
67
sandbox = await createSandbox ( [
68
68
`vitest@${ version } ` ,
69
69
`@vitest/coverage-istanbul@${ version } ` ,
70
- `@vitest/coverage-v8@${ version } `
70
+ `@vitest/coverage-v8@${ version } ` ,
71
+ 'tinypool'
71
72
] , true )
72
73
cwd = sandbox . folder
73
74
} )
@@ -2055,12 +2056,23 @@ versions.forEach((version) => {
2055
2056
} )
2056
2057
} )
2057
2058
2058
- it . skip ( 'does not blow up when tinypool is used outside of a test' , ( done ) => {
2059
- // childProcess = exec('node ./ci-visibility/run-workerpool.js', {
2060
- // cwd,
2061
- // env: getCiVisAgentlessConfig(receiver.port),
2062
- // stdio: 'pipe'
2063
- // })
2059
+ it ( 'does not blow up when tinypool is used outside of a test' , ( done ) => {
2060
+ childProcess = exec ( 'node ./ci-visibility/run-tinypool.mjs' , {
2061
+ cwd,
2062
+ env : getCiVisAgentlessConfig ( receiver . port ) ,
2063
+ stdio : 'pipe'
2064
+ } )
2065
+ childProcess . stdout . on ( 'data' , ( chunk ) => {
2066
+ testOutput += chunk . toString ( )
2067
+ } )
2068
+ childProcess . stderr . on ( 'data' , ( chunk ) => {
2069
+ testOutput += chunk . toString ( )
2070
+ } )
2071
+ childProcess . on ( 'exit' , ( code ) => {
2072
+ assert . include ( testOutput , 'result 10' )
2073
+ assert . equal ( code , 0 )
2074
+ done ( )
2075
+ } )
2064
2076
} )
2065
2077
} )
2066
2078
} )
You can’t perform that action at this time.
0 commit comments