-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
ci: Find duplicate and slow tests #9188
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
dd37911
test: Find duplicate specs and analyze slow tests
dplewis 311b20c
Merge branch 'alpha' into display-slow-tests
dplewis a77d341
remove timeout
dplewis f471e95
output duplicates
dplewis e6e6841
more duplicate tests
dplewis 72312ca
Merge branch 'alpha' into display-slow-tests
dplewis 80b3529
Merge branch 'alpha' into display-slow-tests
mtrezza 4a1f227
Update spec/support/CurrentSpecReporter.js
mtrezza 220b6a5
Update spec/support/CurrentSpecReporter.js
mtrezza af66be7
Update spec/support/CurrentSpecReporter.js
mtrezza 702608f
Update spec/support/CurrentSpecReporter.js
mtrezza be72594
Update spec/support/CurrentSpecReporter.js
mtrezza a93cb3e
Update CurrentSpecReporter.js
mtrezza d7f1a29
Merge branch 'alpha' into display-slow-tests
mtrezza 291c8cb
Update CurrentSpecReporter.js
mtrezza 6cc001e
Merge branch 'alpha' into display-slow-tests
mtrezza c13517e
Merge branch 'alpha' into display-slow-tests
mtrezza 6504b26
remove duplicate tests
dplewis 4cbf09f
remove more duplicate tests
dplewis 2a3ddbe
reduce execution time to 1 second
dplewis 6ab4d85
change back 2 seconds limit was curious about 1 second
dplewis 04c95e5
revert DB specific tests
dplewis 756d110
Merge branch 'alpha' into display-slow-tests
mtrezza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
10.14.2 | ||
|
||
20.15.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
// Sets a global variable to the current test spec | ||
// ex: global.currentSpec.description | ||
|
||
const { performance } = require('perf_hooks'); | ||
global.currentSpec = null; | ||
|
||
const timerMap = {}; | ||
const duplicates = []; | ||
/** The min. execution time in seconds for a test to be considered slow. */ | ||
const slowTestLimit = 2; | ||
|
||
mtrezza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class CurrentSpecReporter { | ||
specStarted(spec) { | ||
if (timerMap[spec.fullName]) { | ||
console.log('Duplicate spec: ' + spec.fullName); | ||
duplicates.push(spec.fullName); | ||
} | ||
timerMap[spec.fullName] = performance.now(); | ||
global.currentSpec = spec; | ||
} | ||
specDone() { | ||
specDone(result) { | ||
if (result.status === 'excluded') { | ||
delete timerMap[result.fullName]; | ||
return; | ||
} | ||
timerMap[result.fullName] = (performance.now() - timerMap[result.fullName]) / 1000; | ||
global.currentSpec = null; | ||
} | ||
} | ||
global.displaySlowTests = function() { | ||
const times = Object.values(timerMap).sort((a,b) => b - a); | ||
if (times.length > 0) { | ||
console.log('Slow tests with execution time >=${slowTestLimit}s:'); | ||
} | ||
times.forEach((time) => { | ||
if (time >= slowTestLimit) { | ||
console.warn(`${time.toFixed(3)}s:`, Object.keys(timerMap).find(key => timerMap[key] === time)); | ||
} | ||
}); | ||
console.log('\n'); | ||
duplicates.forEach((spec) => { | ||
console.warn('Duplicate spec: ' + spec); | ||
}); | ||
}; | ||
|
||
module.exports = CurrentSpecReporter; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.