forked from se-sic/coronet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.R
72 lines (55 loc) · 2.42 KB
/
tests.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
68
69
70
71
72
## 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 2017, 2019 by Claus Hunsen <[email protected]>
## Copyright 2020-2021 by Thomas Bock <[email protected]>
## Copyright 2022 by Jonathan Baumann <[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 = "DEBUG")
options(mc.cores = 1L)
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Debug information -------------------------------------------------------
logging::loginfo("Session information:")
sessionInfo()
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Run tests in subfolder 'tests' ------------------------------------------
logging::loginfo("Running test suite.")
## load packages 'testthat' and 'patrick'
requireNamespace("testthat")
requireNamespace("patrick")
## starting tests
do.tests = function(dir) {
res = testthat::test_dir(dir, reporter = "check")
if (length(res[["failures"]]) > 0) {
cat(str_c("Some R tests failed for directory '", dir, "'"))
for (i in 1:length(res[["failures"]])) {
cat(str_c("Failing test ", i, ": ", res[["failures"]][[i]], "\n"))
}
return(FALSE)
}
return(TRUE)
}
res = sapply(c("./tests"), function(dir) {
do.tests(dir)
})
if (!all(res)) {
stop("Error exiting because of test failures")
}