Skip to content

Commit

Permalink
Make bench tests discoverable and skip them by default
Browse files Browse the repository at this point in the history
  • Loading branch information
naglis committed Nov 13, 2024
1 parent 4c0ed01 commit 3e38c19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 7 additions & 0 deletions aeneas/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
(val := os.getenv("UNITTEST_RUN_SLOW_TESTS")) is None or val.strip() == "0",
"slow tests are disabled. Set `UNITTEST_RUN_SLOW_TESTS=1` in the environment to enable them.",
)

EXTRA_TEST_PATH = os.path.join(os.path.expanduser("~"), ".aeneas.conf")
extra_test = unittest.skipIf(
not os.path.isfile(EXTRA_TEST_PATH),
f"extra tests are disabled (path {EXTRA_TEST_PATH!r} does not exist).",
)

BENCH_DIR = os.path.join(os.path.expanduser("~"), ".aeneas", "benchmark_input")
bench_test = unittest.skipIf(
not os.path.isdir(BENCH_DIR),
f"bench tests are disabled (directory {BENCH_DIR!r} does not exist).",
)


class ExecuteCLICase(unittest.TestCase):
CLI_CLS: typing.ClassVar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@
import tempfile

from aeneas.tools.execute_task import ExecuteTaskCLI
from aeneas.tests.common import BENCH_DIR, bench_test


BENCH_DIR = os.path.join(os.path.expanduser("~"), ".aeneas", "benchmark_input")
BENCH_TESTS = os.path.exists(BENCH_DIR)


@bench_test
class TestBenchmarkExecuteTaskCLI(unittest.TestCase):
def bench_execute(self, parameters, expected_exit_code, timeout):
if not BENCH_TESTS:
return
args = (parameters, expected_exit_code)
p = multiprocessing.Process(target=self.execute, name="funcExecute", args=args)
p.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@
import tempfile

from aeneas.tools.execute_task import ExecuteTaskCLI
from aeneas.tests.common import BENCH_DIR, bench_test


BENCH_DIR = os.path.join(os.path.expanduser("~"), ".aeneas", "benchmark_input")
BENCH_TESTS = os.path.exists(BENCH_DIR)


@bench_test
class TestBenchmarkExecuteTaskCLI(unittest.TestCase):
def bench_execute(self, parameters, expected_exit_code, timeout):
if not BENCH_TESTS:
return
args = (parameters, expected_exit_code)
p = multiprocessing.Process(target=self.execute, name="funcExecute", args=args)
p.start()
Expand Down

0 comments on commit 3e38c19

Please sign in to comment.