tenseleyflow/bensch / 1c8e174

Browse files

fix runner: syntax error, spec-dir support, profile loading

- Fix broken candidates list from fortsh binary path removal
- Add --spec-dir argument for external spec directories
- Load profile from BENSCH_PROFILE env var
- Use rglob to find YAML specs recursively in subdirectories
- Fix duplicate -s short flag between --shell and --spec
Authored by espadonne
SHA
1c8e174730e06550ecd6b3cf3ee07fe059f0b9e2
Parents
6abcabb
Tree
45cf1dc

1 changed file

StatusFile+-
M framework/runner.py 30 16
framework/runner.pymodified
@@ -454,16 +454,10 @@ class YAMLTestRunner:
454454
 
455455
 def find_shell_binary() -> str:
456456
     """Find the shell binary."""
457
-    # Check common locations
458
-    candidates = [
459
-        # removed — bensch requires explicit --shell,
460
-        # path,
461
-        ,
462
-        ,
463
-    ]
464
-
465
-    # Also check FORTSH environment variable
466
-    env_path = os.environ.get('FORTSH')
457
+    candidates = []
458
+
459
+    # Check SHELL_BIN or SHELL environment variables
460
+    env_path = os.environ.get('SHELL_BIN') or os.environ.get('SHELL')
467461
     if env_path:
468462
         candidates.insert(0, env_path)
469463
 
@@ -516,15 +510,20 @@ def main():
516510
         description="Run interactive tests for shell"
517511
     )
518512
     parser.add_argument(
519
-        '--shell', '-s',
513
+        '--shell',
520514
         default=None,
521515
         help='Path to shell binary'
522516
     )
523517
     parser.add_argument(
524
-        '--spec', '-s',
518
+        '--spec',
525519
         default=None,
526520
         help='Run specific YAML spec file'
527521
     )
522
+    parser.add_argument(
523
+        '--spec-dir',
524
+        default=None,
525
+        help='Directory containing YAML spec subdirectories'
526
+    )
528527
     parser.add_argument(
529528
         '--pytest',
530529
         action='store_true',
@@ -562,9 +561,24 @@ def main():
562561
         test_dir = Path(__file__).parent
563562
         return pytest.main([str(test_dir), '-v' if args.verbose else '-q'])
564563
 
564
+    # Load profile if available
565
+    profile = {}
566
+    profile_name = os.environ.get('BENSCH_PROFILE', '')
567
+    if profile_name:
568
+        try:
569
+            from profile import load_profile
570
+            profile = load_profile(profile_name)
571
+        except Exception:
572
+            pass
573
+
565574
     # Run YAML specs
566
-    runner = YAMLTestRunner(shell_path, verbose=args.verbose)
567
-    test_dir = Path(__file__).parent / "test_specs"
575
+    runner = YAMLTestRunner(shell_path, verbose=args.verbose, profile=profile)
576
+
577
+    # Determine spec directory
578
+    if args.spec_dir:
579
+        test_dir = Path(args.spec_dir)
580
+    else:
581
+        test_dir = Path(__file__).parent / "test_specs"
568582
 
569583
     if args.spec:
570584
         # Run specific spec
@@ -576,9 +590,9 @@ def main():
576590
             return 1
577591
         results = runner.run_spec_file(spec_path)
578592
     else:
579
-        # Run all specs
593
+        # Run all specs (recursively find YAML files)
580594
         results = []
581
-        for spec_file in sorted(test_dir.glob("*.yaml")):
595
+        for spec_file in sorted(test_dir.rglob("*.yaml")):
582596
             results.extend(runner.run_spec_file(spec_file))
583597
 
584598
     # Print summary