Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Targets for Tests and Documentation #26

Merged
merged 10 commits into from
Jan 8, 2025
6 changes: 3 additions & 3 deletions .github/workflows/builNTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
./gradlew
./gradlew clean
./gradlew build
- name: Compile
run: ./gradlew compile
- name: Run
run: |
./gradlew full
./gradlew run
./gradlew transform
- name: Test
run: ./gradlew test
- name: Clean Up
run: ./gradlew reset
133 changes: 128 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@ plugins {
id("application")
id("java-library")
id("idea")
id("jvm-test-suite")
}

group "dev.arg-v.transformer"
version "1.0.0"
// rootProject.name.set("argv-transformer")

repositories {
mavenCentral()
mavenCentral() // Most commonly used reposistory
maven {
url = uri("https://repo.eclipse.org/content/groups/releases/")
}
} // Eclipse specific repo that cannot be found on maven central
swflint marked this conversation as resolved.
Show resolved Hide resolved
}

// set run to run the entire program via driver
application {
mainClass.set("full.Driver")
}

// This enforces java 8 compiance with the code
// also allows for the use of later compilers as long as the code conforms
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

// All External Dependencies from either repo
dependencies {
implementation("org.eclipse.jdt:org.eclipse.jdt.core:3.10.0.v20140604-1726")
implementation("org.apache.commons:commons-csv:1.5")
Expand All @@ -29,13 +44,80 @@ dependencies {
implementation("org.eclipse.text:org.eclipse.text:3.5.101")
implementation("org.yaml:snakeyaml:2.0")
implementation("org.soot-oss:soot:4.6.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testImplementation("net.bytebuddy:byte-buddy:1.12.19")
testImplementation("net.bytebuddy:byte-buddy-agent:1.12.19")
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:4.11.0")
testImplementation("org.objenesis:objenesis:3.3")
testImplementation("org.testng:testng:7.5.1")
}

tasks.compileJava {
sourceSets {
main {
java {
srcDirs("src/java")
}
}
}
}

tasks.processResources {
// yup this is blank
}

tasks.classes {
sourceSets {
main {
java {
srcDirs("build/classes/java")
}
}
}
}

tasks.run {
group = "execution"
}


tasks.compileTestJava {
sourceSets {
test {
java {
srcDirs("test")
}
}
}
}

tasks.processTestResources {
// yup this is blank
}

tasks.testClasses {
sourceSets {
test {
java {
srcDirs("build/classes/test")
}
}
}
}


tasks.test {
testLogging {
events("FAILED")
}
}

tasks.javadoc {
}

// Task that generates a file called my.classpath
// my.classpath is a template file with many necessary parts used by various common IDEs
// This file is not meant to be an end all file, rather a starting point
tasks.register("ide-paths") {
group = "Set-Up"
description = "Generate a file, 'my.classpath'\nFile is a template with class path entries for gradle-managed dependencies"
Expand All @@ -53,8 +135,11 @@ tasks.register("ide-paths") {
val dependencyList = mutableListOf("")
classpathFile.appendText("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
classpathFile.appendText("<classpath>\n")
classpathFile.appendText("\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/\"/>\n")
classpathFile.appendText("\t<classpathentry kind=\"con\" path=\"org.eclipse.buildship.core.gradleclasspathcontainer\"/>\n")
classpathFile.appendText("\t<classpathentry kind=\"src\" path=\"src/java\"/>\n")
classpathFile.appendText("\t<classpathentry kind=\"src\" path=\"src/test\"/>\n")
classpathFile.appendText("\t<classpathentry kind=\"src\" path=\"test\"/>\n")

paths.forEach { path ->
path.get().forEach { file ->
Expand All @@ -70,15 +155,29 @@ tasks.register("ide-paths") {
}
}

// Custom Compile task used to run the individual parts from root
task<JavaCompile>("compile") {
source(fileTree("src/java"))
classpath = configurations.runtimeClasspath.get()
destinationDirectory = file("build/classes/java")
outputs.files(fileTree((destinationDirectory)))
}

// Custom Test Compile task for use with test types other than unit tests
task<JavaCompile>("compile-test") {
dependsOn("compile")
source(fileTree("src/java"), fileTree("src/test"), fileTree("test"))
classpath = configurations.runtimeClasspath.get() + configurations.testRuntimeClasspath.get()
classpath += files("build/classes/java")
destinationDirectory = file("build/classes/test")
outputs.files(fileTree((destinationDirectory)))
}

// Custom task class used for creating tasks for individual parts of the code
open class ExecOperationsTask @Inject constructor(@Internal val execOperations: ExecOperations) : DefaultTask()

// This is currently the same as 'run'
// Does not actually run the full application despite the name, only what is in Driver
tasks.register<ExecOperationsTask>("full") {
group = "execution"
description = "Runs the compiled application"
Expand All @@ -95,6 +194,8 @@ tasks.register<ExecOperationsTask>("full") {
}
}

// Runs only the filter task
// Assumes that necesary folders already exist eg database
tasks.register<ExecOperationsTask>("filter") {
group = "execution"
description = "Runs the filter"
Expand All @@ -111,6 +212,8 @@ tasks.register<ExecOperationsTask>("filter") {
}
}

// Runs only the transform task
// Assumes that necessary folders already exist eg suitablePrgms
tasks.register<ExecOperationsTask>("transform") {
group = "execution"
description = "Runs the transformer"
Expand All @@ -127,6 +230,26 @@ tasks.register<ExecOperationsTask>("transform") {
}
}

tasks.register<ExecOperationsTask>("regression-transformer") {
group = "testing"
description = "Runs regression test for transformer"
dependsOn("compile")
doLast {
execOperations.javaexec {
classpath = files(configurations.runtimeClasspath.get().files.joinToString(File.pathSeparator))
// classpath = files(configurations.testRuntimeClasspath.get().files.joinToString(File.pathSeparator))
classpath += files(File.pathSeparator + file("build/classes/java"))
mainClass.set("transform.Main")
args("test/transformer/regression", "testOutput")
// args("-cp")
standardOutput = System.out
errorOutput = System.err
}
}
}

// Wipes all folders created by the code as well as the build folder
// Use for fresh run of code
tasks.register<Delete>("reset") {
group = "clean"
description = "Resets the program - deletes build, database, suitablePrgms and benchmarks"
Expand Down
4 changes: 2 additions & 2 deletions src/java/download/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void createProjectDatabase() {
/**
* Filter GitHub projects according to the filtering criteria.
*
* @param minLinesOfCode Minimum number of lines of code for projects.
* @param maxLinesOfCode Maximum number of lines of code for projects.
* @param minLoc Minimum number of lines of code for projects.
* @param maxLoc Maximum number of lines of code for projects.
*/
public void filterProjects(int minLoc, int maxLoc) {
JavaProjectFilter filter = new JavaProjectFilter(minLoc, maxLoc, 0);
Expand Down
9 changes: 5 additions & 4 deletions src/java/full/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public class Main {
* @param debugLevel
* @param downloadDir
* @param benchmarkDir
* @param minIfStmt
* @param ifStmt
* @param minExpr
* @param type
* @param type
* @param minExpr
* @param minIfStmt
* @param minParams
* @param target
* @throws IOException
*/
public static void start(String filename, int projectCount, int minLoc, int maxLoc, int debugLevel,
Expand Down
2 changes: 1 addition & 1 deletion src/java/transform/TypeChecking/TypeChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static boolean isVoidType(Type type) {
/**
* Integer array type of desired dimension
* @param type
* @param dem - desired dimensions, >= 1
* @param dim - desired dimensions, >= 1
* @return
*/
public static boolean isIntegerArrayType(Type type, int dim) {
Expand Down
1 change: 0 additions & 1 deletion src/java/transform/visitors/TransformVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public class TransformVisitor extends ASTVisitor {
* @param rewriter
* @param typeTable
* @param typeChecker
* @throws IOException
*/
public TransformVisitor(SymbolTable root, ASTRewrite rewriter, TypeTable typeTable, TypeChecker typeChecker, String target) {
this.root = root;
Expand Down
28 changes: 0 additions & 28 deletions src/tests/expr/AssignmentRhsSub.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/tests/expr/AssignmentRhsSub_T.java

This file was deleted.

38 changes: 0 additions & 38 deletions src/tests/expr/Box.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/tests/expr/ForStmtInfixExprSub.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/tests/expr/ForStmtInfixExprSub_T.java

This file was deleted.

Loading
Loading