From 97fabe0e71ebefde89bf6a3fb0824e81a6baecab Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Sat, 21 Aug 2021 04:08:01 +0300 Subject: [PATCH] fix CRAN NOTE about files in temp directory --- .ci/r_tests_windows.ps1 | 3 ++- R-package/tests/testthat/setup.R | 7 +++++++ R-package/tests/testthat/teardown.R | 4 ++++ R-package/tests/testthat/test-RGF_package.R | 11 ----------- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 R-package/tests/testthat/teardown.R diff --git a/.ci/r_tests_windows.ps1 b/.ci/r_tests_windows.ps1 index 5af9413f..1c67c174 100644 --- a/.ci/r_tests_windows.ps1 +++ b/.ci/r_tests_windows.ps1 @@ -31,7 +31,7 @@ $env:_R_CHECK_EXAMPLE_TIMING_THRESHOLD_ = 30 # see: https://stackoverflow.com/a/63837547/8302386 $env:_R_CHECK_SYSTEM_CLOCK_ = 0 -$R_VER = "4.1.0" +$R_VER = "4.1.1" $ProgressPreference = "SilentlyContinue" # progress bar bug extremely slows down download speed Invoke-WebRequest -Uri https://cloud.r-project.org/bin/windows/base/old/$R_VER/R-$R_VER-win.exe -OutFile R-win.exe -MaximumRetryCount 5 Start-Process -FilePath R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH\R /COMPONENTS=main,x64" ; Check-Output $? @@ -50,6 +50,7 @@ Invoke-WebRequest -Uri https://sourceforge.net/projects/qpdf/files/qpdf/10.3.1/q Copy-Item .\qpdf -Destination $env:R_LIB_PATH -Recurse initexmf --set-config-value [MPM]AutoInstall=1 +$env:MIKTEX_EXCEPTION_PATH = "$env:TEMP\miktex" cd "$env:GITHUB_WORKSPACE\R-package" Add-Content .Renviron "R_LIBS=$env:R_LIB_PATH" diff --git a/R-package/tests/testthat/setup.R b/R-package/tests/testthat/setup.R index 04794efc..076938e3 100644 --- a/R-package/tests/testthat/setup.R +++ b/R-package/tests/testthat/setup.R @@ -41,3 +41,10 @@ y_MULTIclass = sample(1:5, 100, replace = TRUE) set.seed(6) W = runif(100) + +# Temporary I/O structures + +# default directory where the temporary 'rgf' files are saved +#------------------------------------------------------------ + +default_dir = file.path(dirname(tempdir()), 'rgf') diff --git a/R-package/tests/testthat/teardown.R b/R-package/tests/testthat/teardown.R new file mode 100644 index 00000000..f4398ff5 --- /dev/null +++ b/R-package/tests/testthat/teardown.R @@ -0,0 +1,4 @@ +context("teardown") + +# remove temporary 'rgf' files +if (dir.exists(default_dir)) unlink(default_dir, recursive = TRUE, force = TRUE) diff --git a/R-package/tests/testthat/test-RGF_package.R b/R-package/tests/testthat/test-RGF_package.R index 0b10f7e1..d6c7b706 100644 --- a/R-package/tests/testthat/test-RGF_package.R +++ b/R-package/tests/testthat/test-RGF_package.R @@ -466,11 +466,6 @@ testthat::test_that("the 'cleanup' method (ESTIMATOR specific) works as expected skip_test_if_no_python() skip_test_if_no_module("rgf.sklearn") - #-------------------------------------------------------------------------------- - # default directory where the temporary 'rgf' files are saved - - default_dir = file.path(dirname(tempdir()), 'rgf') - #-------------------------------------------------------------------------------- # RGF @@ -515,11 +510,6 @@ testthat::test_that("the 'cleanup' method (APPLIES TO ALL ESTIMATORS) works as e skip_test_if_no_python() skip_test_if_no_module("rgf.sklearn") - #-------------------------------------------------------------------------------- - # default directory where the temporary 'rgf' files are saved - - default_dir = file.path(dirname(tempdir()), 'rgf') - #-------------------------------------------------------------------------------- # RGF @@ -549,4 +539,3 @@ testthat::test_that("the 'cleanup' method (APPLIES TO ALL ESTIMATORS) works as e testthat::expect_true( init_exists_upd_rgf && (init_num_files_rgf > 0) && (init_num_files_fastrgf > init_num_files_rgf) && ( init_num_files_rgf > length(lst_files_tmp) && init_num_files_fastrgf > length(lst_files_tmp_end_state) ) ) # normally, both initial and end state must have the same length [ length(lst_files_tmp) == length(lst_files_tmp_end_state) ] }) -