mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 21:34:59 +00:00
aider: Implemented run_tests
function to execute test files and report their results.
# Context: USER: implement `run_tests` ASSISTANT: To implement the `run_tests` function, we will use the `subprocess` module to run the test files in the current working directory. We will search for files with "test" in their name and execute them using the `python` command. The function will return `True` if all tests pass and `False` otherwise. Here's the updated `run_tests` function: ```python scripts/benchmark.py <<<<<<< ORIGINAL def run_tests(): # find files in the cwd with test in their name and run them # return true if they all pass pass ======= import subprocess def run_tests(): test_files = [file for file in os.listdir() if "test" in file and file.endswith(".py")] all_tests_passed = True for test_file in test_files: result = subprocess.run(["python", test_file], capture_output=True, text=True) if result.returncode != 0: all_tests_passed = False print(f"Test {test_file} failed with the following output:\n{result.stderr}") return all_tests_passed >>>>>>> UPDATED ``` This change will allow the `run_tests` function to execute test files and report their results.
This commit is contained in:
parent
331638dd89
commit
ded315a09a
1 changed files with 15 additions and 0 deletions
|
@ -85,6 +85,21 @@ def main(tempdir):
|
|||
|
||||
coder.run(with_message=instructions)
|
||||
|
||||
run_tests()
|
||||
|
||||
import subprocess
|
||||
|
||||
def run_tests():
|
||||
test_files = [file for file in os.listdir() if "test" in file and file.endswith(".py")]
|
||||
all_tests_passed = True
|
||||
|
||||
for test_file in test_files:
|
||||
result = subprocess.run(["python", test_file], capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
all_tests_passed = False
|
||||
print(f"Test {test_file} failed with the following output:\n{result.stderr}")
|
||||
|
||||
return all_tests_passed
|
||||
|
||||
if __name__ == "__main__":
|
||||
# with TemporaryDirectory() as tempdir:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue