|
6 | 6 | from pathlib import Path |
7 | 7 | from typing import List, Optional |
8 | 8 |
|
| 9 | +import click |
| 10 | + |
9 | 11 | from goal.git_ops import run_command |
10 | 12 | from goal.cli.version import PROJECT_TYPES |
11 | 13 | from goal.project_bootstrap import _find_python_bin |
@@ -93,8 +95,25 @@ def _run_subdir_test(project_type: str, base_cmd: List[str], test_dir: str) -> b |
93 | 95 | result = subprocess.run(base_cmd + [test_dir], capture_output=True, text=True, timeout=120) |
94 | 96 | else: |
95 | 97 | result = subprocess.run(base_cmd, cwd=test_dir, capture_output=True, text=True, timeout=120) |
96 | | - return result.returncode == 0 |
97 | | - except Exception: |
| 98 | + if result.returncode != 0: |
| 99 | + click.echo(click.style(f"\n ❌ Tests failed in {test_dir}/", fg='red')) |
| 100 | + if result.stdout: |
| 101 | + click.echo(click.style(" stdout:", fg='yellow')) |
| 102 | + for line in result.stdout.strip().split('\n')[:10]: |
| 103 | + click.echo(f" {line}") |
| 104 | + if result.stderr: |
| 105 | + click.echo(click.style(" stderr:", fg='yellow')) |
| 106 | + for line in result.stderr.strip().split('\n')[:10]: |
| 107 | + click.echo(f" {line}") |
| 108 | + if project_type == 'nodejs': |
| 109 | + if not (Path(test_dir) / 'node_modules').exists(): |
| 110 | + click.echo(click.style(f"\n 💡 Fix: cd {test_dir} && npm install", fg='cyan')) |
| 111 | + elif 'Cannot find module' in (result.stderr or ''): |
| 112 | + click.echo(click.style(f"\n 💡 Fix: cd {test_dir} && npm run compile", fg='cyan')) |
| 113 | + return False |
| 114 | + return True |
| 115 | + except Exception as e: |
| 116 | + click.echo(click.style(f"\n ❌ Error running tests in {test_dir}/: {e}", fg='red')) |
98 | 117 | return False |
99 | 118 |
|
100 | 119 |
|
|
0 commit comments