forked from se-sic/coronet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoverage.R
67 lines (51 loc) · 2.52 KB
/
coverage.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## This file is part of coronet, which is free software: you
## can redistribute it and/or modify it under the terms of the GNU General
## Public License as published by the Free Software Foundation, version 2.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
##
## Copyright 2024 by Maximilian Löffler <[email protected]>
## All Rights Reserved.
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Initialization ----------------------------------------------------------
source("util-init.R")
source("tests/testing-utils.R")
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Logging -----------------------------------------------------------------
library("methods") # to prevent weird error during logger initialization (see #153)
library("logging")
logging::basicConfig(level = "WARN")
options(mc.cores = 1L)
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Debug information -------------------------------------------------------
logging::loginfo("Session information:")
sessionInfo()
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Run tests in subfolder 'tests' ------------------------------------------
logging::loginfo("Generating coverage report.")
## load packages 'testthat' and 'patrick'
library("testthat")
requireNamespace("patrick")
requireNamespace("covr")
## define paths
test.dir = c("./tests")
code.dir = c(".")
excluded.code.files = c("./tests.R", "./coverage.R", "./showcase.R", "./install.R", "./util-init.R")
excluded.test.files = c()
## obtain files
test.files = unlist(sapply(test.dir, list.files, pattern = "\\.R$", full.names = TRUE))
test.files = test.files[!test.files %in% excluded.test.files]
code.files = unlist(sapply(code.dir, list.files, pattern = "\\.R$", full.names = TRUE))
code.files = code.files[!code.files %in% excluded.code.files]
## adjust data path prefix when generating coverage reports
DATA.PATH.PREFIX = "./tests"
## generate and save coverage report
report = covr::file_coverage(source_files = code.files, test_files = test.files)
covr::to_cobertura(report)