Module luacov.reporter

Report module, will transform statistics file into a report.

Functions

report ([reporter_class]) Runs the report generator.

Class ReporterBase

ReporterBase:config () Returns configuration table.
ReporterBase:max_hits () Returns maximum number of hits per line in all coverage data.
ReporterBase:write (...) Writes strings to report file.
ReporterBase:files () Returns array of filenames to be reported.
ReporterBase:stats (filename) Returns coverage data for a file.
ReporterBase:on_start () Stub method called before reporting.
ReporterBase:on_new_file (filename) Stub method called before processing a file.
ReporterBase:on_file_error (filename, error_type, message) Stub method called if a file couldn't be processed due to an error.
ReporterBase:on_empty_line (filename, lineno, line) Stub method called for each empty source line and other lines that can't be hit.
ReporterBase:on_mis_line (filename, lineno, line) Stub method called for each missed source line.
ReporterBase:on_hit_line (filename, lineno, line, hits) Stub method called for each hit source line.
ReporterBase:on_end_file (filename, hits, miss) Stub method called after a file has been processed.
ReporterBase:on_end () Stub method called after reporting.


Functions

report ([reporter_class])
Runs the report generator. To load a config, use luacov.runner.load_config first.

Parameters:

  • reporter_class custom reporter class. Will be instantiated using 'new' method with configuration (see luacov.defaults) as the argument. It should return nil + error if something went wrong. After acquiring a reporter object its 'run' and 'close' methods will be called. The easiest way to implement a custom reporter class is to extend ReporterBase. (optional)

Class ReporterBase

Basic reporter class stub. Implements 'new', 'run' and 'close' methods required by report. Provides some helper methods and stubs to be overridden by child classes.

Usage:

local MyReporter = setmetatable({}, ReporterBase)
MyReporter.__index = MyReporter
function MyReporter:on_hit_line(...)
   self:write(("File %s: hit line %s %d times"):format(...))
end
ReporterBase:config ()
Returns configuration table.

See also:

ReporterBase:max_hits ()
Returns maximum number of hits per line in all coverage data.
ReporterBase:write (...)
Writes strings to report file.

Parameters:

  • ... strings.
ReporterBase:files ()
Returns array of filenames to be reported.
ReporterBase:stats (filename)
Returns coverage data for a file.

Parameters:

  • filename name of the file.

See also:

ReporterBase:on_start ()
Stub method called before reporting.
ReporterBase:on_new_file (filename)
Stub method called before processing a file.

Parameters:

  • filename name of the file.
ReporterBase:on_file_error (filename, error_type, message)
Stub method called if a file couldn't be processed due to an error.

Parameters:

  • filename name of the file.
  • error_type "open", "read" or "load".
  • message error message.
ReporterBase:on_empty_line (filename, lineno, line)
Stub method called for each empty source line and other lines that can't be hit.

Parameters:

  • filename name of the file.
  • lineno line number.
  • line the line itself as a string.
ReporterBase:on_mis_line (filename, lineno, line)
Stub method called for each missed source line.

Parameters:

  • filename name of the file.
  • lineno line number.
  • line the line itself as a string.
ReporterBase:on_hit_line (filename, lineno, line, hits)
Stub method called for each hit source line.

Parameters:

  • filename name of the file.
  • lineno line number.
  • line the line itself as a string.
  • hits number of times the line was hit. Should be positive.
ReporterBase:on_end_file (filename, hits, miss)
Stub method called after a file has been processed.

Parameters:

  • filename name of the file.
  • hits total number of hit lines in the file.
  • miss total number of missed lines in the file.
ReporterBase:on_end ()
Stub method called after reporting.
generated by LDoc 1.4.6 Last updated 2021-02-15 18:40:18