Skip to content

Commit f565733

Browse files
committed
Add a ct_hooks attribute to the ct_test & ct_sharded_test rules
This is a string attribute, so the compiled hook must be provided to the test via the regular means for a dep (runtime_deps, additional_beam, etc.).
1 parent c22c993 commit f565733

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ct.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def _impl(ctx):
5656
for k, v in ctx.attr.test_env.items():
5757
test_env_commands.append("export {}=\"{}\"".format(k, v))
5858

59+
ct_hooks_args = ""
60+
if len(ctx.attr.ct_hooks) > 0:
61+
ct_hooks_args = "-ct_hooks " + " ".join(ctx.attr.ct_hooks)
62+
5963
sname = sanitize_sname("ct-{}-{}".format(
6064
ctx.label.package.rpartition("/")[-1],
6165
ctx.label.name,
@@ -85,6 +89,7 @@ set -x
8589
{pa_args} $FILTER \\
8690
-dir $TEST_SRCDIR/$TEST_WORKSPACE/{dir} \\
8791
-logdir ${{TEST_UNDECLARED_OUTPUTS_DIR}} \\
92+
{ct_hooks_args} \\
8893
-sname {sname}
8994
""".format(
9095
begins_with_fun = BEGINS_WITH_FUN,
@@ -95,6 +100,7 @@ set -x
95100
pa_args = pa_args,
96101
filter_tests_args = filter_tests_args,
97102
dir = short_dirname(ctx.files.compiled_suites[0]),
103+
ct_hooks_args = ct_hooks_args,
98104
sname = sname,
99105
test_env = " && ".join(test_env_commands),
100106
)
@@ -123,6 +129,7 @@ ct_test = rule(
123129
allow_files = [".beam"],
124130
mandatory = True,
125131
),
132+
"ct_hooks": attr.string_list(),
126133
"data": attr.label_list(allow_files = True),
127134
"deps": attr.label_list(providers = [ErlangLibInfo]),
128135
"tools": attr.label_list(),

ct_sharded.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def _impl(ctx):
2929
for k, v in ctx.attr.test_env.items():
3030
test_env_commands.append("export {}=\"{}\"".format(k, v))
3131

32+
ct_hooks_args = ""
33+
if len(ctx.attr.ct_hooks) > 0:
34+
ct_hooks_args = "-ct_hooks " + " ".join(ctx.attr.ct_hooks)
35+
3236
sname = sanitize_sname("ct-{}-{}".format(
3337
ctx.label.package.rpartition("/")[-1],
3438
ctx.label.name,
@@ -85,6 +89,7 @@ set -x
8589
${{FILTER}} \\
8690
-dir $TEST_SRCDIR/$TEST_WORKSPACE/{dir} \\
8791
-logdir ${{TEST_UNDECLARED_OUTPUTS_DIR}} \\
92+
{ct_hooks_args} \\
8893
-sname {sname}
8994
""".format(
9095
begins_with_fun = BEGINS_WITH_FUN,
@@ -98,6 +103,7 @@ set -x
98103
sharding_method = ctx.attr.sharding_method,
99104
suite_name = ctx.attr.suite_name,
100105
dir = short_dirname(ctx.files.compiled_suites[0]),
106+
ct_hooks_args = ct_hooks_args,
101107
sname = sname,
102108
test_env = " && ".join(test_env_commands),
103109
)
@@ -133,6 +139,7 @@ ct_sharded_test = rule(
133139
allow_files = [".beam"],
134140
mandatory = True,
135141
),
142+
"ct_hooks": attr.string_list(),
136143
"data": attr.label_list(allow_files = True),
137144
"deps": attr.label_list(providers = [ErlangLibInfo]),
138145
"tools": attr.label_list(),

0 commit comments

Comments
 (0)