From 7257b91c9fd98a9a1f82fcc983bb74e71dfa513b Mon Sep 17 00:00:00 2001 From: gmanis Date: Mon, 12 Feb 2018 06:01:41 -0500 Subject: [PATCH] Faster R Tests (#314) --- .../test_includePackage.R | 0 R/pkg/tests/run-all.R | 24 +++++++++++++------ R/run-tests.sh | 6 ++++- circle.yml | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) rename R/pkg/tests/{fulltests => condatests}/test_includePackage.R (100%) diff --git a/R/pkg/tests/fulltests/test_includePackage.R b/R/pkg/tests/condatests/test_includePackage.R similarity index 100% rename from R/pkg/tests/fulltests/test_includePackage.R rename to R/pkg/tests/condatests/test_includePackage.R diff --git a/R/pkg/tests/run-all.R b/R/pkg/tests/run-all.R index 94d75188fb948..c14d5cef15da7 100644 --- a/R/pkg/tests/run-all.R +++ b/R/pkg/tests/run-all.R @@ -55,13 +55,23 @@ if (identical(Sys.getenv("NOT_CRAN"), "true")) { test_package("SparkR") if (identical(Sys.getenv("NOT_CRAN"), "true")) { - # set random seed for predictable results. mostly for base's sample() in tree and classification - set.seed(42) - # for testthat 1.0.2 later, change reporter from "summary" to default_reporter() - testthat:::run_tests("SparkR", - file.path(sparkRDir, "pkg", "tests", "fulltests"), - NULL, - "summary") + if (identical(Sys.getenv("CONDA_TESTS"), "true")) { + # set random seed for predictable results. mostly for base's sample() in tree and classification + set.seed(42) + # for testthat 1.0.2 later, change reporter from "summary" to default_reporter() + testthat:::run_tests("SparkR", + file.path(sparkRDir, "pkg", "tests", "condatests"), + NULL, + "summary") + } else { + # set random seed for predictable results. mostly for base's sample() in tree and classification + set.seed(42) + # for testthat 1.0.2 later, change reporter from "summary" to default_reporter() + testthat:::run_tests("SparkR", + file.path(sparkRDir, "pkg", "tests", "fulltests"), + NULL, + "summary") + } } SparkR:::uninstallDownloadedSpark() diff --git a/R/run-tests.sh b/R/run-tests.sh index a946ed288fa0b..51eeefce0b47f 100755 --- a/R/run-tests.sh +++ b/R/run-tests.sh @@ -23,9 +23,13 @@ FAILED=0 LOGFILE=$FWDIR/unit-tests.out rm -f $LOGFILE -SPARK_TESTING=1 NOT_CRAN=true $FWDIR/../bin/spark-submit --driver-java-options "-Dlog4j.configuration=file:$FWDIR/log4j.properties" --num-executors 1 --conf spark.hadoop.fs.defaultFS="file:///" --conf spark.conda.binaryPath=$CONDA_BIN --conf spark.conda.bootstrapPackages="r,r-essentials,r-plyr,r-testthat" --conf spark.conda.channelUrls="https://repo.continuum.io/pkgs/r,https://repo.continuum.io/pkgs/main,https://repo.continuum.io/pkgs/free,https://repo.continuum.io/pkgs/pro" $FWDIR/pkg/tests/run-all.R 2>&1 | tee -a $LOGFILE +SPARK_TESTING=1 NOT_CRAN=true $FWDIR/../bin/spark-submit --driver-java-options "-Dlog4j.configuration=file:$FWDIR/log4j.properties" --conf spark.hadoop.fs.defaultFS="file:///" $FWDIR/pkg/tests/run-all.R 2>&1 | tee -a $LOGFILE FAILED=$((PIPESTATUS[0]||$FAILED)) +SPARK_TESTING=1 NOT_CRAN=true CONDA_TESTS=true $FWDIR/../bin/spark-submit --driver-java-options "-Dlog4j.configuration=file:$FWDIR/log4j.properties" --conf spark.hadoop.fs.defaultFS="file:///" --conf spark.conda.binaryPath=$CONDA_BIN --conf spark.conda.bootstrapPackages="r,r-essentials,r-plyr,r-testthat" --conf spark.conda.channelUrls="https://repo.continuum.io/pkgs/r,https://repo.continuum.io/pkgs/main,https://repo.continuum.io/pkgs/free,https://repo.continuum.io/pkgs/pro" $FWDIR/pkg/tests/run-all.R 2>&1 | tee -a $LOGFILE +FAILED=$((PIPESTATUS[0]||$FAILED)) + + NUM_TEST_WARNING="$(grep -c -e 'Warnings ----------------' $LOGFILE)" # Also run the documentation tests for CRAN diff --git a/circle.yml b/circle.yml index 3d13179807115..b3382e114f34f 100644 --- a/circle.yml +++ b/circle.yml @@ -8,7 +8,7 @@ machine: - sudo apt-get update - sudo apt-get --assume-yes install r-base r-base-dev qpdf - sudo chmod 777 /usr/local/lib/R/site-library - - /usr/lib/R/bin/R -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 'survival', 'devtools', 'roxygen2', 'lintr'), repos='http://cran.us.r-project.org', lib='/usr/local/lib/R/site-library')" + - /usr/lib/R/bin/R -e "install.packages(c('devtools'), repos='http://cran.us.r-project.org', lib='/usr/local/lib/R/site-library'); devtools::install_github('r-lib/testthat@v1.0.2', lib='/usr/local/lib/R/site-library'); install.packages(c('knitr', 'rmarkdown', 'e1071', 'survival', 'roxygen2', 'lintr'), repos='http://cran.us.r-project.org', lib='/usr/local/lib/R/site-library')" - | if [[ ! -d ${CONDA_ROOT} ]]; then echo "Installing Miniconda...";