From 68a6e87a7a0166031208da90b088791b96e7a0b0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Apr 2023 18:21:43 +0100 Subject: Dump XML documents for analysis, not just HTML docs --- gentoobrowse/src/test.cpp | 54 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp index 01ffa76..a534cc6 100644 --- a/gentoobrowse/src/test.cpp +++ b/gentoobrowse/src/test.cpp @@ -37,6 +37,13 @@ public: hdr["Accept-Encoding"] = "gzip, deflate, sdch"; hdr["Accept-Language"] = "en-GB,en;q=0.8"; } + auto + getOutputPath(const char * name, const char * ext) + { + auto realname + = std::unique_ptr {abi::__cxa_demangle(name, 0, 0, nullptr), std::free}; + return (binDir / realname.get()).replace_extension(ext); + } }; template class ChromiumRequestT : public ChromiumRequest { using ChromiumRequest::ChromiumRequest; @@ -55,11 +62,6 @@ public: standardAssertions(const char * name) override { BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) { - auto realname - = std::unique_ptr {abi::__cxa_demangle(name, 0, 0, nullptr), std::free}; - const auto outputPath {(binDir / realname.get()).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"); @@ -71,7 +73,7 @@ public: 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, tidySaveFile(tdoc, getOutputPath(name, ".html").c_str())); BOOST_CHECK_EQUAL(0, tidyRunDiagnostics(tdoc)); tidyRelease(tdoc); } @@ -95,24 +97,28 @@ public: using ChromiumRequestT::ChromiumRequestT; virtual std::unique_ptr - standardAssertions(const char *) override + standardAssertions(const char * name) override { - auto h = getResponseHeaders(); - BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); - BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/xml"); - BOOST_TEST_INFO(this->output.view()); - BOOST_REQUIRE_NE(this->output.view().find("(); - p->parse_stream(this->output); + BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) { + auto h = getResponseHeaders(); + BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); + BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/xml"); + BOOST_REQUIRE_NE(this->output.view().find("parse_stream(this->output); + p->get_document()->write_to_file_formatted(getOutputPath(name, ".xml")); + } return p; } void xsdAssertions(const char * name, const std::filesystem::path & xsd) { - auto doc = standardAssertions(name); - xmlpp::XsdValidator validator {xsd}; - validator.validate(doc->get_document()); + BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) { + auto doc = standardAssertions(name); + xmlpp::XsdValidator validator {xsd}; + validator.validate(doc->get_document()); + } } }; @@ -132,15 +138,17 @@ public: } virtual std::unique_ptr - standardAssertions(const char *) override + standardAssertions(const char * name) override { - auto h = getResponseHeaders(); - BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); - BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/atom+xml"); - BOOST_TEST_INFO(this->output.view()); - BOOST_REQUIRE_NE(this->output.view().find("(); - p->parse_stream(this->output); + BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) { + auto h = getResponseHeaders(); + BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); + BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/atom+xml"); + BOOST_REQUIRE_NE(this->output.view().find("parse_stream(this->output); + p->get_document()->write_to_file_formatted(getOutputPath(name, ".xml")); + } return p; } }; -- cgit v1.2.3