From bd05fae9aa301603ef850aed774209227a66e193 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 13 Aug 2017 00:49:39 +0200 Subject: [PATCH 1/3] Enhanced error handling for unit test runner. --- src/ut/utMain.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ut/utMain.cc b/src/ut/utMain.cc index 99abb31e5..e61ac531e 100644 --- a/src/ut/utMain.cc +++ b/src/ut/utMain.cc @@ -822,13 +822,15 @@ main_cont (int argc, char **argv) // there is no "dlopen" on mingw, so we need to emulate it. HINSTANCE handle = LoadLibraryW ((const wchar_t *) tl::to_qstring (pp).constData ()); if (! handle) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin tests: %s with error message: %s ")), pp, GetLastError ()); + std::cerr << tl::sprintf ("Unable to load plugin tests: %s with error message: %s", pp.c_str (), GetLastError ()) << std::endl; + exit (1); } #else void *handle; handle = dlopen (tl::string_to_system (pp).c_str (), RTLD_LAZY); if (! handle) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin tests: %s")), pp); + std::cerr << tl::sprintf ("Unable to load plugin tests: %s", pp.c_str ()) << std::endl; + exit (1); } #endif From 0accc84367c59a4d8ac248b417a795f2b9d9fa6f Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 14 Aug 2017 21:29:10 +0200 Subject: [PATCH 2/3] Bugfix: package installation wasn't working from scratch * Create the "salt" package directory as well - not just the package folder * Include the package folder in the error message * A better indication of what to do in the Apply button message --- src/lay/laySalt.cc | 6 +++--- src/lay/laySaltManagerDialog.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lay/laySalt.cc b/src/lay/laySalt.cc index 7ef818c5b..c327062ff 100644 --- a/src/lay/laySalt.cc +++ b/src/lay/laySalt.cc @@ -366,7 +366,7 @@ public: bool Salt::create_grain (const SaltGrain &templ, SaltGrain &target) { - tl_assert (!m_root.is_empty ()); + tl_assert (m_root.begin_collections () != m_root.end_collections ()); const SaltGrains *coll = m_root.begin_collections ().operator-> (); @@ -407,8 +407,8 @@ Salt::create_grain (const SaltGrain &templ, SaltGrain &target) if (subdir.exists () && ! subdir.isDir ()) { throw tl::Exception (tl::to_string (tr ("Unable to create target directory '%1' for installing package - is already a file").arg (subdir.path ()))); } else if (! subdir.exists ()) { - if (! target_dir.mkdir (tl::to_qstring (*n))) { - throw tl::Exception (tl::to_string (tr ("Unable to create target directory '%1' for installing package").arg (subdir.path ()))); + if (! target_dir.mkpath (tl::to_qstring (*n))) { + throw tl::Exception (tl::to_string (tr ("Unable to create target directory '%1' for installing package").arg (subdir.filePath ()))); } if (! target_dir.cd (tl::to_qstring (*n))) { throw tl::Exception (tl::to_string (tr ("Unable to change to target directory '%1' for installing package").arg (subdir.path ()))); diff --git a/src/lay/laySaltManagerDialog.cc b/src/lay/laySaltManagerDialog.cc index d16ee2b37..7c2cf6fd1 100644 --- a/src/lay/laySaltManagerDialog.cc +++ b/src/lay/laySaltManagerDialog.cc @@ -454,7 +454,7 @@ SaltManagerDialog::update_apply_state () apply_new_button->setEnabled (marked > 0); if (marked == 0) { - apply_label_new->setText (QString ()); + apply_label_new->setText (tr ("Select at least one package for installation (check button)")); } else if (marked == 1) { apply_label_new->setText (tr ("One package selected")); } else if (marked > 1) { From 639eef069ca5a842b3b4523cbdea17bcfb932600 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 14 Aug 2017 23:28:02 +0200 Subject: [PATCH 3/3] Introducing a tolerance to reduce the number of test fails --- src/unit_tests/dbCIFReader.cc | 4 ++-- src/unit_tests/dbDXFReader.cc | 2 +- src/unit_tests/extGerberImport.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unit_tests/dbCIFReader.cc b/src/unit_tests/dbCIFReader.cc index 051c65c03..129617cfb 100644 --- a/src/unit_tests/dbCIFReader.cc +++ b/src/unit_tests/dbCIFReader.cc @@ -128,12 +128,12 @@ static void run_test (ut::TestBase *_this, const char *file, const char *file_au reader.read (layout_au); } - bool equal = db::compare_layouts (layout2, layout_au, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 0); + bool equal = db::compare_layouts (layout2, layout_au, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1); if (! equal) { _this->raise (tl::sprintf ("Compare failed after reading - see %s vs %s\n", tmp_gds_file, file_au)); } - equal = db::compare_layouts (layout, layout2_cif, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 0); + equal = db::compare_layouts (layout, layout2_cif, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1); if (! equal) { _this->raise (tl::sprintf ("Compare failed after writing - see %s vs %s\n", file, tmp_cif_file)); } diff --git a/src/unit_tests/dbDXFReader.cc b/src/unit_tests/dbDXFReader.cc index ba19ae868..4feff8080 100644 --- a/src/unit_tests/dbDXFReader.cc +++ b/src/unit_tests/dbDXFReader.cc @@ -67,7 +67,7 @@ static void run_test (ut::TestBase *_this, const char *file, const char *file_au reader.read (layout, options); } - _this->compare_layouts (layout, ut::testsrc_private () + std::string ("/testdata/dxf/") + file_au); + _this->compare_layouts (layout, ut::testsrc_private () + std::string ("/testdata/dxf/") + file_au, ut::WriteGDS2, 1); } TEST(1a) diff --git a/src/unit_tests/extGerberImport.cc b/src/unit_tests/extGerberImport.cc index 0e05a3dab..49d7ddb36 100644 --- a/src/unit_tests/extGerberImport.cc +++ b/src/unit_tests/extGerberImport.cc @@ -47,7 +47,7 @@ static void run_test (ut::TestBase *_this, const char *dir) reader.read (layout, options); } - _this->compare_layouts (layout, ut::testsrc_private () + "/testdata/pcb/" + dir + "/au.oas.gz", ut::WriteOAS); + _this->compare_layouts (layout, ut::testsrc_private () + "/testdata/pcb/" + dir + "/au.oas.gz", ut::WriteOAS, 1); } TEST(1)