Skip to content

Commit

Permalink
twister: unify test scenario path to backslash
Browse files Browse the repository at this point in the history
Winodws user may use the `\` as path, but in twister we use the common `/`
as path separated, to avoid the mis-use, convert it to `/` in twister
first normpath, and then replace the os.sep

tested by:

For Linux Like:
west twister -p disco_l475_iot1 -s samples/hello_world/...

For Windows:
west twister -p disco_l475_iot1 -s samples\hello_world\...

fixing: #70310

Signed-off-by: Hake Huang <[email protected]>
  • Loading branch information
hakehuang authored and nashif committed Mar 26, 2024
1 parent 5a49b7c commit 7058c22
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
installed_packages = [pkg.project_name for pkg in pkg_resources.working_set] # pylint: disable=not-an-iterable
PYTEST_PLUGIN_INSTALLED = 'pytest-twister-harness' in installed_packages

def norm_path(astring):
newstring = os.path.normpath(astring).replace(os.sep, '/')
return newstring

def add_parse_arguments(parser = None):
if parser is None:
Expand Down Expand Up @@ -96,7 +99,7 @@ def add_parse_arguments(parser = None):
help="Load a list of tests and platforms to be run from file.")

case_select.add_argument(
"-T", "--testsuite-root", action="append", default=[],
"-T", "--testsuite-root", action="append", default=[], type = norm_path,
help="Base directory to recursively search for test cases. All "
"testcase.yaml files under here will be processed. May be "
"called multiple times. Defaults to the 'samples/' and "
Expand Down Expand Up @@ -209,7 +212,7 @@ def add_parse_arguments(parser = None):
and global timeout multiplier (this parameter)""")

test_xor_subtest.add_argument(
"-s", "--test", "--scenario", action="append",
"-s", "--test", "--scenario", action="append", type = norm_path,
help="Run only the specified testsuite scenario. These are named by "
"<path/relative/to/Zephyr/base/section.name.in.testcase.yaml>")

Expand Down

0 comments on commit 7058c22

Please sign in to comment.