Option to test a local BouncyCastle jar (#16)

Resolves Github issue #4
This commit is contained in:
Emilia Käsper
2017-01-12 02:57:11 +01:00
committed by Thai Duong
parent 189df20960
commit b898a62f3f
4 changed files with 65 additions and 0 deletions
+16
View File
@@ -38,6 +38,14 @@ bouncycastle_all_tests(
deps = common_deps,
)
java_test(
name = "BouncyCastleAllTestsLocal",
size = "large",
srcs = ["java/com/google/security/wycheproof/BouncyCastleAllTests.java"] + test_srcs,
test_class = "com.google.security.wycheproof.BouncyCastleAllTests",
deps = common_deps + ["@local//:bouncycastle_jar"],
)
# Generates SpongyCastleAllTests_1_xx target for all available versions,
# plus a SpongyCastleAllTests alias for latest stable.
#
@@ -79,6 +87,14 @@ bouncycastle_tests(
deps = common_deps,
)
java_test(
name = "BouncyCastleTestLocal",
size = "large",
srcs = ["java/com/google/security/wycheproof/BouncyCastleTest.java"] + test_srcs,
test_class = "com.google.security.wycheproof.BouncyCastleTest",
deps = common_deps + ["@local//:bouncycastle_jar"],
)
# Generates SpongyCastleTest_1_xx target for all available versions,
# plus a SpongyCastleTest alias for latest stable.
#
+20
View File
@@ -110,6 +110,26 @@ bazel test BouncyCastleAllTests_1_52
bazel test BouncyCastleAllTests_*
```
- To test a local jar, set the `WYCHEPROOF_BOUNCYCASTLE_JAR` environment variable:
``` shell
$ WYCHEPROOF_BOUNCYCASTLE_JAR=/path/to/bouncycastle
$ bazel test BouncyCastleTestLocal
$ bazel test BouncyCastleAllTestsLocal
```
Note: bazel does not currently invalidate the build on environment changes. If
you change the `WYCHEPROOF_BOUNCYCASTLE_JAR` environment variable, run `bazel
clean` to force a rebuild:
``` shell
$ WYCHEPROOF_BOUNCYCASTLE_JAR=/path/to/bouncycastle
$ bazel test BouncyCastleTestLocal
$ WYCHEPROOF_BOUNCYCASTLE_JAR=/path/to/other/jar
$ bazel clean
$ bazel test BouncyCastleTestLocal
```
- To test [Spongy Castle](https://rtyley.github.io/spongycastle/), replace
BouncyCastle with SpongyCastle in your commands, for example
+4
View File
@@ -97,3 +97,7 @@ maven_jar(
name = "spongycastle_prov_1_54",
artifact = "com.madgag.spongycastle:prov:1.54.0.0",
)
load(":local_repository_defs.bzl", "local_jars")
local_jars(name = "local")
+25
View File
@@ -0,0 +1,25 @@
_bouncycastle_jar_rule = """
java_import(
name = "bouncycastle_jar",
jars = ["bouncycastle.jar"],
visibility = ["//visibility:public"],
)
"""
# TODO(ekasper): implement environment invalidation once supported by bazel,
# see https://bazel.build/designs/2016/10/18/repository-invalidation.html
# Meanwhile, users have to call 'bazel clean' explicitly when the
# environment changes.
def _local_jars_impl(repository_ctx):
contents = ""
if "WYCHEPROOF_BOUNCYCASTLE_JAR" in repository_ctx.os.environ:
repository_ctx.symlink(repository_ctx.os.environ["WYCHEPROOF_BOUNCYCASTLE_JAR"],
"bouncycastle.jar")
contents += _bouncycastle_jar_rule
repository_ctx.file("BUILD", contents)
local_jars = repository_rule(
implementation = _local_jars_impl,
local = True
)