Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions addon-test-support/-private/patch-test-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,4 @@ import splitTestModules from './split-test-modules';

export default function patchTestLoader(TestLoader) {
TestLoader._urlParams = getUrlParams();

const _super = {
require: TestLoader.prototype.require,
unsee: TestLoader.prototype.unsee,
loadModules: TestLoader.prototype.loadModules,
};

// "Require" the module by adding it to the array of test modules to load
TestLoader.prototype.require = function _emberExamRequire(name) {
this._testModules.push(name);
};

// Make unsee a no-op to avoid any unwanted resets
TestLoader.prototype.unsee = function _emberExamUnsee() {};

TestLoader.prototype.loadModules = function _emberExamLoadModules() {
const urlParams = TestLoader._urlParams;
let partitions = urlParams._partition;
let split = parseInt(urlParams._split, 10);

split = isNaN(split) ? 1 : split;

if (partitions === undefined) {
partitions = [1];
} else if (!Array.isArray(partitions)) {
partitions = [partitions];
}

const testLoader = this;

testLoader._testModules = [];
_super.loadModules.apply(testLoader, arguments);

const splitModules = splitTestModules(testLoader._testModules, split, partitions);

splitModules.forEach((moduleName) => {
_super.require.call(testLoader, moduleName);
_super.unsee.call(testLoader, moduleName);
});
};
}
42 changes: 41 additions & 1 deletion addon-test-support/load.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import getTestLoader from './-private/get-test-loader';
import patchTestLoader from './-private/patch-test-loader';
import patchTestemOutput from './-private/patch-testem-output';
import patchTestLoader from './-private/patch-test-loader';
import qunit from 'qunit';
import { loadTests, start as qunitStart } from 'ember-cli-qunit';

let loaded = false;

Expand All @@ -23,3 +25,41 @@ export default function loadEmberExam() {

return LOAD_SUCCESS;
}

export function start() {
loadTests();

let urlParams = qunit.urlParams;
let totalPartitions = parseInt(urlParams._split) || 1;
let partitions = urlParams._partition;

if (partitions === undefined) {
partitions = [1];
} else if (!Array.isArray(partitions)) {
partitions = [partitions];
}

partitions = partitions.map(function(num) {
return +num;
});

if (totalPartitions > 0) {
let testIds = qunit.config.modules.reduce(function(tests, m) {
return tests.concat(m.tests);
}, []).map(function(test) { return test.testId }).sort();

qunit.config.testId = [];
for (let i = 0; i < testIds.length; ++i) {
let testPartition = (i % totalPartitions) + 1;
if (partitions.includes(testPartition)) {
qunit.config.testId.push(testIds[i]);
}
}

// refill the queue
qunit.config.queue = [];
loadTests();
}

qunitStart({ loadTests: false });
}