23
23
import java .util .ArrayList ;
24
24
import java .util .Comparator ;
25
25
import java .util .HashSet ;
26
+ import java .util .List ;
26
27
import java .util .Set ;
27
28
import java .util .function .Consumer ;
28
29
import java .util .stream .Collectors ;
@@ -42,6 +43,7 @@ public class TestSplit {
42
43
private final @ NotNull String glob ;
43
44
private final @ Nullable String excludeGlob ;
44
45
private final @ Nullable String junitGlob ;
46
+ private final @ NotNull FormatOption format ;
45
47
private final @ NotNull Path workingDirectory ;
46
48
private final boolean debug ;
47
49
private final @ NotNull Consumer <Integer > exitCodeConsumer ;
@@ -52,6 +54,7 @@ public TestSplit(
52
54
final @ NotNull String glob ,
53
55
final @ Nullable String excludeGlob ,
54
56
final @ Nullable String junitGlob ,
57
+ final @ NotNull FormatOption format ,
55
58
final @ NotNull Path workingDirectory ,
56
59
final boolean debug ,
57
60
final @ NotNull Consumer <Integer > exitCodeConsumer ) {
@@ -60,12 +63,13 @@ public TestSplit(
60
63
this .glob = glob ;
61
64
this .excludeGlob = excludeGlob ;
62
65
this .junitGlob = junitGlob ;
66
+ this .format = format ;
63
67
this .workingDirectory = workingDirectory ;
64
68
this .debug = debug ;
65
69
this .exitCodeConsumer = exitCodeConsumer ;
66
70
}
67
71
68
- public @ NotNull String run () throws Exception {
72
+ public @ NotNull List < String > run () throws Exception {
69
73
LOG .info ("Split index {} (total: {})" , splitIndex , splitTotal );
70
74
LOG .info ("Working directory: {}" , workingDirectory );
71
75
LOG .info ("Glob: {}" , glob );
@@ -75,6 +79,7 @@ public TestSplit(
75
79
if (junitGlob != null ) {
76
80
LOG .info ("JUnit glob: {}" , junitGlob );
77
81
}
82
+ LOG .info ("Output format: {}" , format .getParameterValue ());
78
83
final var testPaths = getPaths (workingDirectory , glob , excludeGlob );
79
84
final var classNames = fileToClassName (testPaths , exitCodeConsumer );
80
85
if (classNames .isEmpty ()) {
@@ -153,7 +158,11 @@ public TestSplit(
153
158
.stream ()
154
159
.sorted (Comparator .reverseOrder ())
155
160
.map (TestCase ::name )
156
- .collect (Collectors .joining (" " ));
161
+ .map (test -> switch (format ) {
162
+ case LIST -> test ;
163
+ case GRADLE -> "--tests " + test ;
164
+ })
165
+ .collect (Collectors .toList ());
157
166
}
158
167
159
168
private static @ NotNull Set <Path > getPaths (
0 commit comments