-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test: Run node integration tests in isolation #5721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
b0b65c7
e4b7631
b86bdb7
dd5fe3f
8028d9e
d697937
cc38145
4aee3fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||||
/* eslint-disable no-console */ | ||||||||
import childProcess from 'child_process'; | ||||||||
import os from 'os'; | ||||||||
|
||||||||
const testPaths = childProcess.execSync('jest --listTests', { encoding: 'utf8' }).trim().split('\n'); | ||||||||
|
||||||||
let testsSucceeded = true; | ||||||||
const testAmount = testPaths.length; | ||||||||
lforst marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
const fails: string[] = []; | ||||||||
|
||||||||
const threads = os.cpus().map(async (_, i) => { | ||||||||
|
const threads = os.cpus().map(async (_, i) => { | |
const threads = os.cpus() | |
threads.map(async (_, i) => { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a .forEach
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If by forEach
you mean iterating over the jobs - I didn't do that because a) I don't want to overload the host machine by instantly starting a bazillion of processes, b) I wanted to distribute the jobs among the workers evenly, i.e. by popping another job off the queue when they're done with their current one. I honestly wouldn't know how to do that with forEach
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had in my head to just split the tests by cpus beforehand and then sync iterate, but the producer - consumer pattern you have here is way more effective, I just didn't think it through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having an explanation here is both helpful in its own right and possibly a way to forestall other folks asking the same question Abhi asked about
foreEach
.Also:
TIL! 🙂