Forward environment variables to all tmt subprocess invocations

Problem

The discovery and export methods (_plans_from_git, _is_plan_empty, export_plan) in both test_schedule_tmt and test_schedule_tmt_multihost were not forwarding environment variables to Command.run(env=...), while _run_plan already did.

This caused two issues:

  1. Deployment-level variables like TMT_IMPORT_BEFORE_NAME_FILTER were missing during plan discovery, leading to plans imported with scope: all-plans / importing: become-parent being incorrectly skipped as "empty" (the tmt run discover plan --name probe failed to resolve them without import-before-name-filter).

  2. Request-level tmt.environment variables were only forwarded during _run_plan execution, not during discovery/export. A request carrying TMT_IMPORT_BEFORE_NAME_FILTER in its environment would still see plans skipped.

Fix (3 commits)

  1. Extract _check_accepted_environment_variables -- promote the nested closure from _run_plan to a module method (pure refactor)

  2. Restructure _run_plan env-building -- reorder the inline layering to deployment < map < request in a single pass, replacing the old apply-map / apply-request / re-apply-request pattern (pure refactor)

  3. Extract _base_tmt_process_environment helper -- the inline code from commit 2 becomes the helper body; wire it into all four call sites (_plans_from_git, _is_plan_empty, export_plan, _run_plan)

Testing

  • Added parametrized test_discovery_passes_environment_variables verifying both deployment-level and request-level variables are forwarded in all discovery/export methods (parametrized over 3 methods per module)
  • Added parametrized test_env_precedence verifying the layering order (deployment < map < request) with overlapping and non-overlapping keys (5 cases per module)
  • All 72 single-host and 67 multihost tests pass
Edited by Miroslav Vadkerti

Merge request reports

Loading