From 2c978f6dba22db6070d98edb6edca53011dd9ad5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 2 Dec 2020 17:15:48 +0300 Subject: [PATCH] fix(core): Isolate 3rd party libraries used by busted from tests --- busted/core.lua | 10 +++++----- busted/init.lua | 10 +++++----- busted/runner.lua | 11 ++++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/busted/core.lua b/busted/core.lua index c375dd9f..22bd9b72 100644 --- a/busted/core.lua +++ b/busted/core.lua @@ -11,9 +11,9 @@ end local getfenv = require 'busted.compatibility'.getfenv local setfenv = require 'busted.compatibility'.setfenv local unpack = require 'busted.compatibility'.unpack -local path = require 'pl.path' -local pretty = require 'pl.pretty' -local system = require 'system' +local path = busted_require 'pl.path' +local pretty = busted_require 'pl.pretty' +local system = busted_require 'system' local throw = error local failureMt = { @@ -52,13 +52,13 @@ local function isCallable(obj) end return function() - local mediator = require 'mediator'() - local busted = {} busted.version = '2.0.0-0' busted.require = busted_require + local mediator = busted.require 'mediator'() + local root = require 'busted.context'() busted.context = root.ref() diff --git a/busted/init.lua b/busted/init.lua index 5092960c..06023ea8 100644 --- a/busted/init.lua +++ b/busted/init.lua @@ -87,11 +87,11 @@ local function init(busted) busted.hide('file') - local assert = require 'luassert' - local spy = require 'luassert.spy' - local mock = require 'luassert.mock' - local stub = require 'luassert.stub' - local match = require 'luassert.match' + local assert = busted.require 'luassert' + local spy = busted.require 'luassert.spy' + local mock = busted.require 'luassert.mock' + local stub = busted.require 'luassert.stub' + local match = busted.require 'luassert.match' local fixture_path = require('busted.fixtures').fixture_path diff --git a/busted/runner.lua b/busted/runner.lua index 274a3c39..d852660d 100644 --- a/busted/runner.lua +++ b/busted/runner.lua @@ -1,8 +1,5 @@ -- Busted command-line runner -local path = require 'pl.path' -local tablex = require 'pl.tablex' -local term = require 'term' local utils = require 'busted.utils' local exit = require 'busted.compatibility'.exit local loadstring = require 'busted.compatibility'.loadstring @@ -11,12 +8,16 @@ local loaded = false return function(options) if loaded then return function() end else loaded = true end + local busted = require 'busted.core'() + + local path = busted.require 'pl.path' + local tablex = busted.require 'pl.tablex' + local term = busted.require 'term' + local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout) options = tablex.update(require 'busted.options', options or {}) options.output = options.output or (isatty and 'utfTerminal' or 'plainTerminal') - local busted = require 'busted.core'() - local cli = require 'busted.modules.cli'(options) local filterLoader = require 'busted.modules.filter_loader'() local helperLoader = require 'busted.modules.helper_loader'()