-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.java
71 lines (59 loc) · 1.92 KB
/
Parser.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.io.*;
import java.util.regex.*;
public class Parser {
public static void main(String[] args) {
Pattern pass = Pattern.compile("OK");
Pattern fail = Pattern.compile("Failures");
Pattern err = Pattern.compile("(?d)[)] test");
Pattern assrt = Pattern.compile("at account.tests.Test(.*).test(.*)[(]Test(.*).java:(.*)[)]");
String errors = "";
int passCount = 0;
int failCount = 0;
int testsRun = Integer.parseInt(args[1]);
try {
File file = new File(args[0]);
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while((line = br.readLine()) != null) {
Matcher m0 = pass.matcher(line);
Matcher m1 = fail.matcher(line);
Matcher m2 = err.matcher(line);
Matcher m3 = assrt.matcher(line);
while(m0.find()) {
passCount++;
}
while(m1.find()) {
failCount++;
}
while(m2.find()) {
errors += "\n" + (failCount+1) + ")" + br.readLine();
}
while(m3.find()) {
//open test file
File testFile = new File("account/tests/Test"+m3.group(1)+".java");
BufferedReader testBR = new BufferedReader(new FileReader(testFile));
//go to the line where the error is
for(int i = 0; i < Integer.parseInt(m3.group(4)); i ++) {
line = testBR.readLine();
}
//get rid of extra spaces
line = line.replaceAll(" ", "");
//print line to terminal
errors += " @ Test"+m3.group(1)+".java:"+m3.group(4)+"\n " + line + "\n";
}
}
double percent = ((double) passCount/(double) testsRun)*100;
System.out.println("Tests Run: " + testsRun);
System.out.println("Passed: " + passCount);
System.out.println("Failed: " + failCount);
System.out.println("Deadlocked: " + (testsRun - (failCount+passCount)));
// if(failCount > 0) {
// System.out.println("=====ERRORS=====");
// System.out.println(errors);
// }
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}