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:
-
Deployment-level variables like
TMT_IMPORT_BEFORE_NAME_FILTERwere missing during plan discovery, leading to plans imported withscope: all-plans/importing: become-parentbeing incorrectly skipped as "empty" (thetmt run discover plan --nameprobe failed to resolve them without import-before-name-filter). -
Request-level
tmt.environmentvariables were only forwarded during_run_planexecution, not during discovery/export. A request carryingTMT_IMPORT_BEFORE_NAME_FILTERin its environment would still see plans skipped.
Fix (3 commits)
-
Extract
_check_accepted_environment_variables-- promote the nested closure from_run_planto a module method (pure refactor) -
Restructure
_run_planenv-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) -
Extract
_base_tmt_process_environmenthelper -- 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_variablesverifying both deployment-level and request-level variables are forwarded in all discovery/export methods (parametrized over 3 methods per module) - Added parametrized
test_env_precedenceverifying 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