summaryrefslogtreecommitdiff
path: root/test/relative_paths_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-09-16 10:10:46 +0200
committerCarl Hetherington <cth@carlh.net>2024-09-18 10:41:19 +0200
commita9cb7313f7846f8b2bf9f96d19cf28abd7caf7fc (patch)
tree020b1ed7922e97c9711641209efdab845cdf65fc /test/relative_paths_test.cc
parent5c5da23c412e9b922154f8934e16f3a51ff48bdc (diff)
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.
Diffstat (limited to 'test/relative_paths_test.cc')
-rw-r--r--test/relative_paths_test.cc44
1 files changed, 44 insertions, 0 deletions
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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/content.h"
+#include "lib/content_factory.h"
+#include "lib/config.h"
+#include "lib/film.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+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<Film>(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());
+}
+