aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2018-09-10 14:45:23 -0700
committerLiam Miller-Cushon <cushon@google.com>2018-09-10 19:54:15 -0700
commitf9e413bbcae622b3d2c609a73ff626682d330ffc (patch)
tree5e7828665bda81c7314cf272b2132a6653e1719e /javatests
parente098b2ab3dc4041ecd4080f2f30ff839209f347c (diff)
downloadturbine-f9e413bbcae622b3d2c609a73ff626682d330ffc.tar.gz
Improve usage errors
Add --help text, and print usage errors instead of crashing MOE_MIGRATED_REVID=212338293
Diffstat (limited to 'javatests')
-rw-r--r--javatests/com/google/turbine/main/MainTest.java13
-rw-r--r--javatests/com/google/turbine/options/TurbineOptionsTest.java12
2 files changed, 17 insertions, 8 deletions
diff --git a/javatests/com/google/turbine/main/MainTest.java b/javatests/com/google/turbine/main/MainTest.java
index 9307cb0..654a89b 100644
--- a/javatests/com/google/turbine/main/MainTest.java
+++ b/javatests/com/google/turbine/main/MainTest.java
@@ -229,4 +229,17 @@ public class MainTest {
assertThat(expected).hasMessageThat().contains("java.lang");
}
}
+
+ @Test
+ public void usage() throws IOException {
+ Path src = temporaryFolder.newFile("Test.java").toPath();
+ Files.write(src, "public class Test {}".getBytes(UTF_8));
+
+ try {
+ Main.compile(optionsWithBootclasspath().addSources(ImmutableList.of(src.toString())).build());
+ fail();
+ } catch (UsageException expected) {
+ assertThat(expected).hasMessageThat().contains("--output is required");
+ }
+ }
}
diff --git a/javatests/com/google/turbine/options/TurbineOptionsTest.java b/javatests/com/google/turbine/options/TurbineOptionsTest.java
index f460da4..5953bac 100644
--- a/javatests/com/google/turbine/options/TurbineOptionsTest.java
+++ b/javatests/com/google/turbine/options/TurbineOptionsTest.java
@@ -80,7 +80,7 @@ public class TurbineOptionsTest {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));
- assertThat(options.outputFile()).isEqualTo("out.jar");
+ assertThat(options.output()).hasValue("out.jar");
assertThat(options.sourceJars())
.containsExactly("sources1.srcjar", "sources2.srcjar")
.inOrder();
@@ -223,13 +223,9 @@ public class TurbineOptionsTest {
}
@Test
- public void failIfMissingExpectedArgs() throws Exception {
- try {
- TurbineOptions.builder().build();
- fail();
- } catch (NullPointerException e) {
- assertThat(e).hasMessage("output must not be null");
- }
+ public void tolerateMissingOutput() throws Exception {
+ TurbineOptions options = TurbineOptions.builder().build();
+ assertThat(options.output()).isEmpty();
}
@Test