From a40861645a9bc9a166c7d35ad09083919b4cec38 Mon Sep 17 00:00:00 2001 From: George Roman <30772943+georgeroman@users.noreply.github.com> Date: Tue, 5 Jun 2018 23:26:37 +0300 Subject: Tests: collect coverage data from unit tests (#814) --- spec/fetch_spec.lua | 11 +++++++++++ spec/fs_spec.lua | 11 +++++++++++ spec/fun_spec.lua | 14 +++++++++++++- spec/persist_spec.lua | 12 ++++++++++++ spec/util_spec.lua | 11 +++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index be138b8c..30709fcb 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua @@ -14,6 +14,17 @@ describe("Luarocks fetch test #unit", function() return file1 == file2 or lfs.attributes(file1).ino == lfs.attributes(file2).ino end + local runner + + setup(function() + runner = require("luacov.runner") + runner.init(testing_paths.testrun_dir .. "/luacov.config") + end) + + teardown(function() + runner.shutdown() + end) + describe("fetch.is_basic_protocol", function() it("checks whether the arguments represent a valid protocol and returns the result of the check", function() assert.truthy(fetch.is_basic_protocol("http")) diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index 2d0059b6..e09ac6df 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua @@ -50,6 +50,17 @@ describe("Luarocks fs test #unit", function() fs.execute("chmod -x " .. fs.Q(path)) end end + + local runner + + setup(function() + runner = require("luacov.runner") + runner.init(testing_paths.testrun_dir .. "/luacov.config") + end) + + teardown(function() + runner.shutdown() + end) describe("fs.Q", function() it("simple argument", function() diff --git a/spec/fun_spec.lua b/spec/fun_spec.lua index 259a3148..b0a082ac 100644 --- a/spec/fun_spec.lua +++ b/spec/fun_spec.lua @@ -1,9 +1,21 @@ local test_env = require("spec.util.test_env") -local fun = require("luarocks.fun") +local testing_paths = test_env.testing_paths test_env.unload_luarocks() +local fun = require("luarocks.fun") describe("LuaRocks fun tests #unit", function() + local runner + + setup(function() + runner = require("luacov.runner") + runner.init(testing_paths.testrun_dir .. "/luacov.config") + end) + + teardown(function() + runner.shutdown() + end) + describe("fun.concat", function() it("returns the concatenation of the two tables given as arguments", function() local t1, t2 diff --git a/spec/persist_spec.lua b/spec/persist_spec.lua index f61c7176..339147b1 100644 --- a/spec/persist_spec.lua +++ b/spec/persist_spec.lua @@ -1,9 +1,21 @@ local test_env = require("spec.util.test_env") +local testing_paths = test_env.testing_paths test_env.unload_luarocks() local persist = require("luarocks.persist") describe("Luarocks persist test #unit", function() + local runner + + setup(function() + runner = require("luacov.runner") + runner.init(testing_paths.testrun_dir .. "/luacov.config") + end) + + teardown(function() + runner.shutdown() + end) + describe("persist.save_from_table_to_string", function() it("simple table", function() assert.are.same([[ diff --git a/spec/util_spec.lua b/spec/util_spec.lua index ce309138..075a2122 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -74,6 +74,17 @@ test_env.unload_luarocks() local util = require("luarocks.util") describe("Luarocks util test #unit", function() + local runner + + setup(function() + runner = require("luacov.runner") + runner.init(testing_paths.testrun_dir .. "/luacov.config") + end) + + teardown(function() + runner.shutdown() + end) + describe("util.sortedpairs", function() local function collect(iter, state, var) local collected = {} -- cgit v1.2.3-55-g6feb