From 0d0372cb87db1753842ca0062e746c7b6bc4a0fa Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 23 Oct 2011 00:13:53 -0400 Subject: [PATCH] [#25] Adding proper dirname to combined tests --- tools/combine | 9 +++++++-- tools/combine.tpl | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/combine b/tools/combine index af2be8a..6fc726d 100755 --- a/tools/combine +++ b/tools/combine @@ -142,7 +142,11 @@ if [ "$INC_TEST" ]; then ) # find include files separately so we can output those before the tests - TEST_INC=$( find $PATH_TEST -name 'inc-*.js' -exec basename {} \; ) + TEST_INC=$( + cd "$PATH_TEST" \ + && find . -name 'inc-*.js' \ + | sed 's/^\.\///' \ + ) # include test combine template cat "$TPL_TEST_PATH" | grep -v '^#' | $RMTRAIL @@ -158,6 +162,7 @@ if [ "$INC_TEST" ]; then # prefixing it with "test/" module="${filename%.*}" module="test/${module##*test/}" + module_dir=$( dirname "$module" ) # each module must be enclosed in a closure to emulate a module echo "/** TEST CASE: $testcase **/" @@ -172,7 +177,7 @@ if [ "$INC_TEST" ]; then # add the module, removing trailing commas cat $filename | $RMTRAIL - echo "} )( module['$module'] = {}, 'test' );" + echo "} )( module['$module'] = {}, '$module_dir' );" done echo "};" diff --git a/tools/combine.tpl b/tools/combine.tpl index e4c1625..67496f8 100644 --- a/tools/combine.tpl +++ b/tools/combine.tpl @@ -41,9 +41,8 @@ var easejs = {}; var require = function( module_id ) { // remove the './' directory prefix (every module is currently included - // via a relative path) and stupidly remove single ../'s (combine script - // doesn't include true paths, so they're not necessary to resolve) - var id_clean = module_id.replace( /^\.?\/|\.\.\//, '' ); + // via a relative path), stupidly remove ../'s and remove .js extensions + var id_clean = module_id.replace( /^\.?\/|[^/]*?\/\.\.\/|\.js$/, '' ); // attempt to retrieve the module var mod = module[ id_clean ];