forked from wcygan/java-callgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvexIT.java
More file actions
133 lines (113 loc) · 5.05 KB
/
Copy pathConvexIT.java
File metadata and controls
133 lines (113 loc) · 5.05 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package inttest;
import gr.gousiosg.javacg.stat.JCallGraph;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.junit.Assert.assertTrue;
public class ConvexIT {
private static final Logger LOGGER = LoggerFactory.getLogger(ConvexIT.class);
private final String jarBaseOutput = Paths.get("artifacts", "output", "convex", "convex-core").toString();
private final Path convexJar = Paths.get(System.getProperty("user.dir"),jarBaseOutput, "convex-core-0.7.1.jar");
private final Path convexDependencyJar = Paths.get(System.getProperty("user.dir"),jarBaseOutput, "convex-core-0.7.1-jar-with-dependencies.jar");
private final Path convexTestJar = Paths.get(System.getProperty("user.dir"),jarBaseOutput, "convex-core-0.7.1-tests.jar");
private final Path convexGraph = Paths.get(System.getProperty("user.dir"),"convex-core_graph");
private final Path primitiveRoundTrip = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#primitiveRoundTrip.dot");
private final Path primitiveRoundTripReachability = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#primitiveRoundTrip-reachability.dot");
private final Path dataRoundTripFormat = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#dataRoundTrip.dot");
private final Path dataRoundTripReachability = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#dataRoundTrip-reachability.dot");
private final Path messageRoundTrip = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#messageRoundTrip.dot");
private final Path messageRoundTripReachability = Paths.get(System.getProperty("user.dir"),"output","GenTestFormat#messageRoundTrip-reachability.dot");
@Before
public void setUp(){
String outputDirectoryPath = System.getProperty("user.dir") + "/output/convex/";
File outputDir = new File(outputDirectoryPath);
if(!outputDir.exists())
outputDir.mkdir();
}
@Test
public void testA(){
String [] args = {"git", "-c", "convex"};
JCallGraph.main(args);
}
@Test
public void testB(){
String [] args = {"build", "-j", convexJar.toString(),
"-t", convexTestJar.toString(), "-o", "convex-core_graph"};
JCallGraph.main(args);
}
@Test
public void testC(){
String [] args = {"test", "-c", "convex", "-f", "convex-core_graph"};
JCallGraph.main(args);
}
@Test
public void testD(){
// Git Stage
LOGGER.info("Starting Convex Git Verification");
assertTrue(Files.exists(convexJar));
assertTrue(Files.exists(convexDependencyJar));
assertTrue(Files.exists(convexTestJar));
// Build Stage
LOGGER.info("Starting Convex Build Verification");
assertTrue(Files.exists(convexGraph));
// Test Stage
LOGGER.info("Starting Convex Test Verfication");
assertTrue(Files.exists(primitiveRoundTrip));
assertTrue(Files.exists(primitiveRoundTripReachability));
assertTrue(Files.exists(dataRoundTripFormat));
assertTrue(Files.exists(dataRoundTripReachability));
assertTrue(Files.exists(messageRoundTrip));
assertTrue(Files.exists(messageRoundTripReachability));
}
//
// Create png files for comparison
@Test
public void testE() throws IOException, InterruptedException {
String cmd = "./buildpng.sh";
String project = "convex";
ProcessBuilder pb = new ProcessBuilder(cmd, project);
Process process = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while((line = br.readLine()) != null)
LOGGER.info(line);
process.waitFor();
}
//
// Test difference through diffimg
@Test
public void testF() throws IOException, InterruptedException {
String cmd = "./testdiff.sh";
String project = "convex";
ProcessBuilder pb = new ProcessBuilder(cmd, project);
Process process = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while((line = br.readLine()) != null) {
LOGGER.info(line);
if(line.contains("%")) {
String[] values = line.split(" : ");
Double percentDifference = Double.parseDouble(values[1].replace("%", ""));
Assert.assertTrue(percentDifference < 0.05);
}
}
process.waitFor();
}
@After
public void cleanUp() throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder();
pb.command("sh", "rm", "output/*.dot");
Process process = pb.start();
process.waitFor();
}
}