diff --git a/gpt_engineer/tools/supported_languages.py b/gpt_engineer/tools/supported_languages.py index 5f6ba90177..7644540ca2 100644 --- a/gpt_engineer/tools/supported_languages.py +++ b/gpt_engineer/tools/supported_languages.py @@ -47,7 +47,8 @@ "tree_sitter_name": "cpp", }, {"name": "C", "extensions": [".c", ".h"], "tree_sitter_name": "c"}, - {"name": "Markdown", "extensions": [".md"], "tree_sitter_name": "md"} + {"name": "Markdown", "extensions": [".md"], "tree_sitter_name": "md"}, + {"name": "Arduino C", "extensions": [".ino"], "tree_sitter_name": "ino"} # ---- the following are not supported by the current code chunker implementation ---- # { # "name": "Swift", diff --git a/tests/applications/cli/test_main.py b/tests/applications/cli/test_main.py index 1c33e7f3c9..ca9364872c 100644 --- a/tests/applications/cli/test_main.py +++ b/tests/applications/cli/test_main.py @@ -92,6 +92,21 @@ def test_improve_existing_project(self, tmp_path, monkeypatch): ) args() + # Runs gpt-engineer with improve mode and improves an existing project in the specified path, with skip_file_selection + def test_improve_existing_project_skip_file_selection(self, tmp_path, monkeypatch): + p = tmp_path / "projects/example" + p.mkdir(parents=True) + (p / "prompt").write_text(prompt_text) + args = DefaultArgumentsMain( + str(p), + improve_mode=True, + llm_via_clipboard=True, + no_execution=True, + skip_file_selection=True, + ) + args() + assert args.skip_file_selection, "Skip_file_selection not set" + # def improve_generator(): # yield "y" # while True: diff --git a/tests/core/test_file_selector_enhancements.py b/tests/core/test_file_selector_enhancements.py new file mode 100644 index 0000000000..a5de0a6f38 --- /dev/null +++ b/tests/core/test_file_selector_enhancements.py @@ -0,0 +1,59 @@ +import os + +from pathlib import Path +from typing import List, Union + +from gpt_engineer.applications.cli.file_selector import FileSelector + +editorcalled = False + + +def set_editor_called( + self, input_path: Union[str, Path], init: bool = True +) -> List[str]: + global editorcalled + editorcalled = True + return [] + + +def set_file_selector_tmpproject(tmp_path): + project_path = tmp_path / "project/" + os.mkdir(project_path) + os.mkdir(project_path / "x") + os.mkdir(project_path / "a") + + gpteng_path = project_path / ".gpteng" + os.mkdir(gpteng_path) + + with open(gpteng_path / "file_selection.toml", "w") as file: + file.write("[files]\n") + file.write(' "x/xxtest.py" = "selected"\n') + file.write(' "a/aatest.py" = "selected"\n') + + with open(project_path / "x/xxtest.py", "w") as file: + file.write('print("Hello")') + + with open(project_path / "a/aatest.py", "w") as file: + file.write('print("Hello")') + + return project_path + + +def test_file_selector_enhancement_skip_file_selector(tmp_path): + project_path = set_file_selector_tmpproject(tmp_path) + fileSelector = FileSelector(project_path=project_path) + fileSelector.editor_file_selector = set_editor_called + fileSelector.ask_for_files(skip_file_selection=True) + + assert editorcalled is False, "FileSelector.skip_file_selector is not working" + + +def test_file_selector_enhancement_sort(tmp_path): + project_path = set_file_selector_tmpproject(tmp_path) + fileSelector = FileSelector(project_path=project_path) + + sortedFiles = fileSelector.get_current_files(project_path) + assert sortedFiles == [ + "a/aatest.py", + "x/xxtest.py", + ], "FileSelector.get_current_files is unsorted!"