diff options
Diffstat (limited to 'test/lua/busted/modules/helper_loader.lua')
-rw-r--r-- | test/lua/busted/modules/helper_loader.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lua/busted/modules/helper_loader.lua b/test/lua/busted/modules/helper_loader.lua new file mode 100644 index 000000000..166f7ccd1 --- /dev/null +++ b/test/lua/busted/modules/helper_loader.lua @@ -0,0 +1,23 @@ +local utils = require 'busted.utils' +local hasMoon, moonscript = pcall(require, 'moonscript') + +return function() + local loadHelper = function(helper, hpath, options, busted) + local success, err = pcall(function() + arg = options.arguments + if helper:match('%.lua$') then + dofile(utils.normpath(hpath)) + elseif hasMoon and helper:match('%.moon$') then + moonscript.dofile(utils.normpath(hpath)) + else + require(helper) + end + end) + + if not success then + busted.publish({ 'error', 'helper' }, { descriptor = 'helper', name = helper }, nil, err, {}) + end + end + + return loadHelper +end |