From 4e8c650d7daac769f9af843b1578dd2521318972 Mon Sep 17 00:00:00 2001 From: George Roman Date: Fri, 1 Jun 2018 00:05:49 +0300 Subject: Tests: replace #blackbox with #integration and #whitebox with #unit --- spec/add_spec.lua | 2 +- spec/build_spec.lua | 2 +- spec/config_spec.lua | 2 +- spec/deps_spec.lua | 2 +- spec/doc_spec.lua | 4 +--- spec/download_spec.lua | 2 +- spec/fetch_spec.lua | 17 +++++++------- spec/fs_spec.lua | 2 +- spec/fun_spec.lua | 2 +- spec/help_spec.lua | 2 +- spec/install_spec.lua | 2 +- spec/lint_spec.lua | 2 +- spec/list_spec.lua | 2 +- spec/make_manifest_spec.lua | 2 +- spec/make_spec.lua | 2 +- spec/new_version_spec.lua | 2 +- spec/pack_spec.lua | 4 +--- spec/path_spec.lua | 2 +- spec/persist.lua | 55 -------------------------------------------- spec/persist_spec.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++ spec/purge_spec.lua | 4 +--- spec/refresh_cache_spec.lua | 2 +- spec/remove_spec.lua | 2 +- spec/search_spec.lua | 2 +- spec/show_spec.lua | 2 +- spec/test_spec.lua | 2 +- spec/unpack_spec.lua | 4 +--- spec/upload_spec.lua | 3 +-- spec/util_spec.lua | 4 ++-- spec/write_rockspec_spec.lua | 2 +- test/README.md | 29 ++++++----------------- 31 files changed, 98 insertions(+), 123 deletions(-) delete mode 100644 spec/persist.lua create mode 100644 spec/persist_spec.lua diff --git a/spec/add_spec.lua b/spec/add_spec.lua index 1bc9e2a3..394b8f8a 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua @@ -9,7 +9,7 @@ local extra_rocks = { "/luasocket-3.0rc1-2.rockspec" } -describe("LuaRocks add tests #blackbox #b_add", function() +describe("LuaRocks add tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 2e7333b3..5f1eefd0 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -28,7 +28,7 @@ local extra_rocks = { "/validate-args-1.5.4-1.rockspec" } -describe("LuaRocks build tests #blackbox #b_build", function() +describe("LuaRocks build tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/config_spec.lua b/spec/config_spec.lua index fae68474..94757244 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -7,7 +7,7 @@ local site_config test_env.unload_luarocks() -describe("LuaRocks config tests #blackbox #b_config", function() +describe("LuaRocks config tests #integration", function() before_each(function() test_env.setup_specs() diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index 67c1335f..846434f4 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua @@ -13,7 +13,7 @@ local extra_rocks = { "/lpeg-1.0.0-1.src.rock", } -describe("LuaRocks deps tests #blackbox #b_deps", function() +describe("LuaRocks deps tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index 6d91fc00..c7cacc94 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua @@ -9,7 +9,7 @@ local extra_rocks = { "/c3-1.0-1.src.rock" } -describe("LuaRocks doc tests #blackbox #b_doc", function() +describe("LuaRocks doc tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) @@ -75,5 +75,3 @@ describe("LuaRocks doc tests #blackbox #b_doc", function() end) end) end) - - diff --git a/spec/download_spec.lua b/spec/download_spec.lua index 152470a5..39f5b056 100644 --- a/spec/download_spec.lua +++ b/spec/download_spec.lua @@ -9,7 +9,7 @@ local extra_rocks = { "/validate-args-1.5.4-1.rockspec" } -describe("LuaRocks download tests #blackbox #b_download", function() +describe("LuaRocks download tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index c98a3de3..fa614349 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua @@ -8,11 +8,10 @@ local lfs = require("lfs") local testing_paths = test_env.testing_paths local get_tmp_path = test_env.get_tmp_path -describe("Luarocks fetch test #blackbox #b_fetch", function() +describe("Luarocks fetch test #unit", function() local are_same_files = function(file1, file2) return file1 == file2 or lfs.attributes(file1).ino == lfs.attributes(file2).ino - end - + end describe("fetch.is_basic_protocol", function() it("checks whether the arguments represent a valid protocol and returns the result of the check", function() @@ -25,7 +24,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.fetch_url", function() + describe("fetch.fetch_url #mock", function() setup(function() test_env.mock_server_init() end) @@ -61,7 +60,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.fetch_url_at_temp_dir", function() + describe("fetch.fetch_url_at_temp_dir #mock", function() local tmpfile local tmpdir @@ -129,7 +128,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.find_base_dir", function() + describe("fetch.find_base_dir #mock", function() setup(function() test_env.mock_server_init() end) @@ -160,7 +159,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.fetch_and_unpack_rock", function() + describe("fetch.fetch_and_unpack_rock #mock", function() local tmpdir after_each(function() @@ -271,7 +270,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.load_rockspec", function() + describe("fetch.load_rockspec #mock", function() setup(function() test_env.mock_server_init() end) @@ -318,7 +317,7 @@ describe("Luarocks fetch test #blackbox #b_fetch", function() end) end) - describe("fetch.get_sources", function() + describe("fetch.get_sources #mock", function() setup(function() test_env.mock_server_init() end) diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index b250e321..c0679b34 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua @@ -8,7 +8,7 @@ local posix_ok = pcall(require, "posix") local testing_paths = test_env.testing_paths local get_tmp_path = test_env.get_tmp_path -describe("Luarocks fs test #whitebox #w_fs", function() +describe("Luarocks fs test #unit", function() local exists_file = function(path) local ok, err, code = os.rename(path, path) if not ok and code == 13 then diff --git a/spec/fun_spec.lua b/spec/fun_spec.lua index b5bed0da..259a3148 100644 --- a/spec/fun_spec.lua +++ b/spec/fun_spec.lua @@ -3,7 +3,7 @@ local fun = require("luarocks.fun") test_env.unload_luarocks() -describe("LuaRocks fun tests", function() +describe("LuaRocks fun tests #unit", function() describe("fun.concat", function() it("returns the concatenation of the two tables given as arguments", function() local t1, t2 diff --git a/spec/help_spec.lua b/spec/help_spec.lua index f7bb79b3..93b89ce7 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua @@ -3,7 +3,7 @@ local run = test_env.run test_env.unload_luarocks() -describe("LuaRocks help tests #blackbox #b_help", function() +describe("LuaRocks help tests #integration", function() before_each(function() test_env.setup_specs() diff --git a/spec/install_spec.lua b/spec/install_spec.lua index b4273692..3525cda3 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -27,7 +27,7 @@ local extra_rocks = { "/sailor-0.5-4.src.rock", } -describe("luarocks install #blackbox #b_install", function() +describe("luarocks install #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index 1c082b2a..e7af97fa 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua @@ -8,7 +8,7 @@ local extra_rocks = { "/validate-args-1.5.4-1.rockspec" } -describe("LuaRocks lint tests #blackbox #b_lint", function() +describe("LuaRocks lint tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/list_spec.lua b/spec/list_spec.lua index e4bb7b45..9cf4f0a8 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua @@ -9,7 +9,7 @@ local extra_rocks = { "/say-1.2-1.src.rock" } -describe("LuaRocks list tests #blackbox #b_list", function() +describe("LuaRocks list tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua index 2b109fa7..a33b1f5b 100644 --- a/spec/make_manifest_spec.lua +++ b/spec/make_manifest_spec.lua @@ -3,7 +3,7 @@ local run = test_env.run test_env.unload_luarocks() -describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() +describe("LuaRocks make_manifest tests #integration", function() before_each(function() test_env.setup_specs() diff --git a/spec/make_spec.lua b/spec/make_spec.lua index bb219b68..6df0ab23 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua @@ -14,7 +14,7 @@ local extra_rocks = { "/lxsh-0.8.6-2.rockspec" } -describe("LuaRocks make tests #blackbox #b_make", function() +describe("LuaRocks make tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua index f3bb007e..22506d3c 100644 --- a/spec/new_version_spec.lua +++ b/spec/new_version_spec.lua @@ -10,7 +10,7 @@ local extra_rocks = { "/lpeg-0.12-1.rockspec" } -describe("LuaRocks new_version tests #blackbox #b_new_version", function() +describe("LuaRocks new_version tests #integration", function() setup(function() test_env.setup_specs(extra_rocks) diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 8fbade44..08647cfb 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -14,7 +14,7 @@ local extra_rocks = { "/say-1.0-1.src.rock" } -describe("LuaRocks pack #blackbox #b_pack", function() +describe("LuaRocks pack #integration", function() before_each(function() test_env.setup_specs(extra_rocks) @@ -93,5 +93,3 @@ describe("LuaRocks pack #blackbox #b_pack", function() end) end) - - diff --git a/spec/path_spec.lua b/spec/path_spec.lua index bbc0cfc8..0b115d5c 100644 --- a/spec/path_spec.lua +++ b/spec/path_spec.lua @@ -3,7 +3,7 @@ local run = test_env.run test_env.unload_luarocks() -describe("LuaRocks path tests #blackbox #b_path", function() +describe("LuaRocks path tests #integration", function() before_each(function() test_env.setup_specs() end) diff --git a/spec/persist.lua b/spec/persist.lua deleted file mode 100644 index 00a9b75d..00000000 --- a/spec/persist.lua +++ /dev/null @@ -1,55 +0,0 @@ -local test_env = require("spec.util.test_env") - -test_env.unload_luarocks() -local persist = require("luarocks.persist") - -describe("Luarocks persist test #whitebox #w_persist", function() - describe("persist.save_from_table_to_string", function() - it("simple table", function() - assert.are.same([[ -bar = 1234 -foo = "string" -]], persist.save_from_table_to_string({foo = "string", bar = 1234})) - end) - - it("nested tables", function() - assert.are.same([[ -bar = { - baz = "string" -} -foo = { - 1, 2, 3, 4 -} -]], persist.save_from_table_to_string({foo = {1, 2, 3, 4}, bar = {baz = "string"}})) - end) - - it("strings with quotes", function() - assert.are.same([[ -bar = "a \\backslash?" -foo = "a \"quote\"?" -]], persist.save_from_table_to_string({foo = 'a "quote"?', bar = 'a \\backslash?'})) - end) - - it("multiline strings", function() - assert.are.same([===[ -bar = [==[ -]] -]=]]==] -foo = [[ -First line -Second line]] -]===], persist.save_from_table_to_string({foo = "First line\nSecond line", bar = "]]\n]=]"})) - end) - - it("multiline strings ending with brackets", function() - assert.are.same([===[ -bar = [==[ -]] -]=]==] -foo = [=[ -First line -Second line [1]]=] -]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="})) - end) - end) -end) diff --git a/spec/persist_spec.lua b/spec/persist_spec.lua new file mode 100644 index 00000000..f61c7176 --- /dev/null +++ b/spec/persist_spec.lua @@ -0,0 +1,55 @@ +local test_env = require("spec.util.test_env") + +test_env.unload_luarocks() +local persist = require("luarocks.persist") + +describe("Luarocks persist test #unit", function() + describe("persist.save_from_table_to_string", function() + it("simple table", function() + assert.are.same([[ +bar = 1234 +foo = "string" +]], persist.save_from_table_to_string({foo = "string", bar = 1234})) + end) + + it("nested tables", function() + assert.are.same([[ +bar = { + baz = "string" +} +foo = { + 1, 2, 3, 4 +} +]], persist.save_from_table_to_string({foo = {1, 2, 3, 4}, bar = {baz = "string"}})) + end) + + it("strings with quotes", function() + assert.are.same([[ +bar = "a \\backslash?" +foo = "a \"quote\"?" +]], persist.save_from_table_to_string({foo = 'a "quote"?', bar = 'a \\backslash?'})) + end) + + it("multiline strings", function() + assert.are.same([===[ +bar = [==[ +]] +]=]]==] +foo = [[ +First line +Second line]] +]===], persist.save_from_table_to_string({foo = "First line\nSecond line", bar = "]]\n]=]"})) + end) + + it("multiline strings ending with brackets", function() + assert.are.same([===[ +bar = [==[ +]] +]=]==] +foo = [=[ +First line +Second line [1]]=] +]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="})) + end) + end) +end) diff --git a/spec/purge_spec.lua b/spec/purge_spec.lua index 79ad0dfd..18445b60 100644 --- a/spec/purge_spec.lua +++ b/spec/purge_spec.lua @@ -8,7 +8,7 @@ local extra_rocks = { "/say-1.0-1.src.rock", } -describe("LuaRocks purge tests #blackbox #b_purge", function() +describe("LuaRocks purge tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) end) @@ -34,5 +34,3 @@ describe("LuaRocks purge tests #blackbox #b_purge", function() end) end) end) - - diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua index 51c1572f..9bf0361c 100644 --- a/spec/refresh_cache_spec.lua +++ b/spec/refresh_cache_spec.lua @@ -3,7 +3,7 @@ local run = test_env.run test_env.unload_luarocks() -describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() +describe("LuaRocks refresh_cache tests #integration", function() before_each(function() test_env.setup_specs() diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 10ab012d..55264a75 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -12,7 +12,7 @@ local extra_rocks = { "/luasocket-3.0rc1-2.rockspec" } -describe("LuaRocks remove tests #blackbox #b_remove", function() +describe("LuaRocks remove tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 952458dd..90efb552 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua @@ -7,7 +7,7 @@ local extra_rocks = { "/lzlib-0.4.1.53-1.src.rock" } -describe("LuaRocks search tests #blackbox #b_search", function() +describe("LuaRocks search tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/show_spec.lua b/spec/show_spec.lua index a3f856fd..a721a692 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua @@ -4,7 +4,7 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() -describe("LuaRocks show #blackbox #b_show", function() +describe("LuaRocks show #integration", function() before_each(function() test_env.setup_specs() diff --git a/spec/test_spec.lua b/spec/test_spec.lua index 81dc5318..ffcf2ac0 100644 --- a/spec/test_spec.lua +++ b/spec/test_spec.lua @@ -18,7 +18,7 @@ local extra_rocks = { "/mediator_lua-1.1.2-0.rockspec", } -describe("luarocks test #blackbox #b_test", function() +describe("luarocks test #integration", function() before_each(function() test_env.setup_specs(extra_rocks) diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index fc02d853..1eb40f59 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua @@ -10,7 +10,7 @@ local extra_rocks = { "/luazip-1.2.4-1.rockspec" } -describe("LuaRocks unpack tests #blackbox #b_unpack", function() +describe("LuaRocks unpack tests #integration", function() before_each(function() test_env.setup_specs(extra_rocks) @@ -68,5 +68,3 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() end) end) end) - - diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index a54f21c5..abf2e43d 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -4,7 +4,7 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() -describe("LuaRocks upload tests #blackbox #b_upload", function() +describe("LuaRocks upload tests #integration", function() before_each(function() test_env.setup_specs() @@ -44,4 +44,3 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) end) end) - diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 209dae6f..ce309138 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -4,7 +4,7 @@ local run = test_env.run local testing_paths = test_env.testing_paths local env_variables = test_env.env_variables -describe("Basic tests #blackbox #b_util", function() +describe("Basic tests #integration", function() before_each(function() test_env.setup_specs() @@ -73,7 +73,7 @@ end) test_env.unload_luarocks() local util = require("luarocks.util") -describe("Luarocks util test #whitebox #w_util", function() +describe("Luarocks util test #unit", function() describe("util.sortedpairs", function() local function collect(iter, state, var) local collected = {} diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 95dc87ff..295eaa6b 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua @@ -3,7 +3,7 @@ local git_repo = require("spec.util.git_repo") local lfs = require("lfs") local run = test_env.run -describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() +describe("LuaRocks write_rockspec tests #integration", function() before_each(function() test_env.setup_specs() diff --git a/test/README.md b/test/README.md index 8124a800..770d7083 100644 --- a/test/README.md +++ b/test/README.md @@ -5,7 +5,7 @@ Test suite for LuaRocks project with Busted unit testing framework(http://olivinelabs.com/busted/). -* Contains white-box & black-box tests +* Contains unit & integration tests * Easy setup for your purpose on command line or from configuration file ## Dependencies @@ -33,9 +33,9 @@ os=, type your OS ["linux", "os x", "windows"] --------------------------------------------------------------------------------------------- ####_**Tags** of tests are required and are in this format:_ -**whitebox** - run all whitebox tests +**unit** - run all unit tests -**blackbox** - run all blackbox tests +**integration** - run all integration tests **ssh** - run all tests which require ssh @@ -43,31 +43,16 @@ os=, type your OS ["linux", "os x", "windows"] **unix** - run all tests which are UNIX based, won't work on Windows systems -**w**\_*name-of-command* - whitebox testing of command - -**b**\_*name-of-command* - blackbox testing of command - -for example: `b_install` or `w_help` - ## Examples To run all tests: `busted` -To run white-box tests in LuaRocks directory type : - -`busted -t "whitebox"` - -To run black-box tests just of *install* command (we defined our OS, so OS check is skipped.): - -`busted -Xhelper os=linux -t "b_install"` - -To run black-box tests of *install* command, whitebox of *help* command (using *full* type of environment): - -`busted -Xhelper env=full -t "b_install", "w_help"` +To run unit tests in LuaRocks directory type : -To run black-box tests without tests, which use ssh: +`busted -t "unit"` -`busted -t "blackbox" --exclude-tags=ssh` +To run integration tests without tests which use ssh: +`busted -t "integration" --exclude-tags=ssh` -- cgit v1.2.3-55-g6feb