Skip to content

Commit

Permalink
Allow test_suites to be stored under a system directory
Browse files Browse the repository at this point in the history
When distributing the tool, we need to store the the test
suites under a system directory. Look for a local test_suites
directory first and if it doesn't exist, fallback to looking
under the system directory for the test suites.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
  • Loading branch information
obbardc authored and mdimopoulos committed Dec 27, 2022
1 parent 1bfcfe2 commit a22f609
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fluster/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from fluster.fluster import Fluster, Context, SummaryFormat

TEST_SUITES_DIR = "test_suites"
TEST_SUITES_DIR_SYS = "/usr/share/fluster/test_suites"
DECODERS_DIR = "decoders"
RESOURCES_DIR = "resources"
RESULTS_DIR = "results"
Expand All @@ -45,6 +46,15 @@ class Main:

def __init__(self) -> None:
self.decoders_dir = DECODERS_DIR
self.test_suites_dir = TEST_SUITES_DIR
# Only use the system directory for test suites if the local directory
# doesn't exist and the system directory does exist.
if (
sys.platform.startswith("linux")
and not os.path.exists(TEST_SUITES_DIR)
and os.path.exists(TEST_SUITES_DIR_SYS)
):
self.test_suites_dir = TEST_SUITES_DIR_SYS
self.parser = self._create_parser()

# Prepend to the PATH the decoders_dir so that we can run them
Expand Down Expand Up @@ -110,7 +120,7 @@ def _create_parser(self) -> argparse.ArgumentParser:
"-tsd",
"--test-suites-dir",
help="set the directory where test suite will be read from",
default=TEST_SUITES_DIR,
default=self.test_suites_dir,
)
subparsers = parser.add_subparsers(title="subcommands")
self._add_list_cmd(subparsers)
Expand Down

0 comments on commit a22f609

Please sign in to comment.