Skip to content

Commit 2b902cd

Browse files
authored
Merge pull request #8 from tangentcode/claude/fix-missing-tests-error-018TyDPREfP66fVm9F3sL5Pz
fix missing tests error
2 parents 0532d4a + cb204e8 commit 2b902cd

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

tanco/driver.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,19 @@ def do_test(arg):
465465
except runner.NoTestPlanError:
466466
runner.error(cfg, ['No challenge selected.',
467467
'Use `tanco init`, `tanco test -t file.org`, or set TEST_PLAN environment variable.'])
468+
except runner.NoTestsFoundError as e:
469+
runner.error(cfg, [str(e),
470+
'',
471+
'For org files, tests should be defined using:',
472+
' ** TEST testname : title',
473+
' #+begin_src',
474+
' > input line',
475+
' expected output',
476+
' #+end_src'])
477+
except FileNotFoundError as e:
478+
runner.error(cfg, [f'Test file not found: {e.filename}',
479+
'',
480+
'Make sure the path is correct and the file exists.'])
468481
except runner.StopTesting:
469482
pass
470483
except Exception:
@@ -531,8 +544,21 @@ def do_run(self, arg):
531544
runner.run_tests(cfg)
532545
except runner.NoTestPlanError:
533546
print("No tests specified. Use --tests PATH or ensure you're in a tanco project.")
547+
except runner.NoTestsFoundError as e:
548+
print(str(e))
549+
print()
550+
print('For org files, tests should be defined using:')
551+
print(' ** TEST testname : title')
552+
print(' #+begin_src')
553+
print(' > input line')
554+
print(' expected output')
555+
print(' #+end_src')
556+
except FileNotFoundError as e:
557+
print(f'Test file not found: {e.filename}')
558+
print()
559+
print('Make sure the path is correct and the file exists.')
534560
except runner.StopTesting:
535-
pass # Normal exit after test failure
561+
pass # Normal exit after test failure
536562
except Exception:
537563
# handle_unexpected_error already prints traceback
538564
runner.handle_unexpected_error(cfg)

tanco/runner.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class NoTestPlanError(Exception):
9494
pass
9595

9696

97+
class NoTestsFoundError(Exception):
98+
"""Raised when a test source exists but contains no tests."""
99+
100+
97101
class StopTesting(Exception):
98102
pass
99103

@@ -354,6 +358,14 @@ def run_tests(cfg: Config, names=None):
354358
challenge = get_challenge(cfg)
355359
tests = challenge.tests
356360

361+
# Check for empty tests list
362+
if not tests:
363+
source = cfg.test_path or cfg.test_plan or 'database'
364+
raise NoTestsFoundError(
365+
f'No tests found in {source}. '
366+
'Make sure the file contains valid test definitions.',
367+
)
368+
357369
# Use persistent process mode if restart_cmd is configured
358370
if cfg.restart_cmd and cfg.restart_expect:
359371
run_tests_persistent(cfg, tests, names)
@@ -502,8 +514,21 @@ def main(names: list[str]):
502514
try:
503515
run_tests(cfg, names)
504516
except NoTestPlanError:
505-
error(cfg, ['No challenge selected.'
517+
error(cfg, ['No challenge selected.',
506518
'Use `tanco init` or set TEST_PLAN environment variable.'])
519+
except NoTestsFoundError as e:
520+
error(cfg, [str(e),
521+
'',
522+
'For org files, tests should be defined using:',
523+
' ** TEST testname : title',
524+
' #+begin_src',
525+
' > input line',
526+
' expected output',
527+
' #+end_src'])
528+
except FileNotFoundError as e:
529+
error(cfg, [f'Test file not found: {e.filename}',
530+
'',
531+
'Make sure the path is correct and the file exists.'])
507532
except StopTesting:
508533
pass
509534
except Exception:

0 commit comments

Comments
 (0)