Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
59f59c9f
Unverified
Commit
59f59c9f
authored
May 30, 2022
by
James Lamb
Committed by
GitHub
May 30, 2022
Browse files
[R-package] [ci] silence more logs in tests (fixes #4862) (#5250)
parent
fb37e507
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
35 deletions
+55
-35
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+23
-17
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+3
-1
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+29
-17
No files found.
R-package/tests/testthat/test_basic.R
View file @
59f59c9f
...
@@ -561,13 +561,15 @@ test_that("lgb.cv() raises an informative error for unrecognized objectives", {
...
@@ -561,13 +561,15 @@ test_that("lgb.cv() raises an informative error for unrecognized objectives", {
,
label
=
train
$
label
,
label
=
train
$
label
)
)
expect_error
({
expect_error
({
bst
<-
lgb.cv
(
capture.output
({
data
=
dtrain
bst
<-
lgb.cv
(
,
params
=
list
(
data
=
dtrain
objective_type
=
"not_a_real_objective"
,
params
=
list
(
,
verbosity
=
VERBOSITY
objective_type
=
"not_a_real_objective"
,
verbosity
=
VERBOSITY
)
)
)
)
},
type
=
"message"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
})
})
...
@@ -723,13 +725,15 @@ test_that("lgb.train() raises an informative error for unrecognized objectives",
...
@@ -723,13 +725,15 @@ test_that("lgb.train() raises an informative error for unrecognized objectives",
,
label
=
train
$
label
,
label
=
train
$
label
)
)
expect_error
({
expect_error
({
bst
<-
lgb.train
(
capture.output
({
data
=
dtrain
bst
<-
lgb.train
(
,
params
=
list
(
data
=
dtrain
objective_type
=
"not_a_real_objective"
,
params
=
list
(
,
verbosity
=
VERBOSITY
objective_type
=
"not_a_real_objective"
,
verbosity
=
VERBOSITY
)
)
)
)
},
type
=
"message"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
})
})
...
@@ -2441,11 +2445,13 @@ test_that("lgb.train() w/ linear learner fails already-constructed dataset with
...
@@ -2441,11 +2445,13 @@ test_that("lgb.train() w/ linear learner fails already-constructed dataset with
)
)
dtrain
$
construct
()
dtrain
$
construct
()
expect_error
({
expect_error
({
bst_linear
<-
lgb.train
(
capture.output
({
data
=
dtrain
bst_linear
<-
lgb.train
(
,
nrounds
=
10L
data
=
dtrain
,
params
=
utils
::
modifyList
(
params
,
list
(
linear_tree
=
TRUE
))
,
nrounds
=
10L
)
,
params
=
utils
::
modifyList
(
params
,
list
(
linear_tree
=
TRUE
))
)
},
type
=
"message"
)
},
regexp
=
"Cannot change linear_tree after constructed Dataset handle"
)
},
regexp
=
"Cannot change linear_tree after constructed Dataset handle"
)
})
})
...
...
R-package/tests/testthat/test_dataset.R
View file @
59f59c9f
...
@@ -226,7 +226,9 @@ test_that("cpp errors should be raised as proper R errors", {
...
@@ -226,7 +226,9 @@ test_that("cpp errors should be raised as proper R errors", {
,
init_score
=
seq_len
(
10L
)
,
init_score
=
seq_len
(
10L
)
)
)
expect_error
({
expect_error
({
dtrain
$
construct
()
capture.output
({
dtrain
$
construct
()
},
type
=
"message"
)
},
regexp
=
"Initial score size doesn't match data size"
)
},
regexp
=
"Initial score size doesn't match data size"
)
})
})
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
59f59c9f
...
@@ -749,7 +749,11 @@ test_that("Saving a model with unknown importance type fails", {
...
@@ -749,7 +749,11 @@ test_that("Saving a model with unknown importance type fails", {
UNSUPPORTED_IMPORTANCE
<-
2L
UNSUPPORTED_IMPORTANCE
<-
2L
expect_error
({
expect_error
({
model_string
<-
bst
$
save_model_to_string
(
feature_importance_type
=
UNSUPPORTED_IMPORTANCE
)
capture.output
({
model_string
<-
bst
$
save_model_to_string
(
feature_importance_type
=
UNSUPPORTED_IMPORTANCE
)
},
type
=
"message"
)
},
"Unknown importance type"
)
},
"Unknown importance type"
)
})
})
...
@@ -964,10 +968,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
...
@@ -964,10 +968,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
# unrecognized objective
# unrecognized objective
expect_error
({
expect_error
({
Booster
$
new
(
capture.output
({
params
=
list
(
objective
=
"not_a_real_objective"
)
Booster
$
new
(
,
train_set
=
dtrain
params
=
list
(
objective
=
"not_a_real_objective"
)
)
,
train_set
=
dtrain
)
},
type
=
"message"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
},
regexp
=
"Unknown objective type name: not_a_real_objective"
)
# train_set is not a Dataset
# train_set is not a Dataset
...
@@ -986,10 +992,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
...
@@ -986,10 +992,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
# model file doesn't exist
# model file doesn't exist
expect_error
({
expect_error
({
Booster
$
new
(
capture.output
({
params
=
list
()
Booster
$
new
(
,
modelfile
=
"file-that-does-not-exist.model"
params
=
list
()
)
,
modelfile
=
"file-that-does-not-exist.model"
)
},
type
=
"message"
)
},
regexp
=
"Could not open file-that-does-not-exist.model"
)
},
regexp
=
"Could not open file-that-does-not-exist.model"
)
# model file doesn't contain a valid LightGBM model
# model file doesn't contain a valid LightGBM model
...
@@ -999,18 +1007,22 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
...
@@ -999,18 +1007,22 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
,
con
=
model_file
,
con
=
model_file
)
)
expect_error
({
expect_error
({
Booster
$
new
(
capture.output
({
params
=
list
()
Booster
$
new
(
,
modelfile
=
model_file
params
=
list
()
)
,
modelfile
=
model_file
)
},
type
=
"message"
)
},
regexp
=
"Unknown model format or submodel type in model file"
)
},
regexp
=
"Unknown model format or submodel type in model file"
)
# malformed model string
# malformed model string
expect_error
({
expect_error
({
Booster
$
new
(
capture.output
({
params
=
list
()
Booster
$
new
(
,
model_str
=
"a\nb\n"
params
=
list
()
)
,
model_str
=
"a\nb\n"
)
},
type
=
"message"
)
},
regexp
=
"Model file doesn't specify the number of classes"
)
},
regexp
=
"Model file doesn't specify the number of classes"
)
# model string isn't character or raw
# model string isn't character or raw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment