From b5529ee0649f6fdaa9d5c5087f6c8a1f13fc05c2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 12 Jun 2025 20:58:55 -0700 Subject: [PATCH] ansible-test - Fix ansible-test debug from remote shell (#85321) (cherry picked from commit 299188367278d76fb586990f0bf3a1fae72262c5) --- test/lib/ansible_test/_internal/commands/shell/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/lib/ansible_test/_internal/commands/shell/__init__.py b/test/lib/ansible_test/_internal/commands/shell/__init__.py index 550d4d13efc..dc14b1659b7 100644 --- a/test/lib/ansible_test/_internal/commands/shell/__init__.py +++ b/test/lib/ansible_test/_internal/commands/shell/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +import dataclasses import os import sys import typing as t @@ -107,6 +108,10 @@ def command_shell(args: ShellConfig) -> None: con.run(args.cmd, capture=False, interactive=False, output_stream=OutputStream.ORIGINAL) return + if isinstance(con, LocalConnection) and isinstance(target_profile, DebuggableProfile) and target_profile.debugging_enabled: + # HACK: ensure the pydevd port visible in the shell is the forwarded port, not the original + args.metadata.debugger_settings = dataclasses.replace(args.metadata.debugger_settings, port=target_profile.pydevd_port) + with metadata_context(args): interactive_shell(args, target_profile, con)