ExIntegrationCoveralls.Stats (ExIntegrationCoveralls v0.9.0)
Provide calculation logics of coverage stats.
Link to this section Summary
Functions
Calculate the statistical information for the specified list of modules. It uses :cover.analyse for getting the information.
Generate coverage, based on the pre-calculated statistic information.
Generate objects which stores source-file and coverage stats information.
Returns total line counts of the specified source file.
Read source code
Report the statistical information for the specified module.
Organize coverage data in a human-readable way.
Remove the front and back blank lines
Link to this section Functions
calculate_stats(modules, source_lib_absolute_path \\ File.cwd!())
Calculate the statistical information for the specified list of modules. It uses :cover.analyse for getting the information.
parameters
Parameters
- modules: Cover.modules() return value
returns
Returns
a Map stores the number of executions of executable line in the source file.
examples
Examples
%{
"test/fixtures/test1.ex" => %{1 => 0, 2 => 1},
"test/fixtures/test2.ex" => %{1 => 0, 2 => 0}
}
generate_coverage(hash, base_path \\ File.cwd!())
Generate coverage, based on the pre-calculated statistic information.
parameters
Parameters
- hash: calculate_stats() return value
- base_path: the source code project absolute path
returns
Returns
A tuple array. The first element of the tuple is the source code path The second element of the tuple stores the number of times each row was executed. The nil means it's not an executable line. Non-negative numbers represent the number of times each line of source code is executed.
examples
Examples
[{"lib/hello.ex", [ nil, 0, nil, 0, nil, 1]}, ...]
generate_source_info(coverage, base_path \\ File.cwd!())
Generate objects which stores source-file and coverage stats information.
parameters
Parameters
- coverage: generate_coverage() return value
returns
Returns
A map array.
examples
Examples
Return value like this:
[
%{
coverage: [0, 1, nil, nil],
name: "lib/hello.ex",
source: "defmodule Test do\n def test do\n end\nend"
}
]
get_source_line_count(file_path)
Returns total line counts of the specified source file.
read_source(file_path)
Read source code
report(modules, compile_time_source_lib_abs_path, source_lib_absolute_path)
Report the statistical information for the specified module.
parameters
Parameters
- compile_time_source_lib_abs_path: source code project abs path in compile-time machine.
- source_lib_absolute_path: source code project abs path in run-time machine.
returns
Returns
Return value like this:
[
%{
coverage: [0, 1, nil, nil],
name: "lib/hello.ex",
source: "defmodule Test do\n def test do\n end\nend"
}
]
transform_cov(stats)
Organize coverage data in a human-readable way.
parameters
Parameters
- stats: generate_source_info() return value
return
Return
A map.
examples
Examples
Return value link this:
%{
coverage: 50,
files: [
%ExIntegrationCoveralls.Stats.Source{
coverage: 50,
filename: "test/fixtures/test.ex",
hits: 1,
misses: 1,
sloc: 2,
source: [
%ExIntegrationCoveralls.Stats.Line{coverage: 0, source: "defmodule Test do"},
%ExIntegrationCoveralls.Stats.Line{coverage: 1, source: " def test do"},
%ExIntegrationCoveralls.Stats.Line{coverage: nil, source: " end"},
%ExIntegrationCoveralls.Stats.Line{coverage: nil, source: "end"}
]
}
],
hits: 1,
misses: 1,
sloc: 2
}
trim_empty_prefix_and_suffix(string)
Remove the front and back blank lines