[Framework] Update test runner

Update test runner to provide analogous require configuration
behavior, such that scripts which utilize libraries exposed
from bundles via bundle.json can be unit tested appropriately.
Necessary after capabilities added by WTD-568.
This commit is contained in:
Victor Woeltjen 2015-01-02 18:18:03 -08:00
parent 95e299622e
commit 32ab324eee

View File

@ -110,7 +110,9 @@
// Run all test suites contained in all bundles // Run all test suites contained in all bundles
function runSuites(bundles) { function runSuites(bundles) {
var components = [], count = 0; var components = [],
configuration = { baseUrl: "" },
count = 0;
function addSuite(bundle) { function addSuite(bundle) {
function fixPath(name) { function fixPath(name) {
@ -124,6 +126,7 @@
components = components.concat(suiteSpecs.map(fixPath)); components = components.concat(suiteSpecs.map(fixPath));
count += 1; count += 1;
if (count === bundles.length) { if (count === bundles.length) {
require.config(configuration);
runSpecs(components); runSpecs(components);
} }
} }
@ -131,7 +134,36 @@
loadJSON(bundle + "/test/suite.json", addSpecs); loadJSON(bundle + "/test/suite.json", addSpecs);
} }
bundles.forEach(addSuite); // Some AMD modules are configured in bundle.json files,
// so those need to be read and a require definition built
function readConfig(bundle, definition) {
var lib = bundle.libraries || "lib",
bundleConfig = definition.configuration || {};
// Merge in paths
Object.keys(bundleConfig.paths || {}).forEach(function (path) {
configuration.paths = configuration.paths || {};
configuration.paths[path] =
bundle + "/" + lib + "/" + bundleConfig.paths[path];
});
// Merge in shims
Object.keys(bundleConfig.shim || {}).forEach(function (shim) {
configuration.shim = configuration.shim || {};
configuration.shim[shim] = bundleConfig.shim[shim];
});
}
function addBundle(bundle) {
function readConfigAndContinue(definition) {
readConfig(bundle, definition);
addSuite(bundle);
}
loadJSON(bundle + "/bundle.json", readConfigAndContinue);
}
bundles.forEach(addBundle);
} }
// Set the ball rolling; load and run all test suites // Set the ball rolling; load and run all test suites