Skip to content

Commit 830d0a9

Browse files
committed
circleci: run test-image in parallel
1 parent b38e4a8 commit 830d0a9

File tree

3 files changed

+48
-21
lines changed

3 files changed

+48
-21
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
test-image:
7878
docker:
7979
- image: plotly/testbed:latest
80+
parallelism: 2
8081
working_directory: /var/www/streambed/image_server/plotly.js/
8182
steps:
8283
- attach_workspace:

.circleci/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ case $1 in
7575
;;
7676

7777
image)
78-
npm run test-image || EXIT_STATE=$?
78+
SUITE=$(find $ROOT/test/image/mocks/ -type f -printf "%f\n" | circleci tests split)
79+
npm run test-image -- $SUITE --filter || EXIT_STATE=$?
7980
exit $EXIT_STATE
8081
;;
8182

test/image/compare_pixels_test.js

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var fs = require('fs');
2+
var minimist = require('minimist');
23

34
var common = require('../../tasks/util/common');
45
var getMockList = require('./assets/get_mock_list');
@@ -48,37 +49,61 @@ var QUEUE_WAIT = 10;
4849
* npm run test-image -- gl3d_* --queue
4950
*/
5051

51-
var pattern = process.argv[2];
52-
var mockList = getMockList(pattern);
53-
var isInQueue = (process.argv[3] === '--queue');
52+
var argv = minimist(process.argv.slice(2), {boolean: ['queue', 'filter' ]});
53+
var isInQueue = argv.queue;
54+
var filter = argv.filter;
5455

55-
if(mockList.length === 0) {
56-
throw new Error('No mocks found with pattern ' + pattern);
56+
var allMock = false;
57+
// If no pattern is provided, all mocks are compared
58+
if(argv._.length === 0) {
59+
allMock = true;
60+
argv._.push('');
5761
}
5862

59-
// filter out untestable mocks if no pattern is specified
60-
if(!pattern) {
61-
console.log('Filtering out untestable mocks:');
62-
mockList = mockList.filter(untestableFilter);
63-
console.log('\n');
64-
}
63+
// Build list of mocks to compare
64+
var allMockList = [];
65+
argv._.forEach(function(pattern) {
66+
var mockList = getMockList(pattern);
6567

66-
// gl2d have limited image-test support
67-
if(pattern === 'gl2d_*') {
68-
if(!isInQueue) {
69-
console.log('WARN: Running gl2d image tests in batch may lead to unwanted results\n');
68+
if(mockList.length === 0) {
69+
throw new Error('No mocks found with pattern ' + pattern);
70+
}
71+
72+
// gl2d have limited image-test support
73+
if(pattern === 'gl2d_*') {
74+
if(!isInQueue) {
75+
console.log('WARN: Running gl2d image tests in batch may lead to unwanted results\n');
76+
}
77+
console.log('\nSorting gl2d mocks to avoid gl-shader conflicts');
78+
sortGl2dMockList(mockList);
79+
console.log('');
7080
}
71-
console.log('\nSorting gl2d mocks to avoid gl-shader conflicts');
72-
sortGl2dMockList(mockList);
73-
console.log('');
81+
82+
allMockList = allMockList.concat(mockList);
83+
});
84+
85+
// To get rid of duplicates
86+
Array.prototype.unique = function() {
87+
return this.filter(function(value, index, self) {
88+
return self.indexOf(value) === index;
89+
});
90+
};
91+
allMockList = allMockList.unique();
92+
93+
// filter out untestable mocks if no pattern is specified (ie. we're testing all mocks)
94+
// or if flag '--filter' is provided
95+
if(allMock || filter) {
96+
console.log('Filtering out untestable mocks:');
97+
allMockList = allMockList.filter(untestableFilter);
98+
console.log('\n');
7499
}
75100

76101
// main
77102
if(isInQueue) {
78-
runInQueue(mockList);
103+
runInQueue(allMockList);
79104
}
80105
else {
81-
runInBatch(mockList);
106+
runInBatch(allMockList);
82107
}
83108

84109
/* Test cases:

0 commit comments

Comments
 (0)