mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
integration tests: add --force-color & set in CI
github actions supports color output, but does not report as a tty. See https://github.com/actions/runner/issues/241.
This commit is contained in:
parent
abb80ae71e
commit
3d6056411f
2
.github/workflows/ros_integration_tests.yml
vendored
2
.github/workflows/ros_integration_tests.yml
vendored
@ -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
|
||||
|
||||
|
||||
2
.github/workflows/sitl_tests.yml
vendored
2
.github/workflows/sitl_tests.yml
vendored
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user