[#25] Adding proper dirname to combined tests
parent
9b629b8b61
commit
0d0372cb87
|
@ -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 "};"
|
||||
|
|
|
@ -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 ];
|
||||
|
|
Loading…
Reference in New Issue