Avoid packages config for monolithic modules in tests.

This commit is contained in:
John-David Dalton
2014-02-15 14:07:29 -08:00
parent 76f85389ae
commit 486ba5fe0a
2 changed files with 56 additions and 44 deletions

View File

@@ -186,48 +186,55 @@
var reBasename = /[\w.-]+$/, var reBasename = /[\w.-]+$/,
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''), basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
modulePath = ui.buildPath.replace(/\.js$/, ''), modulePath = ui.buildPath.replace(/\.js$/, ''),
locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
moduleMain = modulePath.match(reBasename)[0], moduleMain = modulePath.match(reBasename)[0],
locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
shimmedLocationPath = './abc/../' + locationPath,
underscoreLocationPath = './xyz/../' + locationPath,
uid = +new Date; uid = +new Date;
function getConfig() { function getConfig() {
return { var result = {
'baseUrl': './', 'baseUrl': './',
'urlArgs': 't=' + uid++, 'urlArgs': 't=' + uid++,
'waitSeconds': 0, 'waitSeconds': 0,
'packages': [ 'paths': {},
{ 'packages': [{
'name': 'lodash', 'name': 'test',
'location': locationPath, 'location': basePath + 'test',
'main': moduleMain 'main': 'test',
}, 'config': {
{ // work around no global being exported
'name': 'shimmed', 'exports': 'QUnit',
'location': './abc/../' + locationPath, 'loader': 'curl/loader/legacy'
'main': moduleMain
},
{
'name': 'underscore',
'location': './xyz/../' + locationPath,
'main': moduleMain
},
{
'name': 'test',
'location': basePath + 'test',
'main': 'test',
'config': {
// work around no global being exported
'exports': 'QUnit',
'loader': 'curl/loader/legacy'
}
} }
], }],
'shim': { 'shim': {
'shimmed': { 'shimmed': {
'exports': '_' 'exports': '_'
} }
} }
}; };
if (ui.isModularize) {
result.packages.push({
'name': 'lodash',
'location': locationPath,
'main': moduleMain
}, {
'name': 'shimmed',
'location': shimmedLocationPath,
'main': moduleMain
}, {
'name': 'underscore',
'location': underscoreLocationPath,
'main': moduleMain
});
} else {
result.paths.lodash = modulePath;
result.paths.shimmed = shimmedLocationPath + '/' + moduleMain;
result.paths.underscore = underscoreLocationPath + '/' + moduleMain;
}
return result;
} }
function loadTests() { function loadTests() {

View File

@@ -151,27 +151,32 @@
uid = +new Date; uid = +new Date;
function getConfig() { function getConfig() {
return { var result = {
'baseUrl': './', 'baseUrl': './',
'urlArgs': 't=' + uid++, 'urlArgs': 't=' + uid++,
'waitSeconds': 0, 'waitSeconds': 0,
'packages': [ 'paths': {},
{ 'packages': [{
'name': moduleId, 'name': 'test',
'location': locationPath, 'location': '../vendor/underscore/test',
'main': moduleMain 'config': {
}, // work around no global being exported
{ 'exports': 'QUnit',
'name': 'test', 'loader': 'curl/loader/legacy'
'location': '../vendor/underscore/test',
'config': {
// work around no global being exported
'exports': 'QUnit',
'loader': 'curl/loader/legacy'
}
} }
] }]
}; };
if (ui.isModularize) {
result.packages.push({
'name': moduleId,
'location': locationPath,
'main': moduleMain
});
} else {
result.paths[moduleId] = modulePath;
}
return result;
} }
QUnit.config.autostart = false; QUnit.config.autostart = false;