From fde02c4beac7188709972ee43fd4e6e071c2d4ef Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 27 Dec 2020 19:55:31 +0000 Subject: Tweaks to improve diagnostic output --- gentoobrowse/src/test.cpp | 75 ++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp index ebb3e78..98dec8d 100644 --- a/gentoobrowse/src/test.cpp +++ b/gentoobrowse/src/test.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -49,20 +50,26 @@ public: virtual void standardAssertions(const char * name) override { - auto h = getResponseHeaders(); - BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); - BOOST_REQUIRE_EQUAL(h["Content-Type"], "text/html"); - - TidyDoc tdoc = tidyCreate(); - TidyInputSource tis {&output, &streamGet, &streamUnget, &streamEof}; - BOOST_REQUIRE_EQUAL(1, tidyOptSetBool(tdoc, TidyIndentContent, yes)); - BOOST_REQUIRE_EQUAL(1, tidyOptSetBool(tdoc, TidyQuiet, yes)); - BOOST_REQUIRE_EQUAL(1, tidyOptSetInt(tdoc, TidyWrapLen, 0)); - BOOST_REQUIRE_EQUAL(0, tidyParseSource(tdoc, &tis)); - BOOST_REQUIRE_EQUAL(0, tidyCleanAndRepair(tdoc)); - BOOST_REQUIRE_EQUAL(0, tidySaveFile(tdoc, (binDir / name).replace_extension(".html").c_str())); - BOOST_REQUIRE_EQUAL(0, tidyRunDiagnostics(tdoc)); - tidyRelease(tdoc); + BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) { + auto realname = abi::__cxa_demangle(name, 0, 0, nullptr); + const auto outputPath {(binDir / realname).replace_extension(".html")}; + std::ofstream {outputPath} << (output.str()); + + auto h = getResponseHeaders(); + BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); + BOOST_REQUIRE_EQUAL(h["Content-Type"], "text/html"); + + TidyDoc tdoc = tidyCreate(); + TidyInputSource tis {&output, &streamGet, &streamUnget, &streamEof}; + BOOST_REQUIRE_EQUAL(1, tidyOptSetBool(tdoc, TidyIndentContent, yes)); + BOOST_REQUIRE_EQUAL(1, tidyOptSetBool(tdoc, TidyQuiet, yes)); + BOOST_REQUIRE_EQUAL(1, tidyOptSetInt(tdoc, TidyWrapLen, 0)); + BOOST_REQUIRE_EQUAL(0, tidyParseSource(tdoc, &tis)); + BOOST_CHECK_EQUAL(0, tidyCleanAndRepair(tdoc)); + BOOST_CHECK_EQUAL(0, tidySaveFile(tdoc, outputPath.c_str())); + BOOST_CHECK_EQUAL(0, tidyRunDiagnostics(tdoc)); + tidyRelease(tdoc); + } } }; @@ -131,105 +138,105 @@ BOOST_AUTO_TEST_CASE(home) { ChromiumRequestHtml request(this, HttpMethod::GET, "/"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(news) { ChromiumRequestHtml request(this, HttpMethod::GET, "/news"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(news_ruby_20_removal) { ChromiumRequestHtml request(this, HttpMethod::GET, "/news/2016-12-06-ruby-20-removal"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(news_404) { ChromiumRequest404 request(this, HttpMethod::GET, "/news/404"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages) { ChromiumRequestHtml request(this, HttpMethod::GET, "/packages"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages_popular) { ChromiumRequestHtml request(this, HttpMethod::GET, "/packages/popular"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages_virtual) { ChromiumRequestHtml request(this, HttpMethod::GET, "/packages/virtual"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages_404) { ChromiumRequest404 request(this, HttpMethod::GET, "/packages/404"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages_virtual_cron) { ChromiumRequestHtml request(this, HttpMethod::GET, "/packages/virtual/cron"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(packages_virtual_404) { ChromiumRequest404 request(this, HttpMethod::GET, "/packages/virtual/404"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(use) { ChromiumRequestHtml request(this, HttpMethod::GET, "/use"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(use_gles) { ChromiumRequestHtml request(this, HttpMethod::GET, "/use/gles"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(use_404) { ChromiumRequest404 request(this, HttpMethod::GET, "/use/404"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(usegroup) { ChromiumRequestHtml request(this, HttpMethod::GET, "/usegroup"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(usegroup_gles) { ChromiumRequestHtml request(this, HttpMethod::GET, "/usegroup/i18n"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(search_default) @@ -237,35 +244,35 @@ BOOST_AUTO_TEST_CASE(search_default) ChromiumRequestHtml request(this, HttpMethod::GET, "/search"); request.qs["criteria"] = "default"; process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(search_sitemap) { ChromiumRequestXml request(this, HttpMethod::GET, "/sitemap.xml"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(home_atom) { ChromiumRequestAtom request(this, HttpMethod::GET, "/"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(news_atom) { ChromiumRequestAtom request(this, HttpMethod::GET, "/news"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_CASE(user_atom) { ChromiumRequestAtom request(this, HttpMethod::GET, "/atom/randomdan"); process(&request); - request.standardAssertions(typeid(this).name()); + request.standardAssertions(typeid(*this).name()); } BOOST_AUTO_TEST_SUITE_END(); -- cgit v1.2.3