mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
feat: Read config.json, copy solution/test files, no fallback
This commit is contained in:
parent
1493b8703f
commit
03aa22ba84
1 changed files with 33 additions and 12 deletions
|
@ -595,21 +595,42 @@ def run_test_real(
|
||||||
print(f"{results_fname} failed to parse, skipping")
|
print(f"{results_fname} failed to parse, skipping")
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO
|
# Read solution and test files from config
|
||||||
fnames = []
|
fnames = []
|
||||||
for fname in testdir.glob("*"):
|
config_file = testdir / ".meta/config.json"
|
||||||
if (
|
if not config_file.exists():
|
||||||
"test" not in fname.name
|
raise ValueError(f"No config file found: {config_file}")
|
||||||
and fname.is_file()
|
|
||||||
and fname.name[0] != "."
|
|
||||||
and fname.suffix == ".py"
|
|
||||||
):
|
|
||||||
fnames.append(fname)
|
|
||||||
|
|
||||||
|
with open(config_file) as f:
|
||||||
|
config = json.loads(f.read())
|
||||||
|
|
||||||
|
# Get solution and test files from config
|
||||||
|
solution_files = config.get("files", {}).get("solution", [])
|
||||||
|
test_files = config.get("files", {}).get("test", [])
|
||||||
|
|
||||||
|
# Copy all solution files
|
||||||
|
for file_path in solution_files:
|
||||||
|
src = testdir / Path(file_path)
|
||||||
|
if src.exists():
|
||||||
|
fnames.append(src)
|
||||||
# restore the original file, in case we interrupted a prev run
|
# restore the original file, in case we interrupted a prev run
|
||||||
# after it had saved changes
|
original_fname = original_dname / testdir.name / file_path
|
||||||
original_fname = original_dname / testdir.name / fname.name
|
if original_fname.exists():
|
||||||
shutil.copy(original_fname, fname)
|
os.makedirs(src.parent, exist_ok=True)
|
||||||
|
shutil.copy(original_fname, src)
|
||||||
|
else:
|
||||||
|
print(f"Warning: Solution file not found: {src}")
|
||||||
|
|
||||||
|
# Copy all test files
|
||||||
|
for file_path in test_files:
|
||||||
|
src = testdir / Path(file_path)
|
||||||
|
if src.exists():
|
||||||
|
original_fname = original_dname / testdir.name / file_path
|
||||||
|
if original_fname.exists():
|
||||||
|
os.makedirs(src.parent, exist_ok=True)
|
||||||
|
shutil.copy(original_fname, src)
|
||||||
|
else:
|
||||||
|
print(f"Warning: Test file not found: {src}")
|
||||||
|
|
||||||
file_list = " ".join(fname.name for fname in fnames)
|
file_list = " ".join(fname.name for fname in fnames)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue