aboutsummaryrefslogtreecommitdiff
path: root/test_defs.bzl
diff options
context:
space:
mode:
authorBrad Corso <bcorso@google.com>2022-03-31 10:26:38 -0700
committerDagger Team <dagger-dev+copybara@google.com>2022-03-31 10:28:05 -0700
commitfd44b09cbe13e050f2d09ec25779f7a0dbab2604 (patch)
tree9195be115e33904bbac545aa8ff2dfd9fae2d000 /test_defs.bzl
parente3d446873e145f1e0b41f1fd08a67b4bca7cce0b (diff)
downloaddagger2-fd44b09cbe13e050f2d09ec25779f7a0dbab2604.tar.gz
Adds script to generate golden files for Dagger's internal/codegen tests and migrates our tests to use it.
This CL should make it easier to update our codegen tests after a change to the generated code. To update it, run the following command: ``` third_party/java_src/dagger/project/java/dagger/testing/golden/scripts/update_goldens.sh ``` RELNOTES=N/A PiperOrigin-RevId: 438601639
Diffstat (limited to 'test_defs.bzl')
-rw-r--r--test_defs.bzl10
1 files changed, 8 insertions, 2 deletions
diff --git a/test_defs.bzl b/test_defs.bzl
index b24b6b06b..2962861f5 100644
--- a/test_defs.bzl
+++ b/test_defs.bzl
@@ -90,7 +90,7 @@ def _GenTests(
lib_javacopts = None,
test_javacopts = None,
functional = True,
- test_kwargs = {}):
+ test_kwargs = None):
_gen_tests(
library_rule_type,
test_rule_type,
@@ -139,7 +139,7 @@ def _gen_tests(
test_javacopts,
functional,
variant_name = None,
- test_kwargs = {}):
+ test_kwargs = None):
if variant_name:
suffix = "_" + variant_name
tags = [variant_name]
@@ -160,6 +160,9 @@ def _gen_tests(
else:
supporting_files.append(src)
+ if not test_kwargs:
+ test_kwargs = {}
+
if not test_only_deps:
test_only_deps = []
@@ -179,12 +182,15 @@ def _gen_tests(
if functional:
_hjar_test(supporting_files_name, tags)
+ should_add_goldens = not functional and (test_rule_type == java_test)
for test_file in test_files:
test_name = test_file.replace(".java", "")
prefix_path = "src/test/java/"
package_name = native.package_name()
if package_name.find("javatests/") != -1:
prefix_path = "javatests/"
+ if should_add_goldens:
+ test_kwargs["resources"] = native.glob(["goldens/%s_*" % test_name])
test_class = (package_name + "/" + test_name).rpartition(prefix_path)[2].replace("/", ".")
test_rule_type(
name = test_name + suffix,