diff --git a/CMakeLists.txt b/CMakeLists.txt index 77ed236c..840f54fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,8 @@ endif() ExternalProject_Add(libloadorder PREFIX "external" - URL "https://github.com/Ortham/libloadorder/archive/14.1.0.tar.gz" - URL_HASH "SHA256=9ff9c73612bc9e375759e122bfd56a4a45d8a4ca36837f610c05ab52fef9d67b" + URL "https://github.com/Ortham/libloadorder/archive/14.2.0.tar.gz" + URL_HASH "SHA256=247969e3fb67ad0a883ac81ac52a4258ee92b8417d11f45308cc23ccc0d61b36" CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1 BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} && diff --git a/src/api/api.cpp b/src/api/api.cpp index 1c12dd46..d0e3f047 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -112,15 +112,18 @@ LOOT_API std::unique_ptr CreateGameHandle( } auto resolvedGamePath = ResolvePath(gamePath); - if (!fs::is_directory(resolvedGamePath)) + if (!fs::is_directory(resolvedGamePath)) { throw std::invalid_argument("Given game path \"" + gamePath.u8string() + "\" does not resolve to a valid directory."); + } auto resolvedGameLocalPath = ResolvePath(gameLocalPath); - if (!gameLocalPath.empty() && !fs::is_directory(resolvedGameLocalPath)) - throw std::invalid_argument("Given game local path \"" + - gameLocalPath.u8string() + - "\" does not resolve to a valid directory."); + if (!gameLocalPath.empty() && fs::exists(resolvedGameLocalPath) && + !fs::is_directory(resolvedGameLocalPath)) { + throw std::invalid_argument( + "Given game local path \"" + gameLocalPath.u8string() + + "\" resolves to a path that exists but is not a valid directory."); + } return std::make_unique(game, resolvedGamePath, resolvedGameLocalPath); } diff --git a/src/tests/api/interface/create_game_handle_test.h b/src/tests/api/interface/create_game_handle_test.h index 4192351b..9bf216fe 100644 --- a/src/tests/api/interface/create_game_handle_test.h +++ b/src/tests/api/interface/create_game_handle_test.h @@ -115,9 +115,15 @@ TEST_P(CreateGameHandleTest, shouldThrowIfPassedAGamePathThatDoesNotExist) { std::invalid_argument); } -TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatDoesNotExist) { +TEST_P(CreateGameHandleTest, shouldSucceedIfPassedALocalPathThatDoesNotExist) { + EXPECT_NO_THROW(handle_ = CreateGameHandle( + GetParam(), dataPath.parent_path(), missingPath)); + EXPECT_TRUE(handle_); +} + +TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatIsNotADirectory) { EXPECT_THROW( - CreateGameHandle(GetParam(), dataPath.parent_path(), missingPath), + CreateGameHandle(GetParam(), dataPath.parent_path(), dataPath / blankEsm), std::invalid_argument); } diff --git a/src/tests/api/internals/game/load_order_handler_test.h b/src/tests/api/internals/game/load_order_handler_test.h index baca7bdb..4b2ea975 100644 --- a/src/tests/api/internals/game/load_order_handler_test.h +++ b/src/tests/api/internals/game/load_order_handler_test.h @@ -122,10 +122,19 @@ TEST_P(LoadOrderHandlerTest, constructorShouldThrowIfNoGamePathIsSet) { std::invalid_argument); } -#ifndef _WIN32 -TEST_P(LoadOrderHandlerTest, constructorShouldThrowOnLinuxIfNoLocalPathIsSet) { - EXPECT_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()), - std::system_error); +#ifdef _WIN32 +TEST_P(LoadOrderHandlerTest, constructorShouldNotThrowIfNoLocalPathIsSet) { + EXPECT_NO_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path())); +} +#else +TEST_P(LoadOrderHandlerTest, + constructorShouldNotThrowIfNoLocalPathIsSetAndGameTypeIsMorrowind) { + if (GetParam() == GameType::tes3) { + EXPECT_NO_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path())); + } else { + EXPECT_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()), + std::system_error); + } } #endif