Skip to content

Commit 0452c03

Browse files
Tests print diffs on error, so CI is more informative.
1 parent aa9b4c2 commit 0452c03

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

source/test/TestMain.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <llvm/Support/CommandLine.h>
2020
#include <llvm/Support/FileSystem.h>
2121
#include <llvm/Support/Path.h>
22+
#include <llvm/Support/Program.h>
2223
#include <llvm/Support/Signals.h>
2324
#include <llvm/Support/ThreadPool.h>
2425
#include <atomic>
@@ -271,15 +272,27 @@ handleFile(
271272
if(options_.badOption.getValue())
272273
{
273274
// Write the .bad.xml file
274-
path::replace_extension(outputPath, "bad.xml");
275-
std::error_code ec;
276-
llvm::raw_fd_ostream os(outputPath, ec, llvm::sys::fs::OF_None);
277-
if(ec)
275+
auto bad = outputPath;
276+
path::replace_extension(bad, "bad.xml");
278277
{
279-
results_.numberOfErrors++;
280-
return makeError("raw_fd_ostream returned ", ec);
278+
std::error_code ec;
279+
llvm::raw_fd_ostream os(bad, ec, llvm::sys::fs::OF_None);
280+
if (ec) {
281+
results_.numberOfErrors++;
282+
return makeError("raw_fd_ostream returned ", ec);
283+
}
284+
os << generatedXml;
285+
}
286+
287+
auto diff = llvm::sys::findProgramByName("diff");
288+
289+
if (!diff.getError())
290+
{
291+
path::replace_extension(bad, "xml");
292+
std::array<llvm::StringRef, 5u> args {
293+
diff.get(), "-u", "--color", bad, outputPath };
294+
llvm::sys::ExecuteAndWait(diff.get(), args);
281295
}
282-
os << generatedXml;
283296

284297
// Fix the path for the code that follows
285298
outputPath.pop_back_n(8);

0 commit comments

Comments
 (0)