Skip to content

Commit

Permalink
test-suites-dir: Allow multiple dirs with OS path separator
Browse files Browse the repository at this point in the history
Allowing multiple directories allows the creation of private test
suites. Implemented using OS path separator (`os.pathsep`). For
instance, on Linux:

```
python3 ./fluster.py -tsd "/opt/fluster_tsd:/opt/priv_f_tsd" list
```
  • Loading branch information
rubenrua authored and rgonzalezfluendo committed Nov 29, 2023
1 parent 9c70053 commit 9e37ae0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ optional arguments:
set the directory where decoder outputs will be stored
-ne, --no-emoji set to use plain text instead of emojis
-tsd TEST_SUITES_DIR, --test-suites-dir TEST_SUITES_DIR
set the directory where test suite will be read from
set directory where test suite will be read from, multiple directories are supported with OS path separator (:)

subcommands:
{list,l,run,r,download,d,reference,f}
Expand Down
9 changes: 7 additions & 2 deletions fluster/fluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
import os.path
from functools import lru_cache
from typing import List, Dict, Any, Tuple, Optional
from typing import List, Dict, Any, Tuple, Optional, Iterator
import sys
from enum import Enum
from shutil import rmtree
Expand Down Expand Up @@ -161,9 +161,14 @@ def __init__(
f" * output_dir: {self.output_dir}"
)

def _walk_test_suite_dir(self) -> Iterator[Tuple[str, List[str], List[str]]]:
for test_suite_dir in self.test_suites_dir.split(os.pathsep):
for root, dirnames, files in os.walk(test_suite_dir):
yield (root, dirnames, files)

@lru_cache(maxsize=128)
def _load_test_suites(self) -> None:
for root, _, files in os.walk(self.test_suites_dir):
for root, _, files in self._walk_test_suite_dir():
for file in files:
if os.path.splitext(file)[1] == ".json":
try:
Expand Down
5 changes: 4 additions & 1 deletion fluster/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ def _create_parser(self) -> argparse.ArgumentParser:
parser.add_argument(
"-tsd",
"--test-suites-dir",
help="set the directory where test suite will be read from",
help=(
"set directory where test suite will be read from, "
f"multiple directories are supported with OS path separator ({os.pathsep})"
),
default=self.test_suites_dir,
)
subparsers = parser.add_subparsers(title="subcommands")
Expand Down

0 comments on commit 9e37ae0

Please sign in to comment.