forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Split functional tests into per file so they don't run out of memory during failures #13534
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 all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
452c83d
Split functional tests on each file
rchiodo cee5587
Try js instead
rchiodo 6fa47ce
Actually use node instead of python
rchiodo f5b3adf
More logging
rchiodo 95a5339
More logging
rchiodo 94819ff
More logging
rchiodo 462990f
Try a different way to run to see if python works
rchiodo b9336b5
Remove grep
rchiodo 3dc4d58
Add comment about environment
rchiodo 24946b6
Merge remote-tracking branch 'origin/master' into rchiodo/split_funct…
rchiodo f7ce254
Try fixing the infinite loop on session shutdown
rchiodo 089e0ca
Fix file system failures
rchiodo 6222116
Increase timeout and fix flakey test
rchiodo 6407b64
Fix path comparisons
rchiodo 17125d8
Add more indicators on the output name
rchiodo 0aadb59
Remove unused file
rchiodo a2b1087
Fix unit tests
rchiodo a6189ac
Remove splitting on PRs and fix the current directory test
rchiodo 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
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// This script will run all of the functional tests for each functional test file in sequence | ||
// This prevents mocha from running out of memory when running all of the tests | ||
// | ||
// This could potentially be improved to run tests in parallel (try that later) | ||
// | ||
// Additionally this was written in python at first but running python on an azure | ||
// machine may pick up an invalid environment for the subprocess. Node doesn't have this problem | ||
var path = require('path'); | ||
var glob = require('glob'); | ||
var child_process = require('child_process'); | ||
|
||
// Create a base for the output file | ||
var originalMochaFile = process.env['MOCHA_FILE']; | ||
var mochaFile = originalMochaFile || './test-results.xml'; | ||
var mochaBaseFile = path.join(path.dirname(mochaFile), path.basename(mochaFile, '.xml')); | ||
var mochaFileExt = '.xml'; | ||
|
||
// Wrap async code in a function so can wait till done | ||
async function main() { | ||
console.log('Globbing files for functional tests'); | ||
|
||
// Glob all of the files that we usually send to mocha as a group (see mocha.functional.opts.xml) | ||
var files = await new Promise((resolve, reject) => { | ||
glob('./out/test/**/*.functional.test.js', (ex, res) => { | ||
if (ex) { | ||
reject(ex); | ||
} else { | ||
resolve(res); | ||
} | ||
}); | ||
}); | ||
|
||
// Iterate over them, running mocha on each | ||
var returnCode = 0; | ||
|
||
// Go through each one at a time | ||
try { | ||
for (var index = 0; index < files.length; index += 1) { | ||
// Each run with a file will expect a $MOCHA_FILE$ variable. Generate one for each | ||
// Note: this index is used as a pattern when setting mocha file in the test_phases.yml | ||
var subMochaFile = `${mochaBaseFile}_${index}_${path.basename(files[index])}${mochaFileExt}`; | ||
process.env['MOCHA_FILE'] = subMochaFile; | ||
var exitCode = await new Promise((resolve) => { | ||
// Spawn the sub node process | ||
var proc = child_process.fork('./node_modules/mocha/bin/_mocha', [ | ||
files[index], | ||
'--require=out/test/unittests.js', | ||
'--exclude=out/**/*.jsx', | ||
'--reporter=mocha-multi-reporters', | ||
'--reporter-option=configFile=build/.mocha-multi-reporters.config', | ||
'--ui=tdd', | ||
'--recursive', | ||
'--colors', | ||
'--exit', | ||
'--timeout=180000' | ||
]); | ||
proc.on('exit', resolve); | ||
}); | ||
|
||
// If failed keep track | ||
if (exitCode !== 0) { | ||
console.log(`Functional tests for ${files[index]} failed.`); | ||
returnCode = exitCode; | ||
} | ||
} | ||
} catch (ex) { | ||
console.log(`Functional tests run failure: ${ex}.`); | ||
returnCode = -1; | ||
} | ||
|
||
// Reset the mocha file variable | ||
if (originalMochaFile) { | ||
process.env['MOCHA_FILE'] = originalMochaFile; | ||
} | ||
|
||
// Indicate error code | ||
console.log(`Functional test run result: ${returnCode}`); | ||
process.exit(returnCode); | ||
} | ||
|
||
// Call the main function. It will exit when promise is finished. | ||
main(); |
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.
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.
THis file didn't change as much as it looks. I just formatted it.