-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Shard gl jasmine tests #2933
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
Shard gl jasmine tests #2933
Changes from 10 commits
635b643
53657e7
02308d0
094e06d
c9a4eb5
e23ee6e
6d8da96
ba753c4
8170900
7712507
bdf468e
689671b
c88bdbb
6c29290
6daf432
006d5d1
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,94 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var falafel = require('falafel'); | ||
var glob = require('glob'); | ||
var minimist = require('minimist'); | ||
|
||
var pathToJasmineTests = require('./util/constants').pathToJasmineTests; | ||
var isJasmineTestIt = require('./util/common').isJasmineTestIt; | ||
|
||
var argv = minimist(process.argv.slice(2), { | ||
string: ['tag', 'limit'], | ||
alias: { | ||
tag: ['t'], | ||
limit: ['l'], | ||
}, | ||
default: { | ||
limit: 20 | ||
} | ||
}); | ||
|
||
var tag = argv.tag; | ||
var limit = argv.limit; | ||
|
||
glob(path.join(pathToJasmineTests, '*.js'), function(err, files) { | ||
if(err) throw err; | ||
|
||
var file2cnt = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to note, with
|
||
|
||
files.forEach(function(file) { | ||
var code = fs.readFileSync(file, 'utf-8'); | ||
var bn = path.basename(file); | ||
|
||
falafel(code, function(node) { | ||
if(isJasmineTestIt(node, tag)) { | ||
if(file2cnt[bn]) { | ||
file2cnt[bn]++; | ||
} else { | ||
file2cnt[bn] = 1; | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
var ranking = Object.keys(file2cnt); | ||
var runs = []; | ||
|
||
// if 'it' count in file greater than threshold, | ||
// run only this file separately, | ||
// don't try to shard within file | ||
Object.keys(file2cnt).forEach(function(f) { | ||
if(file2cnt[f] > limit) { | ||
runs.push(f); | ||
ranking.splice(ranking.indexOf(f), 1); | ||
} | ||
}); | ||
|
||
// sort ranking in decreasing order | ||
ranking.sort(function(a, b) { return file2cnt[b] - file2cnt[a]; }); | ||
|
||
var runi; | ||
var cnt; | ||
|
||
function newRun() { | ||
var r0 = ranking[0]; | ||
runi = [r0]; | ||
cnt = file2cnt[r0]; | ||
ranking.shift(); | ||
} | ||
|
||
function concat() { | ||
runs.push(runi.join(',')); | ||
} | ||
|
||
// try to match files with many tests with files not-that-many, | ||
// by matching first rank with one or multiple trailing ranks. | ||
newRun(); | ||
while(ranking.length) { | ||
var rn = ranking[ranking.length - 1]; | ||
|
||
if((cnt + file2cnt[rn]) > limit) { | ||
concat(); | ||
newRun(); | ||
} else { | ||
runi.push(rn); | ||
cnt += file2cnt[rn]; | ||
ranking.pop(); | ||
} | ||
} | ||
concat(); | ||
|
||
// print result to stdout | ||
console.log(runs.join('\n')); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,10 @@ func.defaultConfig = { | |
suppressSkipped: false, | ||
showSpecTiming: false, | ||
failFast: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More on this topic: to make When doing so, it conflicts with There might be a way, to list them (order dependent?) so that they don't conflict, but using |
||
} | ||
}, | ||
|
||
// e.g. when a test file does not container a given spec tags | ||
failOnEmptyTestSuite: false | ||
}; | ||
|
||
func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify']; | ||
|
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.
node tasks/shard_jasmine_tests.js --tag=gl
outputs:which is then converted into a bash array (that's the outer
()
) and then looped below.