Run tests in a temporary directory (#7723)

Fix some tests to run in a temporary directory in case the root
directory is not writable. Note that most of tests are already
running in the temporary directory, so this PR just make them
consistent.
This commit is contained in:
Haoming Chen 2022-03-12 05:24:36 -08:00 committed by GitHub
parent 55463b76c1
commit 04fc575c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -194,7 +194,8 @@ TEST(SimpleDMatrix, FromCSC) {
}
TEST(SimpleDMatrix, FromFile) {
std::string filename = "test.libsvm";
dmlc::TemporaryDirectory tempdir;
std::string filename = tempdir.path + "test.libsvm";
CreateBigTestData(filename, 3 * 5);
// Add an empty row at the end of the matrix
{

View File

@ -26,7 +26,7 @@ void TestSparseDMatrixLoadFile() {
data::fileiter::Next,
std::numeric_limits<float>::quiet_NaN(),
1,
"cache"};
tmpdir.path + "cache"};
ASSERT_EQ(m.Info().num_col_, 5);
ASSERT_EQ(m.Info().num_row_, 64);