Created
November 27, 2018 08:03
-
-
Save dicarlo2/8254f5b8c3d954515287d5e33f20466f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load(":providers.bzl", "TypeScriptModuleInfo") | |
def _test_sources_aspect_impl(target, ctx): | |
result = depset() | |
if hasattr(ctx.rule.attr, "tags") and "NODE_MODULE_MARKER" in ctx.rule.attr.tags: | |
return struct(node_test_sources=result) | |
if hasattr(ctx.rule.attr, "deps"): | |
for dep in ctx.rule.attr.deps: | |
if hasattr(dep, "node_test_sources"): | |
result = depset(transitive=[result, dep.node_test_sources]) | |
if TypeScriptModuleInfo in target: | |
result = depset( | |
[f for f in target[TypeScriptModuleInfo].js if f.path.endswith( | |
".test.js")], | |
transitive=[result]) | |
elif hasattr(target, "files"): | |
result = depset([f for f in target.files.to_list() if f.path.endswith(".test.js")], | |
transitive=[result]) | |
return struct(node_test_sources=result) | |
test_sources_aspect = aspect( | |
_test_sources_aspect_impl, | |
attr_aspects=["deps"], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment