Skip to content

Commit bc7089f

Browse files
add tinypool test
1 parent d846d48 commit bc7089f

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default ({ a, b }) => {
2+
return a + b
3+
}

integration-tests/vitest/vitest.spec.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ versions.forEach((version) => {
6767
sandbox = await createSandbox([
6868
`vitest@${version}`,
6969
`@vitest/coverage-istanbul@${version}`,
70-
`@vitest/coverage-v8@${version}`
70+
`@vitest/coverage-v8@${version}`,
71+
'tinypool'
7172
], true)
7273
cwd = sandbox.folder
7374
})
@@ -2055,12 +2056,23 @@ versions.forEach((version) => {
20552056
})
20562057
})
20572058

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+
})
20642076
})
20652077
})
20662078
})

0 commit comments

Comments
 (0)