Skip to content

Commit a7704cd

Browse files
committed
TST: generate coverage report
1 parent 35b87a7 commit a7704cd

File tree

3 files changed

+105
-29
lines changed

3 files changed

+105
-29
lines changed

pixi.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,44 @@ tests.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests"]
6666
tests.depends-on = ["clone-xsref", "build-tests"]
6767
tests.cwd = "."
6868

69+
## Coverage
70+
71+
[feature.coverage.dependencies]
72+
lcov = ">=1.16,<2"
73+
74+
[feature.coverage.tasks]
75+
# Configure with tests and coverage
76+
configure-coverage.cmd = [
77+
"cmake",
78+
# Enable building tests
79+
"-DBUILD_TESTS=ON",
80+
# Enable Coverage
81+
"-DCMAKE_BUILD_TYPE=Coverage",
82+
# The source is in the root directory
83+
"-S .",
84+
# We want to build in the build directory
85+
"-B build",
86+
]
87+
configure-coverage.cwd = "."
88+
configure-coverage.env.XSREF_TABLES_PATH = "$PWD/xsref/tables"
89+
90+
## Tests CI
91+
6992
[feature.tests-ci.dependencies]
7093
ccache = ">=4.11.2,<5"
7194

7295
[feature.tests-ci.tasks]
96+
# Build and generate coverage report
7397
# TODO: use a task arg for parallelism https://github.com/prefix-dev/pixi/pull/3433
74-
build-tests-ci.cmd = ["cmake", "--build", "build", "-j3"]
75-
build-tests-ci.depends-on = ["clone-xsref", "configure-tests"]
98+
build-tests-ci.cmd = ["cmake", "--build", "build", "--target", "coverage_html", "-j3"]
99+
build-tests-ci.depends-on = ["clone-xsref", "configure-coverage"]
76100
build-tests-ci.cwd = "."
77-
78-
# run tests
101+
# Run tests
79102
tests-ci.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j3"]
80103
tests-ci.depends-on = ["build-tests-ci"]
81104
tests-ci.cwd = "."
82105

83-
## Coverage
84-
85-
# [feature.coverage.dependencies]
86-
# lcov = ">=1.16,<2"
87-
88-
# [feature.coverage.tasks.configure-coverage]
89-
# cmd = [
90-
# "cmake",
91-
# "-DCMAKE_BUILD_TYPE=Coverage",
92-
# # The source is in the root directory
93-
# "-S .",
94-
# # We want to build in the build directory
95-
# "-B build",
96-
# ]
97-
98-
# [feature.coverage.tasks.coverage]
99-
# depends-on = ["configure-coverage"]
100-
# cmd = ["cmake", "--build", "build", "--target", "coverage_html"]
101-
102-
# [feature.coverage.tasks.tests-coverage]
103-
# # Generate the coverage report and then run tests under the same configuration
104-
# depends-on = ["coverage"]
105-
# cwd = "build"
106-
# cmd = "ctest"
107106

108107
[environments]
109108
default = { features = ["build", "tests"], solve-group = "default" }
110-
tests-ci = { features = ["build", "tests", "tests-ci"], solve-group = "default" }
109+
tests-ci = { features = ["build", "tests", "tests-ci", "coverage"], solve-group = "default" }

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ target_include_directories(xsf INTERFACE ${CMAKE_SOURCE_DIR}/include)
1313

1414
set(TEST_BASE_DIR "${CMAKE_SOURCE_DIR}/tests")
1515

16+
include(${CMAKE_SOURCE_DIR}/tests/Coverage.cmake)
17+
1618
file(GLOB TEST_SOURCES "*/test_*.cpp")
1719
foreach(test_file ${TEST_SOURCES})
1820
# Families of tests go in subfolders of xsf/tests. Test files in different

0 commit comments

Comments
 (0)