aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar dbabkin <dbabkin@google.com>2018-01-10 05:24:22 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-10 05:26:29 -0800
commit32dff21d00ad7d1bdf50e8761d675a6e7e002de9 (patch)
treeb4c63f295bcb7482dabd9e30da7efcea988c7ea0 /src/test/shell
parentcc386e62a2c585f7e0ef87ed5440c9abd757d647 (diff)
Create function createJavaInfo with new API. Implement JavaCompilationArgsProvider.
Added tests for checking JavaCompilationArgsProvider state. All other providers will be implemented in next CLs. RELNOTES:none PiperOrigin-RevId: 181451235
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/bazel_java_test.sh76
1 files changed, 74 insertions, 2 deletions
diff --git a/src/test/shell/bazel/bazel_java_test.sh b/src/test/shell/bazel/bazel_java_test.sh
index e19426d36c..d425411da2 100755
--- a/src/test/shell/bazel/bazel_java_test.sh
+++ b/src/test/shell/bazel/bazel_java_test.sh
@@ -1323,6 +1323,7 @@ EOF
expect_log "liba.jar"
}
+
function test_java_common_create_provider_with_ijar_unset_actions() {
mkdir -p java/com/google/foo
touch java/com/google/foo/{BUILD,A.java,my_rule.bzl}
@@ -1355,9 +1356,45 @@ my_rule = rule(
EOF
bazel build java/com/google/foo:banana >& "$TEST_log" && fail "Unexpected success"
- expect_log "In java_common.create_provider the value of use_ijar is True. Make sure the first argument of the function is the ctx.actions object."
+ expect_log "The value of use_ijar is True. Make sure the ctx.actions argument is valid."
+}
+
+
+function test_java_info_constructor_with_ijar_unset_actions() {
+ mkdir -p java/com/google/foo
+ touch java/com/google/foo/{BUILD,my_rule.bzl}
+ cat > java/com/google/foo/BUILD << EOF
+load(":my_rule.bzl", "my_rule")
+my_rule(
+ name = 'my_skylark_rule',
+ output_jar = 'my_skylark_rule_lib.jar'
+ )
+EOF
+
+ cat > java/com/google/foo/my_rule.bzl << EOF
+result = provider()
+def _impl(ctx):
+ javaInfo = JavaInfo(
+ output_jar = ctx.file.output_jar,
+ use_ijar = True,
+ java_toolchain = ctx.attr._java_toolchain
+ )
+ return [result(property = javaInfo)]
+
+my_rule = rule(
+ implementation = _impl,
+ attrs = {
+ 'output_jar' : attr.label(allow_single_file=True),
+ "_java_toolchain": attr.label(default = Label("//tools/jdk:toolchain"))
+ }
+)
+EOF
+
+ bazel build java/com/google/foo:my_skylark_rule >& "$TEST_log" && fail "Unexpected success"
+ expect_log "The value of use_ijar is True. Make sure the ctx.actions argument is valid."
}
+
function test_java_common_create_provider_with_ijar_unset_java_toolchain() {
mkdir -p java/com/google/foo
touch java/com/google/foo/{BUILD,A.java,my_rule.bzl}
@@ -1390,9 +1427,44 @@ my_rule = rule(
EOF
bazel build java/com/google/foo:banana >& "$TEST_log" && fail "Unexpected success"
- expect_log "In java_common.create_provider the value of use_ijar is True. Make sure the java_toolchain argument is a valid java_toolchain Target."
+ expect_log "The value of use_ijar is True. Make sure the java_toolchain argument is a valid."
}
+
+function test_java_info_constructor_with_ijar_unset_java_toolchain() {
+ mkdir -p java/com/google/foo
+ touch java/com/google/foo/{BUILD,my_rule.bzl}
+ cat > java/com/google/foo/BUILD << EOF
+load(":my_rule.bzl", "my_rule")
+my_rule(
+ name = 'my_skylark_rule',
+ output_jar = 'my_skylark_rule_lib.jar'
+ )
+EOF
+
+ cat > java/com/google/foo/my_rule.bzl << EOF
+result = provider()
+def _impl(ctx):
+ javaInfo = JavaInfo(
+ output_jar = ctx.file.output_jar,
+ use_ijar = True,
+ actions = ctx.actions
+ )
+ return [result(property = javaInfo)]
+
+my_rule = rule(
+ implementation = _impl,
+ attrs = {
+ 'output_jar' : attr.label(allow_single_file=True)
+ }
+)
+EOF
+
+ bazel build java/com/google/foo:my_skylark_rule >& "$TEST_log" && fail "Unexpected success"
+ expect_log "The value of use_ijar is True. Make sure the java_toolchain argument is a valid."
+}
+
+
function test_java_test_timeout() {
setup_javatest_support
mkdir -p javatests/com/google/timeout