diff --git a/.github/workflows/ros_integration_tests.yml b/.github/workflows/ros_integration_tests.yml index c969891d9d..af1587a071 100644 --- a/.github/workflows/ros_integration_tests.yml +++ b/.github/workflows/ros_integration_tests.yml @@ -91,6 +91,6 @@ jobs: run: | . /opt/px4_ws/install/setup.bash /opt/Micro-XRCE-DDS-Agent/build/MicroXRCEAgent udp4 localhost -p 8888 -v 0 & - test/ros_test_runner.py --verbose --model iris --upload + test/ros_test_runner.py --verbose --model iris --upload --force-color timeout-minutes: 45 diff --git a/.github/workflows/sitl_tests.yml b/.github/workflows/sitl_tests.yml index a2ec1c5d2d..ffd7c9ddc1 100644 --- a/.github/workflows/sitl_tests.yml +++ b/.github/workflows/sitl_tests.yml @@ -116,7 +116,7 @@ jobs: PX4_HOME_LON: ${{matrix.config.longitude}} PX4_HOME_ALT: ${{matrix.config.altitude}} PX4_CMAKE_BUILD_TYPE: ${{matrix.config.build_type}} - run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} --upload test/mavsdk_tests/configs/sitl.json --verbose + run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} --upload test/mavsdk_tests/configs/sitl.json --verbose --force-color timeout-minutes: 45 - name: Upload failed logs diff --git a/test/mavsdk_tests/integration_test_runner/logger_helper.py b/test/mavsdk_tests/integration_test_runner/logger_helper.py index 571eccf0c3..41cf086644 100644 --- a/test/mavsdk_tests/integration_test_runner/logger_helper.py +++ b/test/mavsdk_tests/integration_test_runner/logger_helper.py @@ -4,6 +4,7 @@ import os from enum import Enum from functools import lru_cache +force_color = False class color(Enum): PURPLE = '\033[95m' @@ -20,7 +21,7 @@ class color(Enum): def colorize(text: str, c: color) -> str: - if _supports_color(): + if force_color or _supports_color(): return str(c.value) + text + color.RESET.value else: return text diff --git a/test/mavsdk_tests/mavsdk_test_runner.py b/test/mavsdk_tests/mavsdk_test_runner.py index 5a62b744da..b1035b48d7 100755 --- a/test/mavsdk_tests/mavsdk_test_runner.py +++ b/test/mavsdk_tests/mavsdk_test_runner.py @@ -7,7 +7,7 @@ import psutil # type: ignore import signal import subprocess import sys -from integration_test_runner import test_runner +from integration_test_runner import test_runner, logger_helper import integration_test_runner.process_helper as ph from typing import Any, Dict, List, NoReturn @@ -70,6 +70,8 @@ def main() -> NoReturn: help="choice from valgrind, callgrind, gdb, lldb") parser.add_argument("--upload", default=False, action='store_true', help="Upload logs to logs.px4.io") + parser.add_argument("--force-color", default=False, action='store_true', + help="Force colorized output") parser.add_argument("--verbose", default=False, action='store_true', help="enable more verbose output") parser.add_argument("config_file", help="JSON config file to use") @@ -78,6 +80,9 @@ def main() -> NoReturn: help="relative path where the built files are stored") args = parser.parse_args() + if args.force_color: + logger_helper.force_color = True + with open(args.config_file) as json_file: config = json.load(json_file) diff --git a/test/ros_test_runner.py b/test/ros_test_runner.py index ad2a49a520..db8e5a913d 100755 --- a/test/ros_test_runner.py +++ b/test/ros_test_runner.py @@ -121,6 +121,8 @@ def main() -> NoReturn: help="choice from valgrind, callgrind, gdb, lldb") parser.add_argument("--upload", default=False, action='store_true', help="Upload logs to logs.px4.io") + parser.add_argument("--force-color", default=False, action='store_true', + help="Force colorized output") parser.add_argument("--verbose", default=False, action='store_true', help="enable more verbose output") parser.add_argument("--config-file", help="JSON config file to use", @@ -134,6 +136,9 @@ def main() -> NoReturn: "If not provided, it is determined via 'ros2 pkg'") args = parser.parse_args() + if args.force_color: + logger_helper.force_color = True + ros_package_build_dir = args.px4_ros2_interface_lib_build_dir if ros_package_build_dir is None: ros_package_build_dir = lookup_px4_ros2_cpp_build_dir()