Skip to content

Commit

Permalink
Propagating debug source db to test process via env
Browse files Browse the repository at this point in the history
Summary: `dbg-db.json` contains the right source mapping for python unittest file. we inject the source mapping file path via env into the test environement

Reviewed By: patskovn

Differential Revision: D67856724

fbshipit-source-id: 08763b9ee36475e4d27a227b390a7538681a42e9
  • Loading branch information
Yahaya Suleiman authored and facebook-github-bot committed Jan 6, 2025
1 parent d9a827a commit 9b4f80f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions prelude/python/make_py_package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ PexProviders = record(
hidden_resources = list[ArgLike],
sub_targets = dict[str, list[Provider]],
run_cmd = cmd_args,
dbg_source_db = field(Artifact | None, None),
)

ManifestModule = record(
Expand Down
10 changes: 10 additions & 0 deletions prelude/python/python_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ def python_executable(
dbg_source_db_output,
)

exe = PexProviders(
default_output = exe.default_output,
other_outputs = exe.other_outputs,
other_outputs_prefix = exe.other_outputs_prefix,
hidden_resources = exe.hidden_resources,
sub_targets = exe.sub_targets,
run_cmd = exe.run_cmd,
dbg_source_db = dbg_source_db_output,
)

exe.sub_targets.update({
"dbg-source-db": [dbg_source_db],
"library-info": [library_info],
Expand Down
5 changes: 4 additions & 1 deletion prelude/python/python_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ def python_test_impl(ctx: AnalysisContext) -> list[Provider]:

# Setup RE executors based on the `remote_execution` param.
re_executor, executor_overrides = get_re_executors_from_props(ctx)
test_env = ctx.attrs.env
if pex.dbg_source_db:
test_env["PYTHON_SOURCE_MAP"] = pex.dbg_source_db

return inject_test_run_info(
ctx,
ExternalRunnerTestInfo(
type = "pyunit",
command = [test_cmd],
env = ctx.attrs.env,
env = test_env,
labels = ctx.attrs.labels,
contacts = ctx.attrs.contacts,
default_executor = re_executor,
Expand Down

0 comments on commit 9b4f80f

Please sign in to comment.