From 64eeb091b8a34911c4cced63e186cedb9a7f002c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 14 Jul 2013 16:47:17 -0700 Subject: [PATCH] Dynamically create absolute path in test runners. Former-commit-id: b6b7daef445b3750e687b3559966def1f2b165d3 --- test/index.html | 17 ++++++++++------- test/underscore.html | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/index.html b/test/index.html index a04fcf54d..0d40f3e6d 100644 --- a/test/index.html +++ b/test/index.html @@ -53,17 +53,20 @@ if (!window.require) { return; } - var modulePath = ui.buildPath.replace(/\.js$/, ''), - reBasename = /[\w.-]+$/; + var reBasename = /[\w.-]+$/, + basePath = (location.origin + location.pathname).split(/\btest\b/).slice(0, -1).join('test'), + modulePath = ui.buildPath.replace(/\.js$/, ''), + moduleMain = modulePath.match(reBasename)[0]; var locationPath = /modularize/.test(ui.urlParams.build) ? '../modularize' : modulePath.replace(reBasename, ''); - var testPath = ( - (window.curl ? ui.loaderPath.replace(reBasename, 'curl/plugin/js!') : '') + - 'test.js' - ); + var pluginPath = window.curl + ? ui.loaderPath.replace(reBasename, 'curl/plugin/js!') + : ''; + + var testPath = pluginPath + basePath + '/test/test.js'; QUnit.config.autostart = false; @@ -83,7 +86,7 @@ { 'name': 'lodash', 'location': locationPath, - 'main': 'lodash' + 'main': moduleMain } ], 'shim': { diff --git a/test/underscore.html b/test/underscore.html index 4480a3b03..67adf1ac6 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -107,8 +107,10 @@ init(_); return; } - var modulePath = ui.buildPath.replace(/\.js$/, ''), - reBasename = /[\w.-]+$/; + var reBasename = /[\w.-]+$/, + basePath = (location.origin + location.pathname).split(/\btest\b/).slice(0, -1).join('test'), + modulePath = ui.buildPath.replace(/\.js$/, ''), + moduleMain = modulePath.match(reBasename)[0]; var locationPath = /modularize/.test(ui.urlParams.build) ? '../modularize' @@ -128,18 +130,18 @@ { 'name': 'lodash', 'location': locationPath, - 'main': 'lodash' + 'main': moduleMain } ] }, ['lodash'], function(lodash) { init(lodash); require([ - pluginPath + '/vendor/underscore/test/collections.js', - pluginPath + '/vendor/underscore/test/arrays.js', - pluginPath + '/vendor/underscore/test/functions.js', - pluginPath + '/vendor/underscore/test/objects.js', - pluginPath + '/vendor/underscore/test/utility.js' + pluginPath + basePath + '/vendor/underscore/test/collections.js', + pluginPath + basePath + '/vendor/underscore/test/arrays.js', + pluginPath + basePath + '/vendor/underscore/test/functions.js', + pluginPath + basePath + '/vendor/underscore/test/objects.js', + pluginPath + basePath + '/vendor/underscore/test/utility.js' ], function() { QUnit.start(); });