aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java
diff options
context:
space:
mode:
authorGravatar Liam Miller-Cushon <cushon@google.com>2016-04-22 22:47:41 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-04-25 09:09:59 +0000
commitf6893d8773bb01772f4fbaeef07dcc1533d89cc8 (patch)
tree66ac871edbee56e4694b02f80ae7b1a4cd221085 /src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java
parent49acce8a027252585d61e2c82f7298acad9da77a (diff)
Make --target_label and --rule_kind optional
This is consistent with JavaBuilder. Some actions (e.g. resource compilations) don't set these flags. -- MOS_MIGRATED_REVID=120590777
Diffstat (limited to 'src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java')
-rw-r--r--src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java
index c1af7e1978..1b40b7a155 100644
--- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java
+++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/TurbineOptionsTest.java
@@ -17,6 +17,7 @@ package com.google.devtools.build.java.turbine;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
@@ -100,8 +101,8 @@ public class TurbineOptionsTest {
assertThat(options.javacOpts()).containsExactly("-source", "8", "-target", "8").inOrder();
assertThat(options.sources()).containsExactly("Source1.java", "Source2.java");
assertThat(options.outputDeps()).hasValue("out.jdeps");
- assertThat(options.targetLabel()).isEqualTo("//java/com/google/test");
- assertThat(options.ruleKind()).isEqualTo("java_library");
+ assertThat(options.targetLabel()).isEqualTo(Optional.of("//java/com/google/test"));
+ assertThat(options.ruleKind()).isEqualTo(Optional.of("java_library"));
}
@Test
@@ -127,7 +128,7 @@ public class TurbineOptionsTest {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));
- assertThat(options.targetLabel()).isEqualTo("//java/com/google/test");
+ assertThat(options.targetLabel()).isEqualTo(Optional.of("//java/com/google/test"));
assertThat(options.directJarsToTargets())
.containsExactlyEntriesIn(ImmutableMap.of("blaze-out/foo/libbar.jar", "//foo/bar"));
assertThat(options.indirectJarsToTargets())
@@ -157,6 +158,26 @@ public class TurbineOptionsTest {
}
@Test
+ public void optionalTargetLabelAndRuleKind() throws Exception {
+ String[] lines = {
+ "--output",
+ "out.jar",
+ "--temp_dir",
+ "_tmp",
+ "--classpath",
+ "liba.jar:libb.jar:libc.jar",
+ "--processorpath",
+ "libpa.jar:libpb.jar:libpc.jar",
+ };
+
+ TurbineOptions options = TurbineOptionsParser.parse(Arrays.asList(lines));
+
+ assertThat(options.ruleKind()).isAbsent();
+ assertThat(options.targetLabel()).isAbsent();
+ }
+
+
+ @Test
public void paramsFile() throws Exception {
Iterable<String> paramsArgs =
Iterables.concat(BASE_ARGS, Arrays.asList("--javacopts", "-source", "8", "-target", "8"));
@@ -174,7 +195,7 @@ public class TurbineOptionsTest {
// assert that options were read from params file
assertThat(options.javacOpts()).containsExactly("-source", "8", "-target", "8").inOrder();
// ... and directly from the command line
- assertThat(options.targetLabel()).isEqualTo("//custom/label");
+ assertThat(options.targetLabel()).isEqualTo(Optional.of("//custom/label"));
}
@Test
@@ -188,7 +209,7 @@ public class TurbineOptionsTest {
TurbineOptions options =
TurbineOptionsParser.parse(Iterables.concat(BASE_ARGS, Arrays.asList(lines)));
- assertThat(options.targetLabel()).isEqualTo("@@other-repo//foo:local-jam");
+ assertThat(options.targetLabel()).isEqualTo(Optional.of("@@other-repo//foo:local-jam"));
}
@Test