Skip to content

Commit c5a76ac

Browse files
committed
Auto stash before merge of "conformance-lite" and "origin/v2"
feat: refactored to simplify stage implementation removed old test resources removed more resources
1 parent d3e96ed commit c5a76ac

File tree

496 files changed

+1531
-29485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

496 files changed

+1531
-29485
lines changed

build.gradle

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
plugins {
2-
id 'java'
3-
id 'application'
4-
id "org.sonarqube" version "6.3.1.5724"
5-
id "com.github.ben-manes.versions" version "0.53.0"
2+
id("java")
3+
id("application")
4+
id("org.sonarqube") version "6.3.1.5724"
5+
id("com.github.ben-manes.versions") version "0.53.0"
6+
id("com.diffplug.spotless") version "8.0.0"
67
}
78

89
java {
@@ -42,6 +43,7 @@ dependencies {
4243
implementation 'com.github.therapi:therapi-runtime-javadoc:0.15.0'
4344
implementation 'com.github.therapi:therapi-runtime-javadoc-scribe:0.15.0'
4445
implementation 'info.picocli:picocli:4.7.7'
46+
implementation 'org.reflections:reflections:0.9.12'
4547
implementation 'com.google.code.gson:gson:2.13.2'
4648
implementation 'com.github.gestalt-config:gestalt-core:0.36.0'
4749
implementation 'com.github.gestalt-config:gestalt-yaml:0.36.0'
@@ -79,3 +81,21 @@ tasks.register('fatJar', Jar) {
7981
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
8082
with jar
8183
}
84+
85+
spotless {
86+
format 'misc', {
87+
// define the files to apply `misc` to
88+
target '*.gradle', '.gitattributes', '.gitignore'
89+
90+
// Steps
91+
trimTrailingWhitespace()
92+
leadingTabsToSpaces()
93+
endWithNewline()
94+
}
95+
java {
96+
removeUnusedImports()
97+
prettier(['prettier': '3.0.3', 'prettier-plugin-java': '2.3.0'])
98+
.nodeExecutable("/home/millie/.nvm/versions/node/v25.1.0/bin/node")
99+
.config(['parser': 'java', 'tabWidth': 4, 'plugins': ['prettier-plugin-java']])
100+
}
101+
}

src/main/java/chalkbox/ChalkBox.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
import picocli.CommandLine;
55
import picocli.CommandLine.Command;
66

7-
@Command(name = "chalkbox", version="2.0", mixinStandardHelpOptions = true, subcommands = { Run.class })
7+
@Command(
8+
name = "chalkbox",
9+
version = "2.0",
10+
mixinStandardHelpOptions = true,
11+
subcommands = { Run.class }
12+
)
813
public class ChalkBox {
914

1015
public static void main(String[] args) {
1116
int exitCode = new CommandLine(new ChalkBox()).execute(args);
1217
System.exit(exitCode);
1318
}
14-
}
19+
}

src/main/java/chalkbox/api/common/Execution.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Utility class for executing processes
1616
*/
1717
public class Execution {
18+
1819
/**
1920
* Execute a process in a working directory
2021
*
@@ -24,8 +25,11 @@ public class Execution {
2425
* @return the executed process
2526
* @throws IOException if an issue occurs executing the process
2627
*/
27-
public static ProcessExecution runProcess(File working, int timeout, String... args)
28-
throws IOException, TimeoutException {
28+
public static ProcessExecution runProcess(
29+
File working,
30+
int timeout,
31+
String... args
32+
) throws IOException, TimeoutException {
2933
ProcessBuilder builder = new ProcessBuilder(args);
3034
builder.directory(working);
3135

@@ -41,9 +45,11 @@ public static ProcessExecution runProcess(File working, int timeout, String... a
4145
* @return the executed process
4246
* @throws IOException if an issue occurs executing the process
4347
*/
44-
public static ProcessExecution runProcess(Map<String, String> environment,
45-
int timeout, String... args)
46-
throws IOException, TimeoutException {
48+
public static ProcessExecution runProcess(
49+
Map<String, String> environment,
50+
int timeout,
51+
String... args
52+
) throws IOException, TimeoutException {
4753
ProcessBuilder builder = new ProcessBuilder(args);
4854
builder.environment().putAll(environment);
4955

@@ -60,9 +66,12 @@ public static ProcessExecution runProcess(Map<String, String> environment,
6066
* @return the executed process
6167
* @throws IOException if an issue occurs executing the process
6268
*/
63-
public static ProcessExecution runProcess(File working, Map<String, String> environment,
64-
int timeout, String... args)
65-
throws IOException, TimeoutException {
69+
public static ProcessExecution runProcess(
70+
File working,
71+
Map<String, String> environment,
72+
int timeout,
73+
String... args
74+
) throws IOException, TimeoutException {
6675
ProcessBuilder builder = new ProcessBuilder(args);
6776
builder.directory(working);
6877
builder.environment().putAll(environment);
@@ -74,7 +83,7 @@ public static ProcessExecution runProcess(File working, Map<String, String> envi
7483
* Helper to execute a process.
7584
*/
7685
private static ProcessExecution run(ProcessBuilder builder, int timeout)
77-
throws IOException, TimeoutException {
86+
throws IOException, TimeoutException {
7887
Process process;
7988
ProcessExecution execution = new ProcessExecution();
8089
try {
@@ -86,7 +95,9 @@ private static ProcessExecution run(ProcessBuilder builder, int timeout)
8695
@Override
8796
public void run() {
8897
try {
89-
InputStreamReader in = new InputStreamReader(process.getInputStream());
98+
InputStreamReader in = new InputStreamReader(
99+
process.getInputStream()
100+
);
90101
int bite;
91102
while ((bite = in.read()) != -1) {
92103
output.write(bite);
@@ -100,7 +111,9 @@ public void run() {
100111
@Override
101112
public void run() {
102113
try {
103-
InputStreamReader in = new InputStreamReader(process.getErrorStream());
114+
InputStreamReader in = new InputStreamReader(
115+
process.getErrorStream()
116+
);
104117
int bite;
105118
while ((bite = in.read()) != -1) {
106119
error.write(bite);
@@ -141,7 +154,7 @@ public void run() {
141154
* @throws IOException if an issue occurs executing the process
142155
*/
143156
public static ProcessExecution runProcess(int timeout, String... args)
144-
throws IOException, TimeoutException {
157+
throws IOException, TimeoutException {
145158
return runProcess(new File("."), timeout, args);
146159
}
147160

src/main/java/chalkbox/api/common/ProcessExecution.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package chalkbox.api.common;
22

33
public class ProcessExecution {
4+
45
private String output;
56
private String error;
67

src/main/java/chalkbox/api/common/java/Compiler.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package chalkbox.api.common.java;
22

3-
import javax.tools.JavaCompiler;
4-
import javax.tools.JavaFileObject;
5-
import javax.tools.ToolProvider;
63
import java.io.File;
74
import java.io.StringWriter;
85
import java.util.ArrayList;
96
import java.util.List;
7+
import javax.tools.JavaCompiler;
8+
import javax.tools.JavaFileObject;
9+
import javax.tools.ToolProvider;
1010

1111
/**
1212
* Utility class for compiling Java source code.
@@ -25,9 +25,12 @@ public class Compiler {
2525
*
2626
* @return true iff the files were compiled successfully.
2727
*/
28-
public static boolean compile(Iterable<? extends JavaFileObject> files,
29-
String classPath, String outputPath,
30-
StringWriter output) {
28+
public static boolean compile(
29+
Iterable<? extends JavaFileObject> files,
30+
String classPath,
31+
String outputPath,
32+
StringWriter output
33+
) {
3134
/* Try to create the output path directory */
3235
File outFile = new File(outputPath);
3336
if (!outFile.exists()) {
@@ -39,7 +42,9 @@ public static boolean compile(Iterable<? extends JavaFileObject> files,
3942

4043
List<String> options = new ArrayList<>();
4144
options.add("-processor");
42-
options.add("com.github.therapi.runtimejavadoc.scribe.JavadocAnnotationProcessor");
45+
options.add(
46+
"com.github.therapi.runtimejavadoc.scribe.JavadocAnnotationProcessor"
47+
);
4348
options.add("-cp");
4449
options.add(classPath);
4550
options.add("-d");
@@ -58,14 +63,17 @@ public static boolean compile(Iterable<? extends JavaFileObject> files,
5863
*
5964
* @return true iff the files were compiled successfully.
6065
*/
61-
public static boolean compile(Iterable<? extends JavaFileObject> files,
62-
StringWriter output, List<String> options) {
66+
public static boolean compile(
67+
Iterable<? extends JavaFileObject> files,
68+
StringWriter output,
69+
List<String> options
70+
) {
6371
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
6472

6573
boolean success;
6674
try {
67-
success = compiler.getTask(output, null,
68-
null, options, null, files).call();
75+
success =
76+
compiler.getTask(output, null, null, options, null, files).call();
6977
} catch (IllegalStateException e) {
7078
output.write("Empty submission");
7179
return false;

src/main/java/chalkbox/api/common/java/JUnitIndividualResult.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22

33
import chalkbox.stages.Visibility;
44

5-
public record JUnitIndividualResult(int passes, int fails, int total, String output, String outputFormat, String name, int weight, double classWeight, Visibility visibility) { }
5+
public record JUnitIndividualResult(
6+
int passes,
7+
int fails,
8+
int total,
9+
String output,
10+
String outputFormat,
11+
String name,
12+
int weight,
13+
double classWeight,
14+
Visibility visibility
15+
) {}

src/main/java/chalkbox/api/common/java/JUnitListener.java

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package chalkbox.api.common.java;
22

33
import chalkbox.stages.Visibility;
4+
import java.lang.reflect.Field;
5+
import java.util.ArrayList;
6+
import java.util.List;
47
import org.junit.Test;
58
import org.junit.runner.Description;
69
import org.junit.runner.notification.Failure;
710
import org.junit.runner.notification.RunListener;
811

9-
import java.lang.reflect.Field;
10-
import java.util.ArrayList;
11-
import java.util.List;
12-
1312
public class JUnitListener extends RunListener {
13+
1414
private static class TestResult {
15+
1516
private final String testName;
1617
private boolean visible = false;
1718
private boolean passed = true;
@@ -38,9 +39,12 @@ public JUnitListener() {
3839
public void testStarted(Description description) throws Exception {
3940
super.testStarted(description);
4041

41-
this.currentResult = new TestResult(
42-
description.getTestClass().getSimpleName()
43-
+ "." + description.getMethodName());
42+
this.currentResult =
43+
new TestResult(
44+
description.getTestClass().getSimpleName() +
45+
"." +
46+
description.getMethodName()
47+
);
4448

4549
/* Results of this test should be immediately visible */
4650
// TODO create a library containing a custom annotation for this
@@ -67,15 +71,17 @@ public void testStarted(Description description) throws Exception {
6771
* A large number of milliseconds should be used for the timeout, so that the actual
6872
* timeout is not likely to be reached (since global timeout should be used instead).
6973
*/
70-
testWeighting = Math.max(1, (int) (testAnnotation.timeout() % 10));
74+
testWeighting =
75+
Math.max(1, (int) (testAnnotation.timeout() % 10));
7176
}
7277
this.currentResult.weighting = testWeighting;
7378
}
7479

7580
double classWeighting = 1.0;
7681

7782
if (hasField(description.getTestClass().getFields(), "testWeight")) {
78-
classWeighting = description.getTestClass().getField("testWeight").getDouble(null);
83+
classWeighting =
84+
description.getTestClass().getField("testWeight").getDouble(null);
7985
}
8086

8187
this.currentResult.classWeighting = classWeighting;
@@ -107,42 +113,45 @@ public void testFailure(Failure failure) throws Exception {
107113
String failureString = failure.toString();
108114
if (failureString.equals(failure.getTestHeader() + ": null")) {
109115
failureString =
110-
failureString.substring(0, failureString.length() - 4);
111-
failureString += "No message given, refer to stack trace.";
116+
failureString.substring(0, failureString.length() - 4);
117+
failureString += "No message given, refer to stack trace.";
112118
}
113-
119+
114120
if (this.currentResult != null) {
115121
this.output.append(failureString);
116122
this.output.append("\n");
117-
this.currentResult.output = failureString + "\n\n```text\n"
118-
+ failure.getTrace().replaceAll("\r\n", "\n") + "```";
123+
this.currentResult.output =
124+
failureString +
125+
"\n\n```text\n" +
126+
failure.getTrace().replaceAll("\r\n", "\n") +
127+
"```";
119128
this.currentResult.passed = false;
120129
}
121130
this.numFailed++;
122131
}
123132

124133
public JUnitResult getResultsForClass() {
125134
return new JUnitResult(
126-
this.results.size() - this.numFailed,
127-
this.numFailed,
128-
this.results.size(),
129-
this.output.toString()
135+
this.results.size() - this.numFailed,
136+
this.numFailed,
137+
this.results.size(),
138+
this.output.toString()
130139
);
131140
}
132141

133142
public List<JUnitIndividualResult> getIndividualResults() {
134143
var results = new ArrayList<JUnitIndividualResult>();
135144
for (TestResult result : this.results) {
136145
var data = new JUnitIndividualResult(
137-
result.passed ? 1 : 0,
138-
result.passed ? 0 : 1,
139-
1,
140-
result.output,
141-
"md",
142-
result.testName,
143-
result.weighting,
144-
result.classWeighting,
145-
result.visible ? Visibility.VISIBLE : Visibility.AFTER_PUBLISHED
146+
result.passed ? 1 : 0,
147+
result.passed ? 0 : 1,
148+
1,
149+
result.output,
150+
"md",
151+
result.testName,
152+
result.weighting,
153+
result.classWeighting,
154+
result.visible ? Visibility.VISIBLE : Visibility.AFTER_PUBLISHED
146155
);
147156
results.add(data);
148157
}

0 commit comments

Comments
 (0)