Skip to content

Commit

Permalink
tanco test [names]: run only given tests by name
Browse files Browse the repository at this point in the history
  • Loading branch information
tangentstorm committed Feb 14, 2024
1 parent 7169b37 commit 4e98f34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tanco/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ async def bind():
@staticmethod
def do_test(arg):
"""Run the tests."""
runner.main(['tanco']+[x for x in arg.split(' ') if x != ''])
runner.main([x for x in arg.split(' ') if x != ''])

@staticmethod
def do_q(_arg):
Expand Down
9 changes: 5 additions & 4 deletions tanco/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ def get_challenge(cfg: Config) -> Challenge:
raise NoTestPlanError


def run_tests(cfg: Config):
def run_tests(cfg: Config, names=None):
num_passed = 0
challenge = get_challenge(cfg)
tests = challenge.tests
try:
for i, test in enumerate(tests):
if names and test.name not in names: continue
program = spawn(cfg)
run_test(cfg, program, test)
# either it passed or threw exception
Expand Down Expand Up @@ -289,10 +290,10 @@ def handle_unexpected_error(cfg: Config):
' https://github.com/tangentcode/tanco/issues'])


def main(argv: list[str]):
cfg = get_custom_cfg(argv)
def main(names: list[str]):
cfg = load_config()
try:
run_tests(cfg)
run_tests(cfg, names)
except NoTestPlanError:
error(cfg, ['No challenge selected.'
'Use `tanco init` or set TEST_PLAN environment variable.'])
Expand Down

0 comments on commit 4e98f34

Please sign in to comment.