From 00d3f653a8c2819e35f8347be9f6424200f13dea Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 17 Jul 2017 13:36:56 +0200 Subject: [PATCH] Improved loading of pretty. --- init.lua | 5 ++++- test/test_analyze_structure.lua | 2 +- test/test_function.lua | 2 +- test/test_number.lua | 2 +- test/test_pretty.lua | 4 +++- test/test_resilience.lua | 2 +- test/test_sorting.lua | 2 +- test/tests.lua | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 254ef11..f4c759c 100644 --- a/init.lua +++ b/init.lua @@ -1 +1,4 @@ -return require 'pretty.pretty' + +local premodule = (...) +if premodule == 'init' then premodule = '' end +return require (premodule .. (premodule ~= '' and '.' or '') .. 'pretty') diff --git a/test/test_analyze_structure.lua b/test/test_analyze_structure.lua index 597858d..b9f95a3 100644 --- a/test/test_analyze_structure.lua +++ b/test/test_analyze_structure.lua @@ -1,5 +1,5 @@ -local SUITE = require('TestSuite').new('analyze_structure') +local SUITE = require 'TestSuite' 'analyze_structure' SUITE:setEnviroment { analyze_structure = require('analyze_structure'), TABLE_TYPE = require('table_type') diff --git a/test/test_function.lua b/test/test_function.lua index 2956023..faa257d 100644 --- a/test/test_function.lua +++ b/test/test_function.lua @@ -1,5 +1,5 @@ -local SUITE = require('TestSuite').new('function') +local SUITE = require 'TestSuite' 'function' SUITE:setEnviroment{ format = require('pretty') } diff --git a/test/test_number.lua b/test/test_number.lua index 17fe2f7..b62a2f9 100644 --- a/test/test_number.lua +++ b/test/test_number.lua @@ -1,5 +1,5 @@ -local SUITE = require('TestSuite').new('number') +local SUITE = require 'TestSuite' 'number' SUITE:setEnviroment{ format = require('pretty') } diff --git a/test/test_pretty.lua b/test/test_pretty.lua index bb72972..0c5f2aa 100644 --- a/test/test_pretty.lua +++ b/test/test_pretty.lua @@ -1,5 +1,5 @@ -local SUITE = require('TestSuite').new('pretty') +local SUITE = require 'TestSuite' 'pretty' SUITE:setEnviroment{ format = require('pretty') } @@ -395,6 +395,8 @@ SUITE:addTest('UseCase: Can load function from file that is shortly deleted', fu local yo = require(module_name) -- Remove module os.remove('./'..module_name..'.lua') + package.loaded[module_name] = nil + -- Format the function, even though the module it came from is gone. format(yo) assert(true) diff --git a/test/test_resilience.lua b/test/test_resilience.lua index 900684e..8b51098 100644 --- a/test/test_resilience.lua +++ b/test/test_resilience.lua @@ -22,7 +22,7 @@ end -------------------------------------------------------------------------------- -local SUITE = require('TestSuite').new('resilience') +local SUITE = require 'TestSuite' 'resilience' SUITE:setEnviroment{ pretty = require('pretty'), setfenv = setfenv, diff --git a/test/test_sorting.lua b/test/test_sorting.lua index 4859733..1d77b55 100644 --- a/test/test_sorting.lua +++ b/test/test_sorting.lua @@ -1,5 +1,5 @@ -local SUITE = require('TestSuite').new('sorting') +local SUITE = require 'TestSuite' 'sorting' SUITE:setEnviroment{ pretty = require('pretty') } diff --git a/test/tests.lua b/test/tests.lua index b9a6067..d8f331b 100644 --- a/test/tests.lua +++ b/test/tests.lua @@ -4,6 +4,6 @@ package.path = package.path .. ';./test/?.lua;./src/?.lua' local TEST_SUITE = require("TestSuite").new('pretty') TEST_SUITE:enableStrictGlobal() TEST_SUITE:addModules('test/test_*') --- TEST_SUITE:generateRequireSubmodule 'require' + TEST_SUITE:addModuleTests 'pretty' TEST_SUITE:setOptions(...) TEST_SUITE:runTests()