Skip to content

Commit

Permalink
Use new metaprogramming for running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrw committed Dec 25, 2022
1 parent 9516589 commit 05bf662
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import subprocess as sp
import argparse
import sys


def collect_test_options(cls):

tests = []
Expand All @@ -16,6 +17,7 @@ def collect_test_options(cls):
cls._tests = tests
return cls


@collect_test_options
class TestRunner:
def __init__(self, rust_version):
Expand Down Expand Up @@ -99,16 +101,12 @@ class TestRunner:
)

def _run_test_all(self):
for attr in dir(self):
if not attr.startswith("_run_test_"):
continue

test = attr.replace("_run_test_", "").replace("_", "-")
if test == "all":
for test_name in self._tests:
if test_name == "all":
continue

print(f"Running test '{test}'")
method = getattr(self, attr)
method_name = f"_run_test_{test_name}"
method = getattr(self, method_name)
method()


Expand Down

0 comments on commit 05bf662

Please sign in to comment.