Skip to content

Commit

Permalink
Expect error if output path does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Oct 24, 2023
1 parent c1d0a22 commit 2f1c008
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/cpp/lpnamer/main/RunProblemGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ void RunProblemGeneration(
<< "Launching Problem Generation" << std::endl;
if (!CreateDirectories(
xpansion_output_dir, logger.get())) {
return;
throw LogUtils::XpansionError<std::runtime_error>(
"Error creating LP directory", LOGLOCATION);
}
validateMasterFormulation(master_formulation, logger);
std::string solver_name = "CBC"; // TODO Use solver selected by user
Expand Down
16 changes: 16 additions & 0 deletions tests/cpp/lp_namer/ProblemGenerationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,20 @@ TEST(InitializationTest, FoldersAreEmpty) {
ArchiveIOGeneralException);

EXPECT_FALSE(std::filesystem::exists(simulationDirectory / "garbage.txt"));
}

TEST(InitializationTest, ErrorIfSimulationPathDoesNotExists) {
auto workingDirectory =
std::filesystem::temp_directory_path() / std::tmpnam(nullptr);
auto simulationDirectory = workingDirectory / "output" / "simulation";
auto logger = emptyLogger();

EXPECT_THROW(
RunProblemGeneration(simulationDirectory, "integer", "", "", logger,
simulationDirectory / "logs.txt", "", false),
LogUtils::XpansionError<std::runtime_error>);
auto lp = (simulationDirectory.parent_path() /
(simulationDirectory.filename().string() + "-Xpansion")) /
"lp";
EXPECT_FALSE(std::filesystem::exists(lp));
}
6 changes: 0 additions & 6 deletions tests/python/test_problem_generator_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ def test_problem_generator_data(self):
assert problem_generator_driver.user_weights_file_path == self.empty_pblm_gen_data.user_weights_file_path
assert problem_generator_driver.lp_namer_exe_path == self.empty_pblm_gen_data.lp_namer_exe_path

def test_output_path(self, tmp_path):
problem_generator_driver = ProblemGeneratorDriver(
self.empty_pblm_gen_data)
with pytest.raises(ProblemGeneratorDriver.OutputPathError):
problem_generator_driver.launch(tmp_path / "i_don_t_exist", False)

def test_lp_namer_exe_does_not_exit(self, tmp_path):

self._create_empty_area_file(tmp_path)
Expand Down

0 comments on commit 2f1c008

Please sign in to comment.