Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CRAN NOTE about files in temp directory #349

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ci/r_tests_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 $?
Expand All @@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid the following new CRAN NOTE on Windows:

* checking for detritus in the temp directory ... NOTE
Found the following files/directories:
  'lastMiKTeXException'

Env variable was found in sources of MikTeX:
https://github.com/MiKTeX/miktex/blob/ab8ebca7c70fe8c9a1392dfb2393a0a7683e14cc/Libraries/MiKTeX/Core/Exceptions.cpp#L155-L183
https://github.com/MiKTeX/miktex/blob/ab8ebca7c70fe8c9a1392dfb2393a0a7683e14cc/Libraries/MiKTeX/Core/include/miktex/Core/Environment.h#L37

We cannot remove MikTeX temp files during running testthat because PDF generation happens later in CRAN checks after tests have been finished.
Ideally, this path should be controlled via TempDir config value, but it doesn't.
https://mirror.truenetwork.ru/CTAN/systems/win32/miktex/doc/miktex.pdf

initexmf --set-config-value [Core]TempDir="$env:TEMP\miktex"


cd "$env:GITHUB_WORKSPACE\R-package"
Add-Content .Renviron "R_LIBS=$env:R_LIB_PATH"
Expand Down
7 changes: 7 additions & 0 deletions R-package/tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -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')
4 changes: 4 additions & 0 deletions R-package/tests/testthat/teardown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
context("teardown")

# remove temporary 'rgf' files
if (dir.exists(default_dir)) unlink(default_dir, recursive = TRUE, force = TRUE)
11 changes: 0 additions & 11 deletions R-package/tests/testthat/test-RGF_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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) ]
})