Skip to content

Commit

Permalink
support GO tests
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: ndmitchell

Differential Revision: D53019875

fbshipit-source-id: 8a9f001c40aa3d50cb41e54fce98b9963256cbf6
  • Loading branch information
annakukliansky authored and facebook-github-bot committed Jan 24, 2024
1 parent 0723f68 commit 4199f20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion prelude/decls/go_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ load(":common.bzl", "CxxRuntimeType", "CxxSourceType", "HeadersAsRawHeadersMode"
load(":cxx_common.bzl", "cxx_common")
load(":go_common.bzl", "go_common")
load(":native_common.bzl", "native_common")
load(":re_test_common.bzl", "re_test_common")

BuildMode = ["executable", "c_shared", "c_archive"]

Expand Down Expand Up @@ -447,7 +448,8 @@ go_test = prelude_rule(
"platform": attrs.option(attrs.string(), default = None),
"runner": attrs.option(attrs.dep(), default = None),
"specs": attrs.option(attrs.arg(json = True), default = None),
}
} |
re_test_common.test_args()
),
)

Expand Down
12 changes: 11 additions & 1 deletion prelude/go/go_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ load(
"@prelude//linking:link_info.bzl",
"LinkStyle",
)
load(
"@prelude//tests:re_utils.bzl",
"get_re_executors_from_props",
)
load(
"@prelude//utils:utils.bzl",
"map_val",
Expand Down Expand Up @@ -124,6 +128,9 @@ def go_test_impl(ctx: AnalysisContext) -> list[Provider]:
for resource in ctx.attrs.resources:
run_cmd.hidden(ctx.actions.copy_file(resource.short_path, resource))

# Setup RE executors based on the `remote_execution` param.
re_executor, executor_overrides = get_re_executors_from_props(ctx)

return inject_test_run_info(
ctx,
ExternalRunnerTestInfo(
Expand All @@ -132,8 +139,11 @@ def go_test_impl(ctx: AnalysisContext) -> list[Provider]:
env = ctx.attrs.env,
labels = ctx.attrs.labels,
contacts = ctx.attrs.contacts,
default_executor = re_executor,
executor_overrides = executor_overrides,
# FIXME: Consider setting to true
run_from_project_root = False,
run_from_project_root = re_executor != None,
use_project_relative_paths = re_executor != None,
),
) + [
DefaultInfo(
Expand Down

0 comments on commit 4199f20

Please sign in to comment.