@@ -732,6 +732,10 @@ add_dummies <- function(dir, Log)
732732 resultLog(Log , " SKIPPED" )
733733 }
734734
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+
735739 # # Run the package-specific tests.
736740 tests_dir <- file.path(pkgdir , test_dir )
737741 if (test_dir != " tests" && ! dir.exists(tests_dir )) {
@@ -740,7 +744,7 @@ add_dummies <- function(dir, Log)
740744 }
741745 if (dir.exists(tests_dir ) && # trackObjs has only *.Rin
742746 length(dir(tests_dir , pattern = " \\ .(R|r|Rin)$" )))
743- run_tests()
747+ run_tests(test_dir )
744748
745749 # # Check package vignettes.
746750 setwd(pkgoutdir )
@@ -4637,30 +4641,41 @@ add_dummies <- function(dir, Log)
46374641 }
46384642 }
46394643
4640- run_tests <- function ()
4644+ # # this is also used for --run-demo
4645+ run_tests <- function (test_dir = " tests" )
46414646 {
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 ) {
46434651 checkingLog(Log , " for unstated dependencies in " , sQuote(test_dir ))
46444652 Rcmd <- paste(opW_shE_F_str ,
46454653 sprintf(" tools:::.check_packages_used_in_tests(\" %s\" , \" %s\" )\n " , pkgdir , test_dir ))
46464654
46474655 out <- R_runR2(Rcmd , " R_DEFAULT_PACKAGES=NULL" )
46484656 if (length(out )) {
4649- warningLog(Log )
4657+ if ( is_demo ) noteLog( Log ) else warningLog(Log )
46504658 printLog0(Log , paste(c(out , " " ), collapse = " \n " ))
46514659 # wrapLog(msg_DESCRIPTION)
46524660 } else resultLog(Log , " OK" )
46534661 }
46544662
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+ }
46594674
46604675 run_one_arch <- function (arch = " " )
46614676 {
46624677 testsrcdir <- file.path(pkgdir , test_dir )
4663- testdir <- file.path(pkgoutdir , " tests" )
4678+ testdir <- file.path(pkgoutdir , if ( is_demo ) " demo " else " tests" )
46644679 if (nzchar(arch )) testdir <- paste(testdir , arch , sep = " _" )
46654680 if (! dir.exists(testdir )) dir.create(testdir , mode = " 0755" )
46664681 if (! dir.exists(testdir )) {
@@ -6900,6 +6915,7 @@ add_dummies <- function(dir, Log)
69006915 " --no-vignettes do not run R code in vignettes nor build outputs" ,
69016916 " --no-build-vignettes do not build vignette outputs" ,
69026917 " --ignore-vignettes skip all tests on vignettes" ,
6918+ " --run-demo do run R scripts in 'demo' subdirectory" ,
69036919 " --run-dontrun do run \\ dontrun sections in the Rd files" ,
69046920 " --run-donttest do run \\ donttest sections in the Rd files" ,
69056921 " --use-gct use 'gctorture(TRUE)' when running examples/tests" ,
@@ -6992,6 +7008,7 @@ add_dummies <- function(dir, Log)
69927008 multiarch <- NA
69937009 force_multiarch <- FALSE
69947010 as_cran <- FALSE
7011+ do_demo <- FALSE
69957012 run_dontrun <- FALSE
69967013 run_donttest <- FALSE
69977014 stop_on_test_error <- TRUE
@@ -7053,6 +7070,8 @@ add_dummies <- function(dir, Log)
70537070 } else if (a == " --no-latex" ) {
70547071 stop(" '--no-latex' is defunct: use '--no-manual' instead" ,
70557072 call. = FALSE , domain = NA )
7073+ } else if (a == " --run-demo" ) {
7074+ do_demo <- TRUE
70567075 } else if (a == " --run-dontrun" ) {
70577076 run_dontrun <- TRUE
70587077 } else if (a == " --run-donttest" ) {
@@ -7829,9 +7848,11 @@ add_dummies <- function(dir, Log)
78297848 " R_check_bin" ,
78307849 " build_vignettes.log" ,
78317850 " tests" , " vign_test" ,
7851+ if (do_demo ) " demo" ,
78327852 if (this_multiarch )
78337853 c(paste0(" examples_" , inst_archs ),
78347854 paste0(pkgname , " -Ex_" , inst_archs , " .Rout" ),
7855+ if (do_demo ) paste0(" demo_" , inst_archs ),
78357856 paste0(" tests_" , inst_archs ))
78367857 ))
78377858 # # Examples calling dev.new() give files Rplots*.pdf,
0 commit comments