Skip to content

Commit

Permalink
remove use of __FILE__ for test data
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed Jul 21, 2023
1 parent 4a642a1 commit b1234b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions packager/mpd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packager/mpd/test/mpd_builder_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b1234b8

Please sign in to comment.