diff options
author | Emilia Käsper <emilia@openssl.org> | 2017-01-12 02:57:11 +0100 |
---|---|---|
committer | Thai Duong <thaidn@gmail.com> | 2017-01-11 17:57:11 -0800 |
commit | b898a62f3f61fa30bf1ffd1e04016387ccd59141 (patch) | |
tree | a17c406ef3e26743f8154beaee0d28d4d3c9c1c7 | |
parent | 189df209602bda4262034a1e19e84b1fe4330fd8 (diff) | |
download | wycheproof-b898a62f3f61fa30bf1ffd1e04016387ccd59141.tar.gz |
Option to test a local BouncyCastle jar (#16)
Resolves Github issue #4
-rw-r--r-- | BUILD | 16 | ||||
-rw-r--r-- | README.md | 20 | ||||
-rw-r--r-- | WORKSPACE | 4 | ||||
-rw-r--r-- | local_repository_defs.bzl | 25 |
4 files changed, 65 insertions, 0 deletions
@@ -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. # @@ -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 @@ -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") diff --git a/local_repository_defs.bzl b/local_repository_defs.bzl new file mode 100644 index 0000000..3c9b348 --- /dev/null +++ b/local_repository_defs.bzl @@ -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 +) |