Skip to content

Commit e66c5f3

Browse files
authored
Add guard to global config test. (#12180)
1 parent 718bdae commit e66c5f3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/cpp/c_api/test_c_api.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019-2025, XGBoost contributors
2+
* Copyright 2019-2026, XGBoost contributors
33
*/
44
#include <gtest/gtest.h>
55
#include <xgboost/c_api.h>
@@ -18,6 +18,7 @@
1818

1919
#include "../../../src/c_api/c_api_error.h"
2020
#include "../../../src/common/io.h"
21+
#include "../../../src/common/utils.h" // for MakeCleanup
2122
#include "../../../src/data/adapter.h" // for ArrayAdapter
2223
#include "../../../src/data/array_interface.h" // for ArrayInterface
2324
#include "../../../src/data/batch_utils.h" // for MatchingPageBytes
@@ -273,6 +274,10 @@ TEST(CAPI, Exception) {
273274
}
274275

275276
TEST(CAPI, XGBGlobalConfig) {
277+
auto guard = common::MakeCleanup([cfg_bak = *GlobalConfigThreadLocalStore::Get()] {
278+
*GlobalConfigThreadLocalStore::Get() = cfg_bak;
279+
});
280+
276281
int ret;
277282
{
278283
const char *config_str = R"json(

0 commit comments

Comments
 (0)