From b1234b808de21d136d703d32f7b9a7510d7a6c32 Mon Sep 17 00:00:00 2001 From: Cosmin Stejerean Date: Tue, 18 Jul 2023 10:59:54 +0200 Subject: [PATCH] remove use of __FILE__ for test data --- packager/mpd/CMakeLists.txt | 7 +++++++ packager/mpd/test/mpd_builder_test_helper.cc | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packager/mpd/CMakeLists.txt b/packager/mpd/CMakeLists.txt index 868e099296b..1a22134b692 100644 --- a/packager/mpd/CMakeLists.txt +++ b/packager/mpd/CMakeLists.txt @@ -79,6 +79,13 @@ add_executable(mpd_unittest util/mpd_writer_unittest.cc ) +target_compile_definitions(mpd_unittest + PRIVATE + # We used to build off of __FILE__, but that is not always an absolute + # path, depending on the version of CMake. This is consistent. + TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/data" + TEST_SCHEMA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/schema") + target_link_libraries(mpd_unittest file file_test_util diff --git a/packager/mpd/test/mpd_builder_test_helper.cc b/packager/mpd/test/mpd_builder_test_helper.cc index 4c6087d130f..af8a6d21e20 100644 --- a/packager/mpd/test/mpd_builder_test_helper.cc +++ b/packager/mpd/test/mpd_builder_test_helper.cc @@ -19,13 +19,13 @@ namespace shaka { std::filesystem::path GetTestDataFilePath(const std::string& name) { - std::filesystem::path header_path(__FILE__); - return header_path.parent_path() / "data" / name; + auto data_dir = std::filesystem::path(TEST_DATA_DIR); + return data_dir / name; } std::filesystem::path GetSchemaPath() { - std::filesystem::path header_path(__FILE__); - return header_path.parent_path() / "schema" / "DASH-MPD.xsd"; + auto schema_dir = std::filesystem::path(TEST_SCHEMA_DIR); + return schema_dir / "DASH-MPD.xsd"; } std::string GetPathContent(std::filesystem::path& file_path) {