mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user