diff options
Diffstat (limited to 'javatests')
-rw-r--r-- | javatests/com/google/turbine/main/MainTest.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/main/MainTest.java b/javatests/com/google/turbine/main/MainTest.java index 80a0372..b37cc8c 100644 --- a/javatests/com/google/turbine/main/MainTest.java +++ b/javatests/com/google/turbine/main/MainTest.java @@ -29,6 +29,7 @@ import com.google.common.io.ByteStreams; import com.google.common.io.MoreFiles; import com.google.turbine.diag.TurbineError; import com.google.turbine.options.TurbineOptions; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -261,4 +262,18 @@ public class MainTest { .contains("at least one of --output, --gensrc_output, or --resource_output is required"); } } + + @Test + public void noSources() throws IOException { + // Compilations with no sources (or source jars) are accepted, and create empty for requested + // outputs. This is helpful for the Bazel integration, which allows java_library rules to be + // declared without sources. + File gensrc = temporaryFolder.newFile("gensrc.jar"); + Main.compile(optionsWithBootclasspath().setGensrcOutput(gensrc.toString()).build()); + try (JarFile jarFile = new JarFile(gensrc); + Stream<JarEntry> entries = jarFile.stream()) { + assertThat(entries.map(JarEntry::getName)) + .containsExactly("META-INF/", "META-INF/MANIFEST.MF"); + } + } } |