-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from jayhorn/devel
First mostly sound version for simple Java
- Loading branch information
Showing
433 changed files
with
28,568 additions
and
5,350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,12 @@ bin/ | |
cov-int | ||
build/ | ||
**/*.log | ||
*.iml | ||
.idea/ | ||
.idea/gradle.xml | ||
.idea/libraries | ||
*.ipr | ||
*.iws | ||
/out/ | ||
*.dot | ||
.shelf/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
|
||
language: java | ||
|
||
env: | ||
global: | ||
- TMPDIR=/tmp | ||
|
||
jdk: | ||
- oraclejdk8 | ||
- oraclejdk7 | ||
|
||
before_install: | ||
- "export LD_LIBRARY_PATH=jayhorn/native_lib:$LD_LIBRARY_PATH" | ||
|
||
script: ./travis.sh | ||
- pwd | ||
- export LD_LIBRARY_PATH=$(pwd)/jayhorn/native_lib | ||
|
||
script: | ||
- gradle check | ||
- 'if [[ $TRAVIS_PULL_REQUEST != "false" ]]; then gradle integration_test ; fi' | ||
script: | ||
- gradle check -i | ||
|
||
after_success: | ||
- gradle jacocoTestReport coveralls | ||
- gradle jacocoRootReport coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
<img src="http://jayhorn.github.io/jayhorn/images/rhino.png" height=100> Java and Horn clauses | ||
|
||
#### Status of Master | ||
|
||
[![Build Status](https://travis-ci.org/jayhorn/jayhorn.svg?branch=master)](https://travis-ci.org/jayhorn/jayhorn) | ||
[![Coverage Status](https://coveralls.io/repos/jayhorn/jayhorn/badge.svg?branch=master&service=github)](https://coveralls.io/github/jayhorn/jayhorn?branch=master) | ||
[![Coverity Scan](https://scan.coverity.com/projects/6013/badge.svg)](https://scan.coverity.com/projects/6013) | ||
|
||
#### Status of Devel | ||
|
||
[![Build Status](https://travis-ci.org/jayhorn/jayhorn.svg?branch=devel)](https://travis-ci.org/jayhorn/jayhorn) | ||
[![Coverage Status](https://coveralls.io/repos/jayhorn/jayhorn/badge.svg?branch=devel&service=github)](https://coveralls.io/github/jayhorn/jayhorn?branch=devel) | ||
|
||
|
||
Work in progress. Nothing to see here yet. | ||
|
||
If you break the build on devel, you have to buy Martin a beer. If you break the devel twice, terrible things will happen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
// In this section you declare the dependencies for your production and test code | ||
dependencies { | ||
compile 'com.google.guava:guava:18.0' | ||
compile fileTree(dir: 'lib', include: '*.jar') | ||
testCompile 'junit:junit:4.12' | ||
compile project(':soottocfg') | ||
} | ||
|
||
//exclude integration tests when running regular check | ||
test { | ||
include '**/BenchtopTest.java' | ||
include '**/ClasspathTest.java' | ||
exclude '**/SystemTest00.java' | ||
exclude '**/Tests.java' | ||
exclude '**/SystemTest01.java' | ||
exclude '**/SystemTest02.java' | ||
} | ||
|
||
task integration_test(type: Test) { | ||
group 'Verification' | ||
description 'Run integration tests.' | ||
|
||
include '**/BenchtopTest.java' | ||
include '**/ClasspathTest.java' | ||
include '**/SystemTest00.java' | ||
include '**/SystemTest01.java' | ||
include '**/SystemTest02.java' | ||
include '**/Tests.java' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE module PUBLIC | ||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" | ||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> | ||
|
||
<!-- | ||
Checkstyle configuration that checks the Google coding conventions from: | ||
- Google Java Style | ||
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html | ||
Checkstyle is very configurable. Be sure to read the documentation at | ||
http://checkstyle.sf.net (or in your downloaded distribution). | ||
Most Checks are configurable, be sure to consult the documentation. | ||
To completely disable a check, just comment it out or delete it from the file. | ||
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov. | ||
--> | ||
|
||
<module name = "Checker"> | ||
<property name="charset" value="UTF-8"/> | ||
|
||
<property name="severity" value="warning"/> | ||
|
||
|
||
<module name="TreeWalker"> | ||
<module name="OuterTypeFilename"/> | ||
<module name="IllegalTokenText"> | ||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/> | ||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/> | ||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/> | ||
</module> | ||
|
||
<module name="JavadocMethod"> | ||
<property name="scope" value="public"/> | ||
<property name="allowUndeclaredRTE" value="true"/> | ||
</module> | ||
|
||
</module> | ||
</module> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package benchtop; | ||
|
||
import java.io.PrintStream; | ||
|
||
/** | ||
* @author Huascar Sanchez | ||
*/ | ||
public class BasicExecutionLog implements ExecutionLog { | ||
private PrintStream out; | ||
|
||
/** | ||
* Basic ExecutionLog object. | ||
* @param out the current print stream | ||
*/ | ||
public BasicExecutionLog(PrintStream out){ | ||
this.out = out; | ||
} | ||
|
||
@Override public void info(String s) { | ||
out.println("INFO: " + s); | ||
} | ||
|
||
@Override public void error(String s, Throwable throwable) { | ||
out.println("ERROR: " + s); | ||
throwable.printStackTrace(System.out); | ||
} | ||
|
||
@Override public void warn(String s) { | ||
out.println("WARN: " + s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
package benchtop; | ||
|
||
import benchtop.spi.Configuration; | ||
import benchtop.spi.JavaConfiguration; | ||
import benchtop.spi.JavacConfiguration; | ||
import benchtop.spi.RandoopConfiguration; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.ImmutableList; | ||
|
||
import java.io.File; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* A facade for running commands. These commands are configured via classes that implement | ||
* the {@link Configuration} interface. | ||
* | ||
* @author Huascar Sanchez | ||
*/ | ||
public class Benchtop { | ||
/** | ||
* Benchtop's private constructor. | ||
*/ | ||
private Benchtop(){ | ||
throw new Error("Cannot be instantiated!"); | ||
} | ||
|
||
/** | ||
* Creates a command based on a given configuration. | ||
* | ||
* @param configuration The configuration of a command. | ||
* @return a new and configured command. | ||
*/ | ||
public static Command createCommand(Configuration configuration){ | ||
final Command command = createCommand(configuration, newBasicExecutionLog()); | ||
System.out.println(command); | ||
return command; | ||
} | ||
|
||
/** | ||
* Creates a command based on a given configuration and some execution log. | ||
* | ||
* @param configuration The configuration of a command. | ||
* @param executionLog A log that monitors command's execution. | ||
* @return a new and configured command. | ||
*/ | ||
public static Command createCommand(Configuration configuration, ExecutionLog executionLog){ | ||
final Configuration nonNullConfiguration = Preconditions.checkNotNull(configuration); | ||
final Command.Builder builder = Command.of(Preconditions.checkNotNull(executionLog)) | ||
.console(System.out); | ||
nonNullConfiguration.configure(builder); | ||
|
||
return builder.build(); | ||
} | ||
|
||
/** | ||
* Consumes an non-empty array of bundles. See {@link ExecutionBundle} to understand | ||
* how bundles are constructed. | ||
* | ||
* @param bundles an array of bundle objects. | ||
* @return Benchtop's output monitor. | ||
* @throws BundleCreationError unexpected errors have occurred. | ||
*/ | ||
public static Result consumes(ExecutionBundle... bundles) throws BundleCreationError { | ||
final DefaultEnvironment host = new DefaultEnvironment(); | ||
Result monitor = null; | ||
for(ExecutionBundle each : bundles){ | ||
host.install(each); | ||
|
||
if(monitor == null){ monitor = host.getMonitor(); } else { | ||
monitor = monitor.combines(host.getMonitor()); | ||
} | ||
|
||
} | ||
|
||
host.throwCachedErrors(); | ||
|
||
return monitor; | ||
} | ||
|
||
/** | ||
* Executes a configured command. | ||
* | ||
* @param command the command to run | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> run(Command command){ | ||
final List<String> output = Preconditions.checkNotNull(command).execute(); | ||
|
||
//noinspection Convert2streamapi | ||
for(String each : output){ // unchecked warning | ||
System.out.println(each); | ||
} | ||
|
||
return output; | ||
} | ||
|
||
|
||
/** | ||
* Creates a Javac command; ready to be executed. The classpath object is made of the project's | ||
* content; including classes, managed dependencies, and other dependencies under the | ||
* /lib directory. If one needs to update this classpath or have more control of what it is in | ||
* that classpath, then use the {@link Benchtop#java(Classpath, String, String...)} method | ||
* instead. | ||
* | ||
* @param destination the directory where compiled classes will be placed. | ||
* @param sourceFiles the array of source files to compile. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> javac(File destination, File... sourceFiles){ | ||
return javac(Classpath.environmentClasspath() /*classpath is resolved automatically*/, destination, sourceFiles); | ||
} | ||
|
||
/** | ||
* Creates a Javac command; ready to be executed. | ||
* | ||
* @param classpath the required classpath to compile source files. | ||
* @param destination the directory where compiled classes will be placed. | ||
* @param sourceFiles the array of source files to compile. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> javac(Classpath classpath, File destination, File... sourceFiles){ | ||
return javac(classpath, destination, ImmutableList.copyOf(sourceFiles)); | ||
} | ||
|
||
|
||
/** | ||
* Creates a Javac command; ready to be executed. | ||
* | ||
* @param classpath the required classpath to compile source files. | ||
* @param destination the directory where compiled classes will be placed. | ||
* @param sourceFiles the array of source files to compile. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> javac(Classpath classpath, File destination, Collection<File> sourceFiles){ | ||
return run(createCommand( | ||
JavacConfiguration.newJavacConfiguration( | ||
classpath, | ||
destination, | ||
sourceFiles | ||
) | ||
)); | ||
} | ||
|
||
/** | ||
* Creates a Junit command; ready to be executed. | ||
* | ||
* @param classpath the required classpath to run JUnit tests | ||
* @param args the array of parameters needed by JUnit to run. e.g., test class. | ||
* @return the command's output on terminal. | ||
*/ | ||
public static List<String> junit(Classpath classpath, String... args){ | ||
return java(classpath, "org.junit.runner.JUnitCore", args); | ||
} | ||
|
||
/** | ||
* Creates a Java command; ready to be executed. | ||
* | ||
* @param classpath the required classpath to run Java program | ||
* @param mainClass the main class or Java program | ||
* @param args the args taken by the main class. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> java(Classpath classpath, String mainClass, String... args){ | ||
return run(createCommand( | ||
JavaConfiguration.newJavaConfiguration(classpath, mainClass, args) | ||
)); | ||
} | ||
|
||
/** | ||
* Executes a Randoop command. | ||
* | ||
* @param classList list of classes needed by Randoop to generate tests. | ||
*/ | ||
public static List<String> randoop(String... classList){ | ||
return randoop(Classpath.environmentClasspath(), classList); | ||
} | ||
|
||
/** | ||
* Executes a Randoop command. | ||
* | ||
* @param classpath required classpath by Randoop | ||
* @param classList list of classes needed by Randoop to generate tests. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> randoop(Classpath classpath, String... classList){ | ||
return randoop(classpath, RandoopConfiguration.randoopOutput(), classList); | ||
} | ||
|
||
/** | ||
* Executes a Randoop command. | ||
* | ||
* @param classpath required classpath by Randoop | ||
* @param destination the location where these Randoop tests will be placed | ||
* @param classList list of classes needed by Randoop to generate tests. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> randoop(Classpath classpath, File destination, String... classList){ | ||
return randoop(classpath, destination, 60, classList); | ||
} | ||
|
||
/** | ||
* Creates a Randoop command. | ||
* | ||
* @param classpath required classpath by Randoop | ||
* @param destination the location where these Randoop tests will be placed | ||
* @param timeLimit Randoop's time limit | ||
* @param classList list of classes needed by Randoop to generate tests. | ||
* @return the command's output on terminal | ||
*/ | ||
public static List<String> randoop(Classpath classpath, File destination, | ||
int timeLimit, String... classList){ | ||
return run(createCommand( | ||
RandoopConfiguration.defaultConfiguration(classpath, destination, timeLimit, classList) | ||
)); | ||
} | ||
|
||
|
||
private static ExecutionLog newBasicExecutionLog(){ | ||
return new BasicExecutionLog(System.out); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.