Fix thinko in run/tests on macOS.
[dcpomatic.git] / test / test.cc
index 147aac6bf34847d3c1d013282942d8512b82572f..acbc97ea13557ad398aa1883ed361025ec57ed16 100644 (file)
@@ -120,12 +120,8 @@ setup_test_config ()
        Config::instance()->set_master_encoding_threads (boost::thread::hardware_concurrency() / 2);
        Config::instance()->set_server_encoding_threads (1);
        Config::instance()->set_server_port_base (61921);
-       Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
        Config::instance()->set_default_audio_delay (0);
-       Config::instance()->set_default_video_bit_rate(VideoEncoding::JPEG2000, 100000000);
-       Config::instance()->set_default_interop (false);
        Config::instance()->set_default_still_length (10);
-       Config::instance()->set_default_dcp_audio_channels(8);
        Config::instance()->set_log_types (
                LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING |
                LogEntry::TYPE_ERROR | LogEntry::TYPE_DISK
@@ -203,7 +199,7 @@ test_film_dir (string name)
 
 
 shared_ptr<Film>
-new_test_film(string name, vector<shared_ptr<Content>> content, Cleanup* cleanup)
+new_test_film(string name, vector<shared_ptr<Content>> content, Cleanup* cleanup)
 {
        auto p = test_film_dir (name);
        if (boost::filesystem::exists (p)) {
@@ -214,6 +210,7 @@ new_test_film2 (string name, vector<shared_ptr<Content>> content, Cleanup* clean
        }
 
        auto film = make_shared<Film>(p);
+       film->use_template({});
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
        film->set_container (Ratio::from_id ("185"));
        film->write_metadata ();
@@ -573,7 +570,13 @@ check_dcp(boost::filesystem::path ref, boost::filesystem::path check, bool sound
 }
 
 void
-check_xml(xmlpp::Element* ref, xmlpp::Element* test, list<Glib::ustring> ignore)
+check_xml(
+       xmlpp::Element* ref,
+       xmlpp::Element* test,
+       list<Glib::ustring> ignore,
+       optional<boost::filesystem::path> ref_file,
+       optional<boost::filesystem::path> test_file
+       )
 {
        BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ());
        BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ());
@@ -584,9 +587,13 @@ check_xml(xmlpp::Element* ref, xmlpp::Element* test, list<Glib::ustring> ignore)
 
        auto ref_children = ref->get_children ();
        auto test_children = test->get_children ();
+       string context;
+       if (ref_file && test_file) {
+               context = String::compose(" comparing %1 and %2", ref_file->string(), test_file->string());
+       }
        BOOST_REQUIRE_MESSAGE (
                ref_children.size() == test_children.size(),
-               ref->get_name() << " has " << ref_children.size() << " or " << test_children.size() << " children"
+               ref->get_name() << " has " << ref_children.size() << " or " << test_children.size() << " children" << context
                );
 
        auto k = ref_children.begin ();
@@ -599,7 +606,7 @@ check_xml(xmlpp::Element* ref, xmlpp::Element* test, list<Glib::ustring> ignore)
                auto test_el = dynamic_cast<xmlpp::Element*>(*l);
                BOOST_CHECK ((ref_el && test_el) || (!ref_el && !test_el));
                if (ref_el && test_el) {
-                       check_xml (ref_el, test_el, ignore);
+                       check_xml(ref_el, test_el, ignore, ref_file, test_file);
                }
 
                auto ref_cn = dynamic_cast<xmlpp::ContentNode*>(*k);
@@ -636,7 +643,7 @@ check_xml(boost::filesystem::path ref, boost::filesystem::path test, list<Glib::
        auto test_parser = new xmlpp::DomParser(test.string());
        auto test_root = test_parser->get_document()->get_root_node();
 
-       check_xml (ref_root, test_root, ignore);
+       check_xml(ref_root, test_root, ignore, ref, test);
 }
 
 bool
@@ -1029,8 +1036,16 @@ check_int_close (std::pair<int, int> a, std::pair<int, int> b, int d)
 }
 
 
+ConfigRestorer::ConfigRestorer(boost::filesystem::path override_path)
+{
+       Config::override_path = override_path;
+       Config::drop();
+}
+
+
 ConfigRestorer::~ConfigRestorer()
 {
+       Config::override_path = boost::none;
        setup_test_config();
 }