Skip to content

Commit

Permalink
Use gcovr for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
onox committed Jul 28, 2024
1 parent 7b9bb29 commit 23d77eb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
ALR_CLEAN = alr clean -- -p
ALR_BUILD = alr build --development --profiles="*=development"

.PHONY: build clean prove tests coverage

build:
cd json && alr build --validation
cd json && $(ALR_BUILD)

clean:
-gnatprove --clean -P json/json.gpr
cd json && alr clean
cd tests && alr clean
rm -rf json/build tests/build tests/build/cov tests/TEST-*.xml
cd json && $(ALR_CLEAN)
cd tests && $(ALR_CLEAN)
rm -rf json/build tests/build tests/TEST-*.xml

prove:
gnatprove -P json/json.gpr

tests:
cd tests && alr build --development
cd tests && ADAFLAGS="--coverage -gnata" $(ALR_BUILD)
cd tests && alr run -s

coverage:
mkdir -p tests/build/cov
lcov -q -c -d json/build/obj -d tests/build/obj -o tests/build/cov/unit.info
lcov -q -r tests/build/cov/unit.info */adainclude/* -o tests/build/cov/unit.info
lcov -q -r tests/build/cov/unit.info */tests/* -o tests/build/cov/unit.info
genhtml -q --ignore-errors source -o tests/build/cov/html tests/build/cov/unit.info
lcov -l tests/build/cov/unit.info
gcovr --exclude test --html-nested tests/build/cov/coverage.html
7 changes: 4 additions & 3 deletions json/alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ website = "https://github.com/onox/json-ada"
licenses = "Apache-2.0"
tags = ["json"]

executables = ["pretty_print"]
#executables = ["pretty_print"]
#project-files = ["json.gpr", "json_pretty_print.gpr"]

project-files = ["json.gpr", "json_pretty_print.gpr"]
project-files = ["json.gpr"]

authors = ["onox"]
maintainers = ["onox <[email protected]>"]
maintainers-logins = ["onox"]

[build-switches]
validation.compile_checks = "warnings"
"*".style_checks = ["-gnatygAO-Is"]
"*".style_checks = ["-gnatygAOM120-Is"]
2 changes: 1 addition & 1 deletion json/json.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ project JSON is
for Library_Kind use Library_Type;

package Compiler is
for Default_Switches ("Ada") use Json_Config.Ada_Compiler_Switches & ("-gnatyM99");
for Default_Switches ("Ada") use Json_Config.Ada_Compiler_Switches;
for Local_Configuration_Pragmas use "gnat.adc";
end Compiler;

Expand Down
2 changes: 1 addition & 1 deletion tests/alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ json = { path = "../json" }

[build-switches]
validation.compile_checks = "warnings"
"*".style_checks = ["-gnatygAO-Is"]
"*".style_checks = ["-gnatygAOM120-Is"]
5 changes: 2 additions & 3 deletions tests/json_tests.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ project JSON_Tests is
for Main use ("test_bindings.adb");

package Compiler is
for Default_Switches ("Ada") use Json_Tests_Config.Ada_Compiler_Switches &
("-gnatyM99", "--coverage");
for Default_Switches ("Ada") use Json_Tests_Config.Ada_Compiler_Switches;
for Local_Configuration_Pragmas use "gnat.adc";
end Compiler;

Expand All @@ -40,7 +39,7 @@ project JSON_Tests is
end Binder;

package Linker is
for Switches ("Ada") use ("-lgcov");
for Switches ("Ada") use ("--coverage");
end Linker;

end JSON_Tests;

0 comments on commit 23d77eb

Please sign in to comment.