mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
refactor: Use dict for test commands based on file extensions
This commit is contained in:
parent
f36f2fdea2
commit
c4c135e678
1 changed files with 21 additions and 3 deletions
|
@ -789,9 +789,27 @@ def run_test_real(
|
||||||
def run_unit_tests(testdir, history_fname, test_files):
|
def run_unit_tests(testdir, history_fname, test_files):
|
||||||
timeout = 60
|
timeout = 60
|
||||||
|
|
||||||
# Choose test command based on test file extensions
|
# Map of file extensions to test commands
|
||||||
is_rust = any(Path(f).suffix == ".rs" for f in test_files)
|
TEST_COMMANDS = {
|
||||||
command = "cargo test -- --include-ignored".split() if is_rust else ["pytest"]
|
'.py': ['pytest'],
|
||||||
|
'.rs': ['cargo', 'test', '--', '--include-ignored'],
|
||||||
|
'.cs': ['dotnet', 'test'],
|
||||||
|
'.go': ['go', 'test', './...'],
|
||||||
|
'.js': ['npm', 'test'],
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get unique file extensions from test files
|
||||||
|
extensions = {Path(f).suffix for f in test_files}
|
||||||
|
|
||||||
|
# Find matching test command
|
||||||
|
command = None
|
||||||
|
for ext in extensions:
|
||||||
|
if ext in TEST_COMMANDS:
|
||||||
|
command = TEST_COMMANDS[ext]
|
||||||
|
break
|
||||||
|
|
||||||
|
if not command:
|
||||||
|
raise ValueError(f"No test command found for files with extensions: {extensions}")
|
||||||
print(" ".join(command))
|
print(" ".join(command))
|
||||||
|
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue