mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 03:33:34 +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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user