+ check_text_file ("test/data/utf8_config.xml", "build/test/config.xml");
+}
+
+
+BOOST_AUTO_TEST_CASE (config_upgrade_test)
+{
+ ConfigRestorer cr;
+
+ boost::filesystem::path dir = "build/test/config_upgrade_test";
+ Config::override_path = dir;
+ Config::drop ();
+ boost::filesystem::remove_all (dir);
+ boost::filesystem::create_directories (dir);
+
+ boost::filesystem::copy_file ("test/data/2.14.config.xml", dir / "config.xml");
+ boost::filesystem::copy_file ("test/data/2.14.cinemas.xml", dir / "cinemas.xml");
+ Config::instance();
+ try {
+ /* This will fail to write cinemas.xml since the link is to a non-existant directory */
+ Config::instance()->write();
+ } catch (...) {}
+
+ check_xml (dir / "config.xml", "test/data/2.14.config.xml", {});
+ check_xml (dir / "cinemas.xml", "test/data/2.14.cinemas.xml", {});
+#ifdef DCPOMATIC_WINDOWS
+ /* This file has the windows path for dkdm_recipients.xml (with backslashes) */
+ check_xml (dir / "2.16" / "config.xml", "test/data/2.16.config.windows.xml", {});
+#else
+ check_xml (dir / "2.16" / "config.xml", "test/data/2.16.config.xml", {});
+#endif
+ /* cinemas.xml is not copied into 2.16 as its format has not changed */
+ BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.16" / "cinemas.xml"));
+}
+
+
+BOOST_AUTO_TEST_CASE (config_keep_cinemas_if_making_new_config)
+{
+ ConfigRestorer cr;
+
+ boost::filesystem::path dir = "build/test/config_keep_cinemas_if_making_new_config";
+ Config::override_path = dir;
+ Config::drop ();
+ boost::filesystem::remove_all (dir);
+ boost::filesystem::create_directories (dir);
+
+ Config::instance()->write();
+
+ Config::instance()->add_cinema(make_shared<Cinema>("My Great Cinema", list<string>(), "", 0, 0));
+ Config::instance()->write();
+
+ boost::filesystem::copy_file (dir / "cinemas.xml", dir / "backup_for_test.xml");
+
+ Config::drop ();
+ boost::filesystem::remove (dir / "2.16" / "config.xml");
+ Config::instance();
+
+ check_text_file (dir / "backup_for_test.xml", dir / "cinemas.xml.1");