Description
Background
We use klmr/box (previously we used wahani/modules) to structure the code of our Shiny apps. These packages bring a module/import system similar to what you can find in languages like Python, JavaScript (ES6+) or Java.
Each module has its own namespace and multiple modules can export objects with identical names. For example, we can have modules named main.R
and sidebar.R
both of which export ui
and server
objects. When using them in some other module, they can be referred to e.g. as main$server
and sidebar$server
. This also works in our testthat unit tests - the test file itself imports the functions it needs to test.
Unfortunately the covr package is not prepared for this kind of usage. The file_coverage()
function just sources all files passed in the source_files
argument, so any duplicate names in the modules clash and overwrite each other. The generated coverage report has files missing.
Goal
We'd love to use covr to generate coverage report for our Shiny apps, but we find modules very important for structuring large apps, and these two tools are currently incompatible. I'd like to start a discussion - how can we change that?
I'm happy to provide more details, e.g. prepare a demo project.