Skip to content

Commit

Permalink
Debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
dws committed Nov 12, 2020
1 parent 348c5ca commit cd7a3e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/types.bzl
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions lib/unittest.bzl
Expand Up @@ -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)
Expand Down

0 comments on commit cd7a3e1

Please sign in to comment.