Skip to content

Commit

Permalink
fix(core): Isolate 3rd party libraries used by busted from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 25, 2022
1 parent ca35d6d commit 2c978f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions busted/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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()

Expand Down
10 changes: 5 additions & 5 deletions busted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions busted/runner.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'()
Expand Down

0 comments on commit 2c978f6

Please sign in to comment.