From 11fd97ec8c806aebde7b3b6f0ab6b8af28813098 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Thu, 4 Jul 2024 20:01:27 +0800 Subject: [PATCH] runtests.py: parse the command line with shelx Signed-off-by: Yi Sun --- BM/runtests.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BM/runtests.py b/BM/runtests.py index 5812367..36c2dc2 100755 --- a/BM/runtests.py +++ b/BM/runtests.py @@ -3,6 +3,7 @@ import subprocess import argparse import os +import shlex from avocado.core.job import Job from avocado.core.nrunner.runnable import Runnable from avocado.core.suite import TestSuite @@ -67,13 +68,20 @@ def create_runnables_from_file(ftests): # Handle empty lines and comments. if not line.strip() or line.startswith('#'): continue + # Split command line parameters. - parts = line.strip().split() - # Create a Runnable object. - runnable = Runnable("exec-test", parts[0], *parts[1:]) + parts = parse_cmd_str(line.strip()) + runnable = Runnable("exec-test", *parts) tests.append(runnable) + return tests +def parse_cmd_str(cmd): + lexer = shlex.shlex(cmd, posix=True) + lexer.whitespace_split = True + lexer.whitespace = ' ' + return list(lexer) + def main(): # Get the absolute directory of the tests file. tests_abs = os.path.abspath(args.tests)