Skip to content

Commit e7dd3c9

Browse files
committed
check test xml
1 parent 6f5e434 commit e7dd3c9

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

source/lib/XML.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,7 @@ renderCodeAsXML(
570570
Corpus corpus;
571571
if(llvm::Error err = buildIndex(cfg, corpus))
572572
return ! err;
573-
XMLGenerator(cfg).render(xml, corpus, cfg);
574-
575-
return true;
573+
return XMLGenerator(cfg).render(xml, corpus, cfg);
576574
}
577575

578576
//------------------------------------------------

source/tests/TestMain.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Mapper.h"
1313
#include "Representation.h"
1414
#include <mrdox/Config.hpp>
15+
#include <mrdox/XML.hpp>
1516
#include <clang/tooling/Tooling.h>
1617
#include <llvm/ADT/StringRef.h>
1718
#include <llvm/Support/Signals.h>
@@ -58,6 +59,7 @@ do_main(int argc, const char** argv)
5859
return EXIT_FAILURE;
5960
}
6061

62+
std::string xml;
6163
for(int i = 1; i < argc; ++i)
6264
{
6365
std::error_code ec;
@@ -128,17 +130,12 @@ do_main(int argc, const char** argv)
128130
}
129131
expectedXml = xmlResult->get()->getBuffer();
130132

131-
std::unique_ptr<ASTUnit> astUnit =
132-
clang::tooling::buildASTFromCodeWithArgs(cppCode, {});
133-
MapASTVisitor visitor(cfg);
134-
visitor.HandleTranslationUnit(astUnit->getASTContext());
135-
Corpus corpus;
136-
if(llvm::Error err = buildIndex(cfg, corpus))
137-
{
138-
llvm::errs() <<
139-
toString(std::move(err)) << "\n";
133+
if(! renderCodeAsXML(xml, cppCode, cfg))
140134
return EXIT_FAILURE;
141-
}
135+
136+
if(xml != expectedXml)
137+
llvm::errs() <<
138+
"Failed: \"" << xmlPath << "\"\n";
142139
}
143140

144141
return EXIT_SUCCESS;

testfiles/1.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<ns n="">
2+
<fn n="f1" r="void" a="3">
3+
<tp n="class T"/>
4+
</fn>
5+
<fn n="f2" r="void" a="3">
6+
<tp n="typename U"/>
7+
</fn>
8+
<fn n="f3" r="void" a="3">
9+
<tp n="int N"/>
10+
</fn>
11+
</ns>

0 commit comments

Comments
 (0)