summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-01-16 21:47:16 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-01-16 21:47:16 +0000
commit6b5178583d54313a506ec2d70783504a78fbe4fb (patch)
tree680f86dd13cc48c0e5163467a479ab2aff33a219
parentReference local schema.sql (diff)
downloadgentoobrowse-api-6b5178583d54313a506ec2d70783504a78fbe4fb.tar.bz2
gentoobrowse-api-6b5178583d54313a506ec2d70783504a78fbe4fb.tar.xz
gentoobrowse-api-6b5178583d54313a506ec2d70783504a78fbe4fb.zip
Use libtidy instead of messy shelling out to tidy
-rw-r--r--gentoobrowse-api/unittests/Jamfile.jam2
-rw-r--r--gentoobrowse-api/unittests/testNotifications.cpp15
2 files changed, 11 insertions, 6 deletions
diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam
index 200234f..1ecae8a 100644
--- a/gentoobrowse-api/unittests/Jamfile.jam
+++ b/gentoobrowse-api/unittests/Jamfile.jam
@@ -3,6 +3,7 @@ import testing ;
lib boost_utf : : <name>boost_unit_test_framework ;
lib dbpp-postgresql : : : : <include>/usr/include/dbpp-postgresql ;
lib dl ;
+lib tidy ;
lib dryice : : : : <include>/usr/include/icetray ;
path-constant me : . ;
@@ -108,6 +109,7 @@ run
<dependency>../db/schema.sql
<define>BOOST_TEST_DYN_LINK
<library>testCommon
+ <library>tidy
<implicit-dependency>testCommon
: testNotifications ;
diff --git a/gentoobrowse-api/unittests/testNotifications.cpp b/gentoobrowse-api/unittests/testNotifications.cpp
index 15d62ea..8759e85 100644
--- a/gentoobrowse-api/unittests/testNotifications.cpp
+++ b/gentoobrowse-api/unittests/testNotifications.cpp
@@ -4,6 +4,7 @@
#include "mockDefs.h"
#include <definedDirs.h>
#include <fstream>
+#include <tidy.h>
BOOST_GLOBAL_FIXTURE( Mail );
@@ -21,12 +22,14 @@ save(const std::string & name, Gentoo::EmailPtr e)
std::ofstream text((binDir / (name + ".txt")).string());
text << e->body[0]->payload;
- char buf[BUFSIZ];
- sprintf(buf, "tidy --indent yes --wrap 0 -quiet -output %s/%s.html",
- binDir.c_str(), name.c_str());
- FILE * tidy = popen(buf, "w");
- BOOST_REQUIRE_EQUAL(1, fwrite(e->body[1]->payload.c_str(), e->body[1]->payload.length(), 1, tidy));
- BOOST_REQUIRE_EQUAL(0, pclose(tidy));
+ TidyDoc tdoc = tidyCreate();
+ BOOST_REQUIRE_EQUAL(1, tidyOptSetBool(tdoc, TidyIndentContent, yes));
+ BOOST_REQUIRE_EQUAL(1, tidyOptSetInt(tdoc, TidyWrapLen, 0));
+ BOOST_REQUIRE_EQUAL(0, tidyParseString(tdoc, e->body[1]->payload.c_str()));
+ 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);
}
void