From b8e6551734910d263e713507605672a40c6ef178 Mon Sep 17 00:00:00 2001 From: Tong He Date: Fri, 19 Aug 2016 16:55:03 -0700 Subject: [PATCH] Add unittest for garbage collection's safety in R (#1490) * Add test for garbage collection safety --- R-package/tests/testthat/test_gc_safety.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 R-package/tests/testthat/test_gc_safety.R diff --git a/R-package/tests/testthat/test_gc_safety.R b/R-package/tests/testthat/test_gc_safety.R new file mode 100644 index 000000000..795621346 --- /dev/null +++ b/R-package/tests/testthat/test_gc_safety.R @@ -0,0 +1,15 @@ +require(xgboost) + +context("Garbage Collection Safety Check") + +test_that("train and prediction when gctorture is on", { + data(agaricus.train, package='xgboost') + data(agaricus.test, package='xgboost') + train <- agaricus.train + test <- agaricus.test + gctorture(TRUE) + bst <- xgboost(data = train$data, label = train$label, max.depth = 2, + eta = 1, nthread = 2, nround = 2, objective = "binary:logistic") + pred <- predict(bst, test$data) + gctorture(FALSE) +})