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 committed Nov 27, 2023
1 parent 2e8d5ab commit eb87b9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 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
7 changes: 6 additions & 1 deletion fluster/fluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,14 @@ def __init__(
f" * output_dir: {self.output_dir}"
)

def _walk_test_suite_dir(self):
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 @@ -158,7 +158,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 eb87b9d

Please sign in to comment.