15
15
package org .jspecify .conformance ;
16
16
17
17
import static com .google .common .base .Strings .nullToEmpty ;
18
- import static com .google .common .collect .ImmutableList . toImmutableList ;
18
+ import static com .google .common .collect .ImmutableSortedSet . toImmutableSortedSet ;
19
19
import static com .google .common .collect .Lists .partition ;
20
20
import static com .google .common .io .MoreFiles .asCharSink ;
21
21
import static com .google .common .io .MoreFiles .asCharSource ;
22
22
import static com .google .common .truth .Truth .assertThat ;
23
23
import static java .nio .charset .StandardCharsets .UTF_8 ;
24
24
import static java .nio .file .Files .walk ;
25
25
import static java .util .Arrays .stream ;
26
+ import static java .util .Comparator .naturalOrder ;
26
27
import static java .util .stream .Collectors .toList ;
27
28
28
29
import com .google .common .base .Ascii ;
29
30
import com .google .common .collect .ImmutableList ;
31
+ import com .google .common .collect .ImmutableSortedSet ;
30
32
import java .io .IOException ;
31
33
import java .io .UncheckedIOException ;
32
34
import java .nio .file .Files ;
@@ -48,7 +50,7 @@ public interface Analyzer {
48
50
* @return the facts reported by the analysis
49
51
*/
50
52
Iterable <ReportedFact > analyze (
51
- Path testDirectory , ImmutableList <Path > files , ImmutableList <Path > testDeps );
53
+ Path testDirectory , ImmutableSortedSet <Path > files , ImmutableList <Path > testDeps );
52
54
}
53
55
54
56
private final Analyzer analyzer ;
@@ -72,26 +74,28 @@ public ConformanceTestReport runTests(Path testDirectory, ImmutableList<Path> te
72
74
.filter (path -> path .toFile ().isDirectory ())
73
75
.flatMap (
74
76
directory -> {
75
- Stream <ImmutableList <Path >> groups = javaFileGroups (directory );
77
+ Stream <ImmutableSortedSet <Path >> groups = javaFileGroups (directory );
76
78
return directory .equals (testDirectory )
77
- ? groups .flatMap (files -> partition (files , 1 ).stream ())
79
+ ? groups .flatMap (files -> partition (files . asList () , 1 ).stream ())
78
80
: groups ;
79
81
})
80
- .map (ImmutableList ::copyOf )
82
+ .map (ImmutableSortedSet ::copyOf )
81
83
.forEach (
82
84
files -> report .addFiles (files , analyzer .analyze (testDirectory , files , testDeps )));
83
85
return report .build ();
84
86
}
85
87
}
86
88
87
- private static Stream <ImmutableList <Path >> javaFileGroups (Path directory ) {
88
- ImmutableList <Path > files = javaFilesInDirectory (directory );
89
+ private static Stream <ImmutableSortedSet <Path >> javaFileGroups (Path directory ) {
90
+ ImmutableSortedSet <Path > files = javaFilesInDirectory (directory );
89
91
return files .isEmpty () ? Stream .empty () : Stream .of (files );
90
92
}
91
93
92
- private static ImmutableList <Path > javaFilesInDirectory (Path directory ) {
94
+ private static ImmutableSortedSet <Path > javaFilesInDirectory (Path directory ) {
93
95
try (Stream <Path > files = Files .list (directory )) {
94
- return files .filter (f -> f .toString ().endsWith (".java" )).collect (toImmutableList ());
96
+ return files
97
+ .filter (f -> f .toString ().endsWith (".java" ))
98
+ .collect (toImmutableSortedSet (naturalOrder ()));
95
99
} catch (IOException e ) {
96
100
throw new UncheckedIOException (e );
97
101
}
0 commit comments