From 3bf9ac4ebd8e2ac9bb77b50e73fa367d5d24309e Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 8 May 2023 23:12:16 +0200 Subject: [PATCH] chore: configure coverage --- .editorconfig | 8 +------- .gitignore | 1 + .luacov | 46 +++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 6 ++++++ justfile | 5 +++++ 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 .luacov diff --git a/.editorconfig b/.editorconfig index dc552b6..2ff1b1a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,13 +8,7 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[*.lua] -indent_size = 3 - -[*.{tl,d.tl}] -indent_size = 3 - -[.busted] +[*.{lua,tl,d.tl,busted,luacheckrc,luacov}] indent_size = 3 [justfile] diff --git a/.gitignore b/.gitignore index f6ca0ea..97ac9ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ lua_modules generated build +luacov diff --git a/.luacov b/.luacov new file mode 100644 index 0000000..381eb6d --- /dev/null +++ b/.luacov @@ -0,0 +1,46 @@ +-- -- Per https://github.com/lunarmodules/luacov/blob/c915f4b95e8df5dbfaf2b1f04f0b7da04506fc7a/src/luacov/reporter.lua#L102 +-- -- > The option includeuntestedfiles requires the lfs module (from luafilesystem) to be installed. +-- -- So I'm ok with including it here, since it's already an hard dependency. +-- local lfs = require "lfs" + +-- local function walk(dir, callback) +-- for file in lfs.dir(dir) do +-- if file ~= "." and file ~= ".." then +-- local path = dir .. "/" .. file +-- local attr = lfs.attributes(path) +-- if attr.mode == "directory" then +-- walk(path, callback) +-- else +-- callback(path) +-- end +-- end +-- end +-- end + +-- local teal_files = {} +-- for _, path in pairs { "spec", "src" } do +-- walk(path, function(file) +-- if file:match "%.tl$" then +-- table.insert(teal_files, file) +-- end +-- end) +-- end + +return { + statsfile = "luacov/luacov.stats.out", + reporter = "html", + reportfile = "luacov/luacov.report.html", + include = { + "spec", + "src", + }, + exclude = { + "lua_modules", + "spec/tlconfig.lua", + "src/awesome.d.tl/types", + "types", + }, + -- runreport = true, -- For some reason, it makes my computer crash + -- includeuntestedfiles = teal_files, + includeuntestedfiles = true, +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 8a4c47c..e0a991d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "getcontent", "gitea", "htmlparser", + "includeuntestedfiles", "isdir", "justfile", "libc", @@ -22,6 +23,7 @@ "lpath", "Luacheck", "luacheckrc", + "luacov", "luafilesystem", "lualogging", "Luarocks", @@ -29,8 +31,11 @@ "luasocket", "mkdir", "modname", + "reportfile", "rockspec", + "runreport", "setopt", + "statsfile", "stringx", "Stylua", "sublist", @@ -47,6 +52,7 @@ "files.associations": { ".busted": "lua", ".luacheckrc": "lua", + ".luacov": "lua", "*.rockspec": "lua" } } diff --git a/justfile b/justfile index f2072b8..cb67890 100644 --- a/justfile +++ b/justfile @@ -49,3 +49,8 @@ validate: test: busted + +# Requires a patched version of luacov (https://github.com/lunarmodules/luacov/issues/98#issuecomment-1530491759) +coverage: + busted --coverage + luacov