Unverified Commit 7f71c96c authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] fixed some minor issues with testing on Windows (#2908)

parent c6245ed4
......@@ -400,6 +400,8 @@ python-package/lightgbm/VERSION.txt
R-package/src/CMakeLists.txt
R-package/src/lib_lightgbm.so.dSYM/
R-package/src/src/
R-package/src-x64
R-package/src-i386
lightgbm_r/*
lightgbm*.tar.gz
lightgbm.Rcheck/
......
......@@ -4,7 +4,7 @@ use_gpu <- FALSE
use_mingw <- FALSE
if (.Machine$sizeof.pointer != 8L) {
stop("Only support 64-bit R, please check your the version of your R and Rtools.")
stop("LightGBM only supports 64-bit R, please check the version of R and Rtools.")
}
R_int_UUID <- .Internal(internalsID())
......@@ -16,8 +16,13 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262"
}
# Move in CMakeLists.txt
if (!file.copy("../inst/bin/CMakeLists.txt", "CMakeLists.txt", overwrite = TRUE)) {
stop("Copying CMakeLists failed")
write_succeeded <- file.copy(
"../inst/bin/CMakeLists.txt"
, "CMakeLists.txt"
, overwrite = TRUE
)
if (!write_succeeded) {
stop("Copying CMakeLists.txt failed")
}
# Get some paths
......@@ -55,22 +60,28 @@ if (!use_precompile) {
build_cmd <- "mingw32-make.exe _lightgbm"
system(paste0(cmake_cmd, " ..")) # Must build twice for Windows due sh.exe in Rtools
} else {
try_vs <- 0L
local_vs_def <- ""
vs_versions <- c("Visual Studio 16 2019", "Visual Studio 15 2017", "Visual Studio 14 2015")
vs_versions <- c(
"Visual Studio 16 2019"
, "Visual Studio 15 2017"
, "Visual Studio 14 2015"
)
for (vs in vs_versions) {
print(paste0("Trying to build with: '", vs, "'"))
vs_def <- paste0(" -G \"", vs, "\" -A x64")
tmp_cmake_cmd <- paste0(cmake_cmd, vs_def)
try_vs <- system(paste0(tmp_cmake_cmd, " .."))
if (try_vs == 0L) {
local_vs_def <- vs_def
print(paste0("Building with '", vs, "' succeeded"))
break
} else {
unlink("./*", recursive = TRUE) # Clean up build directory
}
}
if (try_vs == 1L) {
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ") # Switch to MinGW on failure, try build once
print("Building with Visual Studio failed. Attempted with MinGW")
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ")
system(paste0(cmake_cmd, " ..")) # Must build twice for Windows due sh.exe in Rtools
build_cmd <- "mingw32-make.exe _lightgbm"
} else {
......
......@@ -86,5 +86,5 @@ test_that("lgb.get.eval.result() should throw an informative error for incorrect
, data_name = "test"
, eval_name = "l1"
)
}, regexp = "Only the following eval_names exist for dataset 'test': [l2]", fixed = TRUE)
}, regexp = "Only the following eval_names exist for dataset.*\\: \\[l2\\]", fixed = FALSE)
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment