Skip to content

Commit 7f329f4

Browse files
committed
Trim unused TestCompiler members, rename javaTestSettings
1 parent 231d5be commit 7f329f4

3 files changed

Lines changed: 4 additions & 64 deletions

File tree

build.sbt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ lazy val snapshots = project
591591
.in(file("tests/snapshots"))
592592
.settings(
593593
javaOnlySettings,
594-
javaJUnitTestSettings,
594+
javaTestSettings,
595595
Compile / mainClass := Some("tests.SaveSnapshots"),
596596
Compile / run / fork := true,
597597
Test / javaOptions ++= snapshotPathOptions.value,
@@ -609,14 +609,13 @@ lazy val javaOnlySettings = List[Def.Setting[_]](
609609
Compile / javacOptions ++= Seq("--release", "11")
610610
)
611611

612-
lazy val javaJUnitTestSettings = List[Def.Setting[_]](
612+
lazy val javaTestSettings = List[Def.Setting[_]](
613613
(publish / skip) := true,
614614
autoScalaLibrary := false,
615615
crossPaths := false,
616616
Test / fork := true,
617-
// Open the JDK-internal javac packages to in-process tests that drive
618-
// javac via reflection (e.g. JavacClassesDirectoryTest, TestCompiler).
619-
// On JDK 17+ this is required or the reflective access fails.
617+
// Open the JDK-internal javac packages to the in-process javac the tests
618+
// drive; on JDK 17+ this is required or the reflective access fails.
620619
Test / javaOptions ++= javacModuleOptions.map(_.stripPrefix("-J")),
621620
// Pin the JDK version embedded in stdlib SCIP symbols (e.g. `jdk 11
622621
// java/lang/String#`) so snapshots are stable across JDK 11/17/21.

scip-javac/src/test/java/com/sourcegraph/scip_javac/SimpleClassFile.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@ public OutputStream openOutputStream() throws IOException {
2222
public byte[] getCompiledBinaries() {
2323
return out.toByteArray();
2424
}
25-
26-
// getters
2725
}

scip-javac/src/test/java/com/sourcegraph/scip_javac/TestCompiler.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
import java.io.IOException;
44
import java.io.StringWriter;
55
import java.io.UncheckedIOException;
6-
import java.nio.charset.StandardCharsets;
76
import java.nio.file.Files;
87
import java.nio.file.Path;
98
import java.util.ArrayList;
10-
import java.util.Collections;
119
import java.util.List;
1210
import java.util.stream.Collectors;
13-
import java.util.stream.Stream;
1411
import javax.tools.JavaCompiler;
1512
import javax.tools.JavaFileObject;
1613
import javax.tools.ToolProvider;
@@ -39,31 +36,6 @@ public TestCompiler(
3936
new SimpleFileManager(compiler.getStandardFileManager(null, null, null), targetroot);
4037
}
4138

42-
public TestCompiler(String classpath, List<String> javacOptions, Path targetroot) {
43-
this(classpath, javacOptions, targetroot, createTempDir());
44-
}
45-
46-
public TestCompiler(Path targetroot) {
47-
this(PROCESSOR_PATH, Collections.emptyList(), targetroot);
48-
}
49-
50-
public CompileResult compileScipDirectory(Path dir) {
51-
return compileScip(inputsFromDirectory(dir));
52-
}
53-
54-
public CompileResult compileScip(List<VirtualFile> inputs) {
55-
return compile(
56-
inputs,
57-
Collections.singletonList(
58-
String.format(
59-
"-Xplugin:scip -verbose -text:on -sourceroot:%s -targetroot:%s",
60-
sourceroot, targetroot)));
61-
}
62-
63-
public CompileResult compile(List<VirtualFile> inputs) {
64-
return compile(inputs, Collections.emptyList());
65-
}
66-
6739
public CompileResult compile(List<VirtualFile> inputs, List<String> extraJavacOptions) {
6840
List<VirtualFile> javacInputs =
6941
inputs.stream().filter(i -> i.path.endsWith(".java")).collect(Collectors.toList());
@@ -108,33 +80,4 @@ private CompileResult compileJavac(List<VirtualFile> inputs, List<String> extraJ
10880
}
10981
return new CompileResult(bytecode, output.toString(), docs, isSuccess);
11082
}
111-
112-
private List<VirtualFile> inputsFromDirectory(Path dir) {
113-
try (Stream<Path> paths = Files.walk(dir)) {
114-
return paths
115-
.filter(Files::isRegularFile)
116-
.filter(p -> p.getFileName().toString().endsWith(".java"))
117-
.map(
118-
p -> {
119-
try {
120-
return new VirtualFile(
121-
dir.relativize(p).toString(),
122-
new String(Files.readAllBytes(p), StandardCharsets.UTF_8));
123-
} catch (IOException e) {
124-
throw new UncheckedIOException(e);
125-
}
126-
})
127-
.collect(Collectors.toList());
128-
} catch (IOException e) {
129-
throw new UncheckedIOException(e);
130-
}
131-
}
132-
133-
private static Path createTempDir() {
134-
try {
135-
return Files.createTempDirectory("scip-javac");
136-
} catch (IOException e) {
137-
throw new UncheckedIOException(e);
138-
}
139-
}
14083
}

0 commit comments

Comments
 (0)