Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 604725039
  • Loading branch information
cpovirk authored and Javac Team committed Feb 6, 2024
1 parent 63cf102 commit f0b18b1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
3 changes: 1 addition & 2 deletions javatests/com/google/turbine/binder/ClassPathBinderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.io.MoreFiles;
import com.google.common.truth.Truth8;
import com.google.turbine.binder.bound.EnumConstantValue;
import com.google.turbine.binder.bound.TypeBoundClass;
import com.google.turbine.binder.bytecode.BytecodeBoundClass;
Expand Down Expand Up @@ -126,7 +125,7 @@ public void scope() {
new LookupKey(
ImmutableList.of(ident("java"), ident("util"), ident("Map"), ident("Entry"))));
assertThat(result.sym()).isEqualTo(new ClassSymbol("java/util/Map"));
Truth8.assertThat(result.remaining().stream().map(Ident::value)).containsExactly("Entry");
assertThat(result.remaining().stream().map(Ident::value)).containsExactly("Entry");

result =
scope.lookup(new LookupKey(ImmutableList.of(ident("java"), ident("util"), ident("Map"))));
Expand Down
9 changes: 4 additions & 5 deletions javatests/com/google/turbine/main/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.MoreFiles;
import com.google.common.truth.Truth8;
import com.google.protobuf.ExtensionRegistry;
import com.google.turbine.diag.TurbineError;
import com.google.turbine.options.LanguageVersion;
Expand Down Expand Up @@ -205,7 +204,7 @@ public void testManifest() throws IOException {

try (JarFile jarFile = new JarFile(output.toFile())) {
try (Stream<JarEntry> entries = jarFile.stream()) {
Truth8.assertThat(entries.map(JarEntry::getName))
assertThat(entries.map(JarEntry::getName))
.containsAtLeast("META-INF/", "META-INF/MANIFEST.MF");
}
Manifest manifest = requireNonNull(jarFile.getManifest());
Expand Down Expand Up @@ -311,7 +310,7 @@ public void noSources() throws IOException {
Main.compile(optionsWithBootclasspath().setGensrcOutput(gensrc.toString()).build());
try (JarFile jarFile = new JarFile(gensrc);
Stream<JarEntry> entries = jarFile.stream()) {
Truth8.assertThat(entries.map(JarEntry::getName))
assertThat(entries.map(JarEntry::getName))
.containsExactly("META-INF/", "META-INF/MANIFEST.MF");
}
}
Expand Down Expand Up @@ -419,7 +418,7 @@ public void noSourcesProcessing() throws IOException {
.build());
try (JarFile jarFile = new JarFile(gensrc);
Stream<JarEntry> entries = jarFile.stream()) {
Truth8.assertThat(entries.map(JarEntry::getName))
assertThat(entries.map(JarEntry::getName))
.containsExactly("META-INF/", "META-INF/MANIFEST.MF");
}
}
Expand Down Expand Up @@ -486,7 +485,7 @@ public void classGeneration() throws IOException {
.build());
try (JarFile jarFile = new JarFile(resources);
Stream<JarEntry> entries = jarFile.stream()) {
Truth8.assertThat(entries.map(JarEntry::getName)).containsExactly("g/Gen.class");
assertThat(entries.map(JarEntry::getName)).containsExactly("g/Gen.class");
}
}

Expand Down
9 changes: 4 additions & 5 deletions javatests/com/google/turbine/options/LanguageVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.truth.Truth8;
import javax.lang.model.SourceVersion;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -102,9 +101,9 @@ public void invalidRelease() {

@Test
public void parseRelease() {
Truth8.assertThat(LanguageVersion.fromJavacopts(ImmutableList.of("--release", "16")).release())
assertThat(LanguageVersion.fromJavacopts(ImmutableList.of("--release", "16")).release())
.hasValue(16);
Truth8.assertThat(
assertThat(
LanguageVersion.fromJavacopts(ImmutableList.of("-source", "8", "-target", "8"))
.release())
.isEmpty();
Expand All @@ -126,11 +125,11 @@ public void parseTarget() {

@Test
public void releaseUnderride() {
Truth8.assertThat(
assertThat(
LanguageVersion.fromJavacopts(ImmutableList.of("--release", "12", "-source", "8"))
.release())
.isEmpty();
Truth8.assertThat(
assertThat(
LanguageVersion.fromJavacopts(ImmutableList.of("--release", "12", "-target", "8"))
.release())
.isEmpty();
Expand Down
29 changes: 14 additions & 15 deletions javatests/com/google/turbine/options/TurbineOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.truth.Truth8;
import com.google.turbine.options.TurbineOptions.ReducedClasspathMode;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -82,7 +81,7 @@ public void exhaustiveArgs() throws Exception {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));

Truth8.assertThat(options.output()).hasValue("out.jar");
assertThat(options.output()).hasValue("out.jar");
assertThat(options.sourceJars())
.containsExactly("sources1.srcjar", "sources2.srcjar")
.inOrder();
Expand All @@ -94,9 +93,9 @@ public void exhaustiveArgs() throws Exception {
assertThat(options.bootClassPath()).containsExactly("rt.jar", "zipfs.jar").inOrder();
assertThat(options.javacOpts()).containsExactly("-source", "8", "-target", "8").inOrder();
assertThat(options.sources()).containsExactly("Source1.java", "Source2.java");
Truth8.assertThat(options.outputDeps()).hasValue("out.jdeps");
Truth8.assertThat(options.targetLabel()).hasValue("//java/com/google/test");
Truth8.assertThat(options.injectingRuleKind()).hasValue("foo_library");
assertThat(options.outputDeps()).hasValue("out.jdeps");
assertThat(options.targetLabel()).hasValue("//java/com/google/test");
assertThat(options.injectingRuleKind()).hasValue("foo_library");
assertThat(options.reducedClasspathMode()).isEqualTo(ReducedClasspathMode.NONE);
}

Expand All @@ -119,7 +118,7 @@ public void strictJavaDepsArgs() throws Exception {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));

Truth8.assertThat(options.targetLabel()).hasValue("//java/com/google/test");
assertThat(options.targetLabel()).hasValue("//java/com/google/test");
assertThat(options.directJars()).containsExactly("blaze-out/foo/libbar.jar");
assertThat(options.depsArtifacts()).containsExactly("foo.jdeps", "bar.jdeps");
}
Expand Down Expand Up @@ -185,8 +184,8 @@ public void optionalTargetLabel() throws Exception {

TurbineOptions options = TurbineOptionsParser.parse(Arrays.asList(lines));

Truth8.assertThat(options.targetLabel()).isEmpty();
Truth8.assertThat(options.injectingRuleKind()).isEmpty();
assertThat(options.targetLabel()).isEmpty();
assertThat(options.injectingRuleKind()).isEmpty();
}

@Test
Expand Down Expand Up @@ -218,7 +217,7 @@ public void paramsFile() throws Exception {
.containsExactly("-source", "8", "-target", "8", "-Aconnector.opt=with,space, here")
.inOrder();
// ... and directly from the command line
Truth8.assertThat(options.targetLabel()).hasValue("//custom/label");
assertThat(options.targetLabel()).hasValue("//custom/label");
}

@Test
Expand All @@ -232,13 +231,13 @@ public void escapedExternalRepositoryLabel() throws Exception {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));

Truth8.assertThat(options.targetLabel()).hasValue("@other-repo//foo:local-jam");
assertThat(options.targetLabel()).hasValue("@other-repo//foo:local-jam");
}

@Test
public void tolerateMissingOutput() throws Exception {
TurbineOptions options = TurbineOptions.builder().build();
Truth8.assertThat(options.output()).isEmpty();
assertThat(options.output()).isEmpty();
}

@Test
Expand Down Expand Up @@ -320,8 +319,8 @@ public void miscOutputs() throws Exception {
Iterables.concat(
BASE_ARGS,
ImmutableList.of("--gensrc_output", "gensrc.jar", "--profile", "turbine.prof")));
Truth8.assertThat(options.gensrcOutput()).hasValue("gensrc.jar");
Truth8.assertThat(options.profile()).hasValue("turbine.prof");
assertThat(options.gensrcOutput()).hasValue("gensrc.jar");
assertThat(options.profile()).hasValue("turbine.prof");
}

@Test
Expand Down Expand Up @@ -379,8 +378,8 @@ public void javaBuilderCompatibility() throws Exception {
"--native_header_output",
"ignored",
"--compress_jar")));
Truth8.assertThat(options.outputDeps()).hasValue("output_deps.proto");
Truth8.assertThat(options.gensrcOutput()).hasValue("generated_sources.jar");
assertThat(options.outputDeps()).hasValue("output_deps.proto");
assertThat(options.gensrcOutput()).hasValue("generated_sources.jar");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.truth.Truth8;
import com.google.turbine.binder.Binder;
import com.google.turbine.binder.Binder.BindingResult;
import com.google.turbine.binder.ClassPathBinder;
Expand Down Expand Up @@ -573,7 +572,7 @@ public void qualifiedErrorType() throws IOException {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(
assertThat(
e.diagnostics().stream()
.filter(d -> d.severity().equals(Diagnostic.Kind.NOTE))
.map(d -> d.message()))
Expand Down Expand Up @@ -624,12 +623,12 @@ public void badElementValue() throws IOException {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(
assertThat(
e.diagnostics().stream()
.filter(d -> d.severity().equals(Diagnostic.Kind.ERROR))
.map(d -> d.message()))
.containsExactly("could not resolve element noSuch() in java.lang.Deprecated");
Truth8.assertThat(
assertThat(
e.diagnostics().stream()
.filter(d -> d.severity().equals(Diagnostic.Kind.NOTE))
.map(d -> d.message()))
Expand Down Expand Up @@ -680,7 +679,7 @@ public void recordProcessing() throws IOException {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(
assertThat(
e.diagnostics().stream()
.filter(d -> d.severity().equals(Diagnostic.Kind.ERROR))
.map(d -> d.message()))
Expand Down Expand Up @@ -719,7 +718,7 @@ public void missingElementValue() {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(e.diagnostics().stream().map(d -> d.message()))
assertThat(e.diagnostics().stream().map(d -> d.message()))
.containsExactly("missing required annotation argument: value");
}

Expand Down Expand Up @@ -811,7 +810,7 @@ public void bound() {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(e.diagnostics().stream().map(d -> d.message()))
assertThat(e.diagnostics().stream().map(d -> d.message()))
.containsExactly(
"A#f<U>(java.util.List<U>)U <: B#f<U>(java.util.List<U>)U ? false",
"A#f<U>(java.util.List<U>)U <: C#f<U>(java.util.List<U>)U ? false",
Expand Down Expand Up @@ -870,7 +869,7 @@ public void uriProcessing() throws IOException {
SourceVersion.latestSupported()),
TestClassPaths.TURBINE_BOOTCLASSPATH,
Optional.empty()));
Truth8.assertThat(
assertThat(
e.diagnostics().stream()
.filter(d -> d.severity().equals(Diagnostic.Kind.ERROR))
.map(d -> d.message()))
Expand Down

0 comments on commit f0b18b1

Please sign in to comment.