From a9cb7313f7846f8b2bf9f96d19cf28abd7caf7fc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 16 Sep 2024 10:10:46 +0200 Subject: Fix thinko in relative path change. We have to canonicalise relative paths with respect to the film's directory on load, otherwise we try to use the relative path and it's interpreted against the current working directory. This unfortunately requires the film's directory to be piped into quite a lot of new places. --- test/relative_paths_test.cc | 44 +++++++++++++++++++++++++++++++++++++++++++ test/time_calculation_test.cc | 8 ++++---- test/wscript | 1 + 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test/relative_paths_test.cc (limited to 'test') diff --git a/test/relative_paths_test.cc b/test/relative_paths_test.cc new file mode 100644 index 000000000..cf40a8465 --- /dev/null +++ b/test/relative_paths_test.cc @@ -0,0 +1,44 @@ +/* + Copyright (C) 2024 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/content.h" +#include "lib/content_factory.h" +#include "lib/config.h" +#include "lib/film.h" +#include "test.h" +#include + + +BOOST_AUTO_TEST_CASE(relative_paths_test) +{ + ConfigRestorer cr; + Config::instance()->set_relative_paths(true); + + auto picture = content_factory("test/data/flat_red.png")[0]; + auto film = new_test_film("relative_paths_test", { picture }); + film->write_metadata(); + + auto film2 = std::make_shared(boost::filesystem::path("build/test/relative_paths_test")); + film2->read_metadata(); + BOOST_REQUIRE_EQUAL(film2->content().size(), 1U); + BOOST_REQUIRE(film2->content()[0]->paths_valid()); +} + diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index 0e09ae2c3..28a1c61ab 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) doc->read_string (xml); list notes; - auto content = make_shared(doc, film->state_version(), notes); + auto content = std::make_shared(doc, boost::none, film->state_version(), notes); /* 25fps content, 25fps DCP */ film->set_video_frame_rate (25); @@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) doc->read_string (xml); list notes; - auto content = make_shared(doc, film->state_version(), notes); + auto content = std::make_shared(doc, boost::none, film->state_version(), notes); film->set_sequence (false); film->add_content (content); @@ -398,7 +398,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) doc->read_string (xml); list notes; - auto content = make_shared(doc, film->state_version(), notes); + auto content = std::make_shared(doc, boost::none, film->state_version(), notes); film->set_sequence (false); film->add_content (content); @@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) doc->read_string (xml); list notes; - auto content = make_shared(doc, film->state_version(), notes); + auto content = std::make_shared(doc, boost::none, film->state_version(), notes); auto stream = content->audio->streams().front(); film->set_sequence (false); film->add_content (content); diff --git a/test/wscript b/test/wscript index 2802a4678..e9f24f0fe 100644 --- a/test/wscript +++ b/test/wscript @@ -132,6 +132,7 @@ def build(bld): playlist_test.cc pulldown_detect_test.cc ratio_test.cc + relative_paths_test.cc release_notes_test.cc repeat_frame_test.cc recover_test.cc -- cgit v1.2.3