From cd7a3e18f067d9026a50e424943e1bc9bc6ddcb4 Mon Sep 17 00:00:00 2001 From: David Sanderson Date: Thu, 12 Nov 2020 16:50:29 -0500 Subject: [PATCH] Debugging. --- lib/types.bzl | 11 ++++++++++- lib/unittest.bzl | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/types.bzl b/lib/types.bzl index 2ba73d06..5219d60c 100644 --- a/lib/types.bzl +++ b/lib/types.bzl @@ -28,6 +28,15 @@ def _a_function(): _a_function_type = type(_a_function) +def _a_rule_impl(ctx): + return [] + +_a_rule = rule( + implementation = _a_rule_impl, +) + +_a_rule_type = type(_a_rule) + def _is_list(v): """Returns True if v is an instance of a list. @@ -148,7 +157,7 @@ def _is_partial(v): True if v was created by partial.make(), False otherwise. """ return type(v) == _a_struct_type \ - and hasattr(v, "function") and _is_function(v.function) \ + and hasattr(v, "function") and (_is_function(v.function) or type(v.function) == _a_rule_type) \ and hasattr(v, "args") and _is_tuple(v.args) \ and hasattr(v, "kwargs") and _is_dict(v.kwargs) diff --git a/lib/unittest.bzl b/lib/unittest.bzl index c075cced..e742c33f 100644 --- a/lib/unittest.bzl +++ b/lib/unittest.bzl @@ -272,6 +272,8 @@ def _suite(name, *test_rules): test_name = "%s_test_%d" % (name, index) if types.is_partial(test_rule): partial.call(test_rule, name = test_name) + elif type(test_rule) == type(struct()): + fail("unexpected struct: {};\ntype(function): {};\ntype(args): {};\ntype(kwargs): {}".format(repr(test_rule), repr(type(test_rule.function)), repr(type(test_rule.args)), repr(type(test_rule.kwargs)) )) else: test_rule(name = test_name) test_names.append(test_name)