{"id":519787,"url":"https://keplerproject.github.io/luacov","last_synced_at":"2025-08-13T05:34:01.323Z","repository":{"id":719265,"uuid":"366447","full_name":"lunarmodules/luacov","owner":"lunarmodules","description":"LuaCov is a simple coverage analyzer for Lua code.","archived":false,"fork":false,"pushed_at":"2024-01-21T04:27:06.000Z","size":806,"stargazers_count":295,"open_issues_count":23,"forks_count":66,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-06-22T00:53:41.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://lunarmodules.github.io/luacov/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lunarmodules.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2009-11-09T16:38:33.000Z","updated_at":"2024-06-07T11:28:31.000Z","dependencies_parsed_at":"2023-07-06T01:55:06.176Z","dependency_job_id":"b884fb48-9910-4a7b-a0fa-ddbebdb4488a","html_url":"https://github.com/lunarmodules/luacov","commit_stats":{"total_commits":277,"total_committers":21,"mean_commits":13.19047619047619,"dds":0.516245487364621,"last_synced_commit":"c915f4b95e8df5dbfaf2b1f04f0b7da04506fc7a"},"previous_names":["keplerproject/luacov"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarmodules%2Fluacov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarmodules%2Fluacov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarmodules%2Fluacov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarmodules%2Fluacov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lunarmodules","download_url":"https://codeload.github.com/lunarmodules/luacov/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":216462159,"owners_count":16029773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-09T08:06:46.321Z","updated_at":"2024-08-22T11:30:34.414Z","avatar_url":"https://github.com/lunarmodules.png","language":"Lua","readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eLuaCov\u003c/h1\u003e\n    \u003cimg src=\"./docs/logo/luacov-144x144.png\" width=\"144\" /\u003e\n    \u003cp align=\"center\"\u003e\n        Coverage analyzer for Lua\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n## Status\n[![Unix build](https://img.shields.io/github/actions/workflow/status/lunarmodules/luacov/unix_build.yml?branch=master\u0026label=Unix%20build\u0026logo=linux)](https://github.com/lunarmodules/luacov/actions/workflows/unix_build.yml)\n[![Windows build](https://ci.appveyor.com/api/projects/status/nwlc6603cva412ub?svg=true)](https://ci.appveyor.com/project/hishamhm/luacov)\n[![Lint](https://github.com/lunarmodules/luacov/workflows/Lint/badge.svg)](https://github.com/lunarmodules/luacov/actions/workflows/lint.yml)\n[![SemVer](https://img.shields.io/github/v/tag/lunarmodules/luacov?color=brightgreen\u0026label=SemVer\u0026logo=semver\u0026sort=semver)](CHANGELOG.md)\n\n## Overview\n\nLuaCov is a simple coverage analyzer for [Lua](http://www.lua.org) scripts.\nWhen a Lua script is run with the `luacov` module loaded, it generates a stats\nfile with the number of executions of each line of the script and its loaded\nmodules. The `luacov` command-line script then processes this file generating\na report file which allows one to visualize which code paths were not\ntraversed, which is useful for verifying the effectiveness of a test suite.\n\nLuaCov is free software and, like Lua, is released under the\n[MIT License](https://www.lua.org/license.html).\n\n## Download and Installation\n\nLuaCov can be downloaded from its\n[Github downloads page](https://github.com/lunarmodules/luacov/releases).\n\nIt can also be installed using Luarocks:\n\n```\nluarocks install luacov\n```\n\nIn order to additionally install experimental C extensions that improve\nperformance and analysis accuracy install\n[CLuaCov](https://github.com/mpeterv/cluacov) package instead:\n\n```\nluarocks install cluacov\n```\n\nLuaCov is written in pure Lua and has no external dependencies.\n\n## Instructions\n\nUsing LuaCov consists of two steps: running your script to collect coverage\ndata, and then running `luacov` on the collected data to generate a report\n(see [configuration](#configuration) below for other options).\n\nTo collect coverage data, your script needs to load the `luacov` Lua module.\nThis can be done from the command-line, without modifying your script, like\nthis:\n\n    lua -lluacov test.lua\n\nAlternatively, you can add `require(\"luacov\")` to the first line of your\nscript.\n\nOnce the script is run, a file called `luacov.stats.out` is generated. If the\nfile already exists, statistics are _added_ to it. This is useful, for\nexample, for making a series of runs with different input parameters in a test\nsuite. To start the accounting from scratch, just delete the stats file.\n\nTo generate a report, just run the `luacov` command-line script. It expects to\nfind a file named `luacov.stats.out` in the current directory, and outputs a\nfile named `luacov.report.out`. The script takes the following parameters:\n\n    luacov [-c=configfile] [filename...]\n\nFor the `-c` option see below at [configuration](#configuration). The filenames\n(actually Lua patterns) indicate the files to include in the report, specifying\nthem here equals to adding them to the `include` list in the configuration\nfile, with `.lua` extension stripped.\n\nThis is an example output of the report file:\n\n```\n==============================================================================\ntest.lua\n==============================================================================\n 1 if 10 \u003e 100 then\n*0    print(\"I don't think this line will execute.\")\n   else\n 1    print(\"Hello, LuaCov!\")\n   end\n```\n\nNote that to generate this report, `luacov` reads the source files. Therefore,\nit expects to find them in the same location they were when the `luacov`\nmodule ran (the stats file stores the filenames, but not the sources\nthemselves).\n\nTo silence missed line reporting for a group of lines, place inline options\n`luacov: disable` and `luacov: enable` in short comments around them:\n\n```lua\nif SOME_DEBUG_CONDITION_THAT_IS_ALWAYS_FALSE_IN_TESTS then\n   -- luacov: disable\n\n   -- Lines here are not marked as missed even though they are not covered.\n\n   -- luacov: enable\nend\n```\n\nLuaCov saves its stats upon normal program termination. If your program is a\ndaemon -- in other words, if it does not terminate normally -- you can use the\n`luacov.tick` module or `tick` configuration option, which periodically saves\nthe stats file. For example, to run (on Unix systems) LuaCov on\n[Xavante](httpsf://lunarmodules.github.io/xavante/), just modify the first line\nof `xavante_start.lua` so it reads:\n\n```\n#!/usr/bin/env lua -lluacov.tick\n```\n\nor add\n\n```lua\ntick = true\n```\n\nto `.luacov` config file.\n\n\n## Configuration\n\nLuaCov includes several configuration options, which have their defaults\nstored in `src/luacov/defaults.lua`. These are the global defaults. To use\nproject specific configuration, create a Lua script setting options as globals\nor returning a table with some options and store it as `.luacov` in the project\ndirectory from where `luacov` is being run. Alternatively, store it elsewhere\nand specify the path in the `LUACOV_CONFIG` environment variable.\n\nFor example, this config informs LuaCov that only `foo` module and its\nsubmodules should be covered and that they are located inside `src` directory:\n\n```lua\nmodules = {\n   [\"foo\"] = \"src/foo/init.lua\",\n   [\"foo.*\"] = \"src\"\n}\n```\n\nFor a full list of options, see\n[`luacov.defaults` documentation](https://lunarmodules.github.io/luacov/doc/modules/luacov.defaults.html).\n\n## Html reporter\n\nTo generate report file as html document, adjust the `.luacov` parameters to\n\n```lua\nreporter = \"html\"\nreportfile = \"luacov.report.html\"\n```\n\n![LuaCov Html Reporter](docs/luacov-html-reporter.png)\n\n## Custom reporter engines\n\nLuaCov supports custom reporter engines, which are distributed as separate\npackages. Check them out!\n\n* Cobertura: https://github.com/britzl/luacov-cobertura\n* Coveralls: https://github.com/moteus/luacov-coveralls\n* Console: https://github.com/spacewander/luacov-console\n* LCOV: https://github.com/daurnimator/luacov-reporter-lcov\n\n## Using development version\n\nAfter cloning this repo, these commands may be useful:\n\n* `luarocks make` to install LuaCov from local sources;\n* `busted` to run tests using [busted](https://github.com/Olivine-Labs/busted).\n* `ldoc .` to regenerate documentation using\n  [LDoc](https://github.com/stevedonovan/LDoc).\n* `luacheck .` to lint using [Luacheck](https://github.com/lunarmodules/luacheck).\n\n## Credits\n\nLuaCov was designed and implemented by Hisham Muhammad as a tool for testing\n[LuaRocks](https://luarocks.org/).\n","funding_links":[],"categories":["Resources","资源"],"sub_categories":["Analysis Tools and ASTs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/keplerproject.github.io%2Fluacov","html_url":"https://awesome.ecosyste.ms/projects/keplerproject.github.io%2Fluacov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/keplerproject.github.io%2Fluacov/lists"}