-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-install-test.R
51 lines (36 loc) · 1.44 KB
/
build-install-test.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
rm(list = ls(all = TRUE))
# ensure consistent Roxygen version
if(packageVersion("roxygen2") != '7.1.1') devtools::install_version('roxygen2', version = "7.1.1")
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
devtools::document()
devtools::document()
devtools::install(upgrade = 'never')
# Check to make sure each R file has a related test file.
rfiles = list.files( 'R' )
rfiles = rfiles[ !grepl( 'totype|utils|usepkg', rfiles ) ] # files that do not need tests.
rtests = list.files( 'tests/testthat' )
rtests_expected = paste0('test_',rfiles)
need_tests = rtests_expected[ ! rtests_expected %in% rtests ]
if( length(need_tests) > 0 ) warning(
'Not all R files have test files. Please create test files for [',
paste(need_tests,collapse = '], ['),
']'
)
# Run examples and tests.
tryCatch({
# this is required in newer versions.
usethis::use_testthat()
}, error = function(e) devtools::use_testthat()
)
devtools::run_examples()
devtools::test()
# clear test files and folders.
system( "rm -r tests/testthat/test-files-temp/cache" )
system( "rm -r cache" )
system( "rm -r tests/testthat/test-files-temp" )
# Optionally, build to compressed tar.gz.
# devtools::build( vignettes = FALSE )
# Optionally, run noLD check:
# https://www.r-bloggers.com/a-nold-platform-on-r-hub-package-builder/
# in R from the home directory, run:
# rhub::check(platform = "debian-gcc-devel-nold")