Skip to content

Commit 95b28d5

Browse files
committed
More clean up
1 parent e6e5a6e commit 95b28d5

4 files changed

Lines changed: 15 additions & 56 deletions

File tree

src/software/gameplay_tests/fixture.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,8 @@
3636

3737
LAUNCH_DELAY_S = 0.1
3838

39+
# The test-mode session bound to the currently running test
3940
ACTIVE_SESSION = None
40-
"""The test-mode session bound to the currently running test, or None.
41-
42-
Set by the test-mode launcher (software.gameplay_tests.test_mode) while a
43-
selected test runs, so that gameplay_test_runner binds the test to the open
44-
Thunderscope instead of launching new binaries.
45-
"""
4641

4742

4843
@dataclass
@@ -56,17 +51,12 @@ class SessionContext:
5651
blue_full_system_proto_unix_io: ProtoUnixIO
5752
yellow_full_system_proto_unix_io: ProtoUnixIO
5853
simulator_proto_unix_io: ProtoUnixIO
59-
gamecontroller: Any
60-
robot_communication: Optional[Any] = None
61-
"""The RobotCommunication instance, only set for field tests"""
62-
estop_mode: Optional[Any] = None
63-
"""The EstopMode, only set for field tests"""
64-
simulator: Optional[Any] = None
65-
"""The Simulator context manager, only set for simulated tests"""
66-
blue_full_system: Optional[Any] = None
67-
"""The blue FullSystem context manager, only set for simulated tests"""
68-
yellow_full_system: Optional[Any] = None
69-
"""The yellow FullSystem context manager, only set for simulated tests"""
54+
gamecontroller: Gamecontroller
55+
robot_communication: Optional[RobotCommunication] = None
56+
estop_mode: Optional[EstopMode] = None
57+
simulator: Optional[Simulator] = None
58+
blue_full_system: Optional[FullSystem] = None
59+
yellow_full_system: Optional[FullSystem] = None
7060

7161

7262
@pytest.fixture
@@ -174,9 +164,7 @@ def simulated_session(args, runtime_subpath):
174164
should_restart_on_crash=False,
175165
running_in_realtime=args.enable_thunderscope and not args.ci_mode,
176166
) as yellow_fs,
177-
Gamecontroller(
178-
suppress_logs=(not args.show_gamecontroller_logs)
179-
) as gamecontroller,
167+
Gamecontroller(suppress_logs=(not args.verbose)) as gamecontroller,
180168
):
181169
blue_fs.setup_proto_unix_io(blue_full_system_proto_unix_io)
182170
yellow_fs.setup_proto_unix_io(yellow_full_system_proto_unix_io)
@@ -189,6 +177,7 @@ def simulated_session(args, runtime_subpath):
189177
gamecontroller.setup_proto_unix_io(
190178
blue_full_system_proto_unix_io=blue_full_system_proto_unix_io,
191179
yellow_full_system_proto_unix_io=yellow_full_system_proto_unix_io,
180+
simulator_proto_unix_io=None, # None so that gamecontroller doesn't set robot limit
192181
)
193182

194183
time.sleep(LAUNCH_DELAY_S)
@@ -240,7 +229,7 @@ def field_session(args, runtime_subpath):
240229
) as friendly_fs,
241230
Gamecontroller(
242231
# we would be using conventional port if and only if we are playing in robocup.
243-
suppress_logs=(not args.show_gamecontroller_logs),
232+
suppress_logs=(not args.verbose),
244233
use_conventional_port=False,
245234
) as gamecontroller,
246235
WifiCommunicationManager(

src/software/gameplay_tests/test_mode.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import argparse
1+
import copy
22
import threading
33
from dataclasses import dataclass, field
44

@@ -16,7 +16,6 @@
1616
logger = create_logger(__name__)
1717

1818
TEST_MODE_RUNTIME_SUBPATH = "test_mode"
19-
"""Fixed runtime subdirectory used for the long-lived test-mode binaries"""
2019

2120

2221
@dataclass
@@ -109,42 +108,14 @@ def run_selected_test(session: TestModeSession, test_path: str) -> str:
109108
return collector.summary(exit_code)
110109

111110

112-
def _build_test_args(main_args) -> argparse.Namespace:
113-
"""Builds a gameplay-test args namespace from thunderscope_main's arguments.
114-
115-
Maps the subset of test-mode-relevant flags onto the namespace expected by
116-
the session context managers and runners.
117-
118-
:param main_args: parsed thunderscope_main command-line arguments.
119-
:return: a Namespace compatible with the session context managers.
120-
"""
121-
return argparse.Namespace(
122-
run_field_test=main_args.run_field_test,
123-
simulator_runtime_dir=main_args.simulator_runtime_dir,
124-
blue_full_system_runtime_dir=main_args.blue_full_system_runtime_dir,
125-
yellow_full_system_runtime_dir=main_args.yellow_full_system_runtime_dir,
126-
debug_simulator=main_args.debug_simulator,
127-
debug_blue_full_system=main_args.debug_blue_full_system,
128-
debug_yellow_full_system=main_args.debug_yellow_full_system,
129-
enable_realism=main_args.enable_realism,
130-
enable_thunderscope=True,
131-
ci_mode=main_args.ci_mode,
132-
show_gamecontroller_logs=main_args.verbose,
133-
run_yellow=main_args.run_yellow,
134-
channel=main_args.channel,
135-
interface=main_args.interface,
136-
keyboard_estop=main_args.keyboard_estop,
137-
disable_communication=main_args.disable_communication,
138-
layout=main_args.layout,
139-
)
140-
141-
142111
def launch_test_mode(main_args) -> None:
143112
"""Launches Thunderscope in test mode and runs the Qt event loop.
144113
145114
:param main_args: parsed thunderscope_main command-line arguments.
146115
"""
147-
args = _build_test_args(main_args)
116+
args = copy.copy(main_args)
117+
args.enable_thunderscope = True
118+
148119
tests = discover_tests()
149120

150121
session_cm = (

src/software/gameplay_tests/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def load_command_line_arguments(allow_unrecognized: bool = False):
105105
help="Debug yellow full_system",
106106
)
107107
general_group.add_argument(
108-
"--show_gamecontroller_logs",
108+
"--verbose",
109109
action="store_true",
110110
default=False,
111111
help="Show gamecontroller logs",

src/software/thunderscope/test_runner_widget.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class TestRunnerWidget(QWidget):
1919
"""
2020

2121
__run_finished_signal = pyqtSignal(str)
22-
"""Carries a finished run's status string onto the main (Qt) thread."""
2322

2423
def __init__(
2524
self,

0 commit comments

Comments
 (0)