@@ -732,6 +732,10 @@ add_dummies <- function(dir, Log)
732
732
resultLog(Log , " SKIPPED" )
733
733
}
734
734
735
+ # # Run the demos if requested (traditionally part of tests, as in base)
736
+ if (dir.exists(file.path(pkgdir , " demo" )))
737
+ run_tests(" demo" )
738
+
735
739
# # Run the package-specific tests.
736
740
tests_dir <- file.path(pkgdir , test_dir )
737
741
if (test_dir != " tests" && ! dir.exists(tests_dir )) {
@@ -740,7 +744,7 @@ add_dummies <- function(dir, Log)
740
744
}
741
745
if (dir.exists(tests_dir ) && # trackObjs has only *.Rin
742
746
length(dir(tests_dir , pattern = " \\ .(R|r|Rin)$" )))
743
- run_tests()
747
+ run_tests(test_dir )
744
748
745
749
# # Check package vignettes.
746
750
setwd(pkgoutdir )
@@ -4637,30 +4641,41 @@ add_dummies <- function(dir, Log)
4637
4641
}
4638
4642
}
4639
4643
4640
- run_tests <- function ()
4644
+ # # this is also used for --run-demo
4645
+ run_tests <- function (test_dir = " tests" )
4641
4646
{
4642
- if (! extra_arch && ! is_base_pkg ) {
4647
+ is_demo <- test_dir == " demo"
4648
+ check_packages_used <- ! is_demo ||
4649
+ config_val_to_logical(Sys.getenv(" _R_CHECK_PACKAGES_USED_IN_DEMO_" , do_demo ))
4650
+ if (check_packages_used && ! extra_arch && ! is_base_pkg ) {
4643
4651
checkingLog(Log , " for unstated dependencies in " , sQuote(test_dir ))
4644
4652
Rcmd <- paste(opW_shE_F_str ,
4645
4653
sprintf(" tools:::.check_packages_used_in_tests(\" %s\" , \" %s\" )\n " , pkgdir , test_dir ))
4646
4654
4647
4655
out <- R_runR2(Rcmd , " R_DEFAULT_PACKAGES=NULL" )
4648
4656
if (length(out )) {
4649
- warningLog(Log )
4657
+ if ( is_demo ) noteLog( Log ) else warningLog(Log )
4650
4658
printLog0(Log , paste(c(out , " " ), collapse = " \n " ))
4651
4659
# wrapLog(msg_DESCRIPTION)
4652
4660
} else resultLog(Log , " OK" )
4653
4661
}
4654
4662
4655
- if (test_dir == " tests" )
4656
- checkingLog(Log , " tests" )
4657
- else
4658
- checkingLog(Log , " tests in " , sQuote(test_dir ))
4663
+ if (is_demo ) {
4664
+ if (do_demo ) {
4665
+ checkingLog(Log , " demos" )
4666
+ do_tests <- TRUE
4667
+ } else return ()
4668
+ } else {
4669
+ if (test_dir == " tests" )
4670
+ checkingLog(Log , " tests" )
4671
+ else
4672
+ checkingLog(Log , " tests in " , sQuote(test_dir ))
4673
+ }
4659
4674
4660
4675
run_one_arch <- function (arch = " " )
4661
4676
{
4662
4677
testsrcdir <- file.path(pkgdir , test_dir )
4663
- testdir <- file.path(pkgoutdir , " tests" )
4678
+ testdir <- file.path(pkgoutdir , if ( is_demo ) " demo " else " tests" )
4664
4679
if (nzchar(arch )) testdir <- paste(testdir , arch , sep = " _" )
4665
4680
if (! dir.exists(testdir )) dir.create(testdir , mode = " 0755" )
4666
4681
if (! dir.exists(testdir )) {
@@ -6900,6 +6915,7 @@ add_dummies <- function(dir, Log)
6900
6915
" --no-vignettes do not run R code in vignettes nor build outputs" ,
6901
6916
" --no-build-vignettes do not build vignette outputs" ,
6902
6917
" --ignore-vignettes skip all tests on vignettes" ,
6918
+ " --run-demo do run R scripts in 'demo' subdirectory" ,
6903
6919
" --run-dontrun do run \\ dontrun sections in the Rd files" ,
6904
6920
" --run-donttest do run \\ donttest sections in the Rd files" ,
6905
6921
" --use-gct use 'gctorture(TRUE)' when running examples/tests" ,
@@ -6992,6 +7008,7 @@ add_dummies <- function(dir, Log)
6992
7008
multiarch <- NA
6993
7009
force_multiarch <- FALSE
6994
7010
as_cran <- FALSE
7011
+ do_demo <- FALSE
6995
7012
run_dontrun <- FALSE
6996
7013
run_donttest <- FALSE
6997
7014
stop_on_test_error <- TRUE
@@ -7053,6 +7070,8 @@ add_dummies <- function(dir, Log)
7053
7070
} else if (a == " --no-latex" ) {
7054
7071
stop(" '--no-latex' is defunct: use '--no-manual' instead" ,
7055
7072
call. = FALSE , domain = NA )
7073
+ } else if (a == " --run-demo" ) {
7074
+ do_demo <- TRUE
7056
7075
} else if (a == " --run-dontrun" ) {
7057
7076
run_dontrun <- TRUE
7058
7077
} else if (a == " --run-donttest" ) {
@@ -7829,9 +7848,11 @@ add_dummies <- function(dir, Log)
7829
7848
" R_check_bin" ,
7830
7849
" build_vignettes.log" ,
7831
7850
" tests" , " vign_test" ,
7851
+ if (do_demo ) " demo" ,
7832
7852
if (this_multiarch )
7833
7853
c(paste0(" examples_" , inst_archs ),
7834
7854
paste0(pkgname , " -Ex_" , inst_archs , " .Rout" ),
7855
+ if (do_demo ) paste0(" demo_" , inst_archs ),
7835
7856
paste0(" tests_" , inst_archs ))
7836
7857
))
7837
7858
# # Examples calling dev.new() give files Rplots*.pdf,
0 commit comments