From d05ac3175be1bb59c8e251a6b63e7543d7979e05 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Wed, 25 Jun 2025 09:05:14 +0000 Subject: [PATCH] Small improvements on how paths are handled in tests --- cpp/tests/mip/doc_example_test.cu | 12 +++++++----- cpp/tests/mip/feasibility_jump_tests.cu | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cpp/tests/mip/doc_example_test.cu b/cpp/tests/mip/doc_example_test.cu index 7b32cf068a..c021da0b1c 100644 --- a/cpp/tests/mip/doc_example_test.cu +++ b/cpp/tests/mip/doc_example_test.cu @@ -130,23 +130,25 @@ TEST(docs, user_problem_file) // Create the problem from documentation example auto problem = create_doc_example_problem(); - EXPECT_FALSE(std::filesystem::exists("user_problem.mps")); + const auto user_problem_path = std::filesystem::temp_directory_path() / "user_problem.mps"; + EXPECT_FALSE(std::filesystem::exists(user_problem_path)); settings.time_limit = test_time_limit; - settings.user_problem_file = "user_problem.mps"; + settings.user_problem_file = user_problem_path; EXPECT_EQ(solve_mip(&handle_, problem, settings).get_termination_status(), mip_termination_status_t::Optimal); - EXPECT_TRUE(std::filesystem::exists("user_problem.mps")); + EXPECT_TRUE(std::filesystem::exists(user_problem_path)); cuopt::mps_parser::mps_data_model_t problem2 = - cuopt::mps_parser::parse_mps("user_problem.mps", false); + cuopt::mps_parser::parse_mps(user_problem_path, false); EXPECT_EQ(problem2.get_n_variables(), problem.get_n_variables()); EXPECT_EQ(problem2.get_n_constraints(), problem.get_n_constraints()); EXPECT_EQ(problem2.get_nnz(), problem.get_nnz()); - settings.user_problem_file = "user_problem2.mps"; + const auto user_problem_path2 = std::filesystem::temp_directory_path() / "user_problem2.mps"; + settings.user_problem_file = user_problem_path2; mip_solution_t solution = solve_mip(&handle_, problem2, settings); EXPECT_EQ(solution.get_termination_status(), mip_termination_status_t::Optimal); diff --git a/cpp/tests/mip/feasibility_jump_tests.cu b/cpp/tests/mip/feasibility_jump_tests.cu index d2d878daae..1fafb830e6 100644 --- a/cpp/tests/mip/feasibility_jump_tests.cu +++ b/cpp/tests/mip/feasibility_jump_tests.cu @@ -76,7 +76,7 @@ static fj_state_t run_fj(std::string test_instance, const raft::handle_t handle_{}; std::cout << "Running: " << test_instance << std::endl; - auto path = "datasets/mip/" + test_instance; + auto path = cuopt::test::get_rapids_dataset_root_dir() + ("/mip/" + test_instance); cuopt::mps_parser::mps_data_model_t mps_problem = cuopt::mps_parser::parse_mps(path, false); handle_.sync_stream();