diff options
author | Mikhail Galanin <negram@users.noreply.github.com> | 2018-09-25 15:22:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-25 15:22:28 +0100 |
commit | 70571f2b5513db967f68194878e177c52e69a107 (patch) | |
tree | 8c564a5e9e70fdd6fca0a2fd07f3d44fd020133a | |
parent | a84877f40f9139f3cba7bd81d7bdd73c86870c4c (diff) | |
download | rspamd-70571f2b5513db967f68194878e177c52e69a107.tar.gz rspamd-70571f2b5513db967f68194878e177c52e69a107.zip |
[Minor] Add Lua coverage collection for unit-tests (#2528)
* [Minor] Add Lua coverage collection for unit-tests
* [Minor] add coverage collection to CircleCI
* [Minor] split into two lines
* [Minor] sudo
* [Minor] fixed nonsense
* [Minor] Fix functional test
-rw-r--r-- | .circleci/config.yml | 14 | ||||
-rw-r--r-- | test/lua/tests.lua | 15 |
2 files changed, 27 insertions, 2 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index a9985e175..1ac0e01e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,6 +15,14 @@ references: gem install coveralls-lcov lcov --no-external -b ../project -d ../project -c --output-file coverage.${CIRCLE_JOB}.info + - &capture_lua_coverage_data + run: + name: Capturing Lua coverage data + command: | + set -e + sudo luarocks install luacov-coveralls + if [ ! -z $COVERALLS_REPO_TOKEN ]; then luacov-coveralls -t ${COVERALLS_REPO_TOKEN} || true; fi + - &restore_coverage_data restore_cache: keys: @@ -61,13 +69,16 @@ jobs: at: *workspace_root - run: sudo apt-get update -qq || true - - run: sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libicu-dev libluajit-5.1-dev libmagic-dev libsqlite3-dev libssl-dev ragel libunwind-dev libunwind8 + - run: sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libicu-dev libluajit-5.1-dev libmagic-dev libsqlite3-dev libssl-dev ragel libunwind-dev libunwind8 luarocks + - run: sudo luarocks install luacheck + - run: sudo luarocks install luacov - run: cd ../build - run: make rspamd-test -j`nproc` - run: set +e; test/rspamd-test -p /rspamd/lua; echo "export RETURN_CODE=$?" >> $BASH_ENV - *capture_coverage_data + - *capture_lua_coverage_data # Share coverage data between jobs - save_cache: @@ -95,6 +106,7 @@ jobs: - run: sudo pip install demjson psutil robotframework requests http - run: sudo luarocks install luacheck + - run: sudo luarocks install luacov - run: cd ../build - run: set +e; RSPAMD_INSTALLROOT=../install sudo -E robot -x xunit.xml --exclude isbroken ../project/test/functional/cases; echo "export RETURN_CODE=$?" >> $BASH_ENV diff --git a/test/lua/tests.lua b/test/lua/tests.lua index 6c05e02e0..82c546903 100644 --- a/test/lua/tests.lua +++ b/test/lua/tests.lua @@ -2,6 +2,15 @@ local telescope = require "telescope" require "rspamd_assertions" +local loaded, luacov = pcall(require, 'luacov.runner') +if not loaded then + luacov = { + init = function() end, + shutdown = function() end, + run_report = function() end + } +end +luacov.init() local contexts = {} @@ -14,6 +23,7 @@ end if not test_pattern then test_filter = function(_) return true end end + local buffer = {} local results = telescope.run(contexts, callbacks, test_filter) local summary, data = telescope.summary_report(contexts, results) @@ -35,4 +45,7 @@ for _, v in pairs(results) do v.status_code == telescope.status_codes.fail then os.exit(1) end -end
\ No newline at end of file +end + +luacov:shutdown() +luacov:run_report() |