Skip to content

Instantly share code, notes, and snippets.

@aravindavk
Last active June 7, 2019 13:03
Show Gist options
  • Save aravindavk/690f212de85a07e56fb8f3e35b8ec058 to your computer and use it in GitHub Desktop.
Save aravindavk/690f212de85a07e56fb8f3e35b8ec058 to your computer and use it in GitHub Desktop.
`./failurelogs.d regression-1.log > failed_logs_1.log` (D language (https://dlang.org/), `dmd` is required to run this script)
#!/usr/bin/rdmd
import std.stdio;
import std.string;
import std.conv;
void main(string[] args)
{
string[] records;
bool inRecord;
bool failedRecord;
string testname;
string[] failedTests;
foreach(line; File(args[1]).byLine)
{
records ~= to!string(line);
if (line == "================================================================================")
{
if (inRecord)
{
inRecord = false;
// Print lines of failed Test
if (failedRecord)
{
if (testname != "")
failedTests ~= testname;
testname = "";
foreach(record; records)
{
writeln(record);
}
}
// Reset and continue processing next record
records = [];
failedRecord = false;
continue;
}
if (!inRecord)
{
inRecord = true;
continue;
}
}
if (line.startsWith("Result: FAIL"))
{
failedRecord = true;
}
if (line.startsWith("/usr/share/glusterfs/tests/") && line.stripRight.endsWith(" .."))
{
testname = to!string(line.replace(" ..", ""));
}
}
stderr.writeln("Failed test files:");
stderr.writeln(failedTests.join("\n"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment