Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
49d06ad
add PyTest framework
WangGLJoseph Mar 6, 2025
280c6e7
update pytest yml
WangGLJoseph Mar 6, 2025
c9e6b53
update CI
Mar 6, 2025
4a66b6a
activate workflow
Mar 6, 2025
5cf1881
fix branch name
Mar 6, 2025
150ae70
add missing checkout
Mar 6, 2025
6a752f1
Merge branch 'main' into pytest-ci
Mar 6, 2025
b594195
add correct docker command
Mar 6, 2025
63bea68
add sonar source files
Mar 6, 2025
5c6bdc7
output converage to both term and xml
Mar 6, 2025
757cf93
use acr-pytest for container name
Mar 6, 2025
830de0f
Update pytest.yml
Marti2203 Mar 6, 2025
78a89bf
Update sonar-project.properties
Marti2203 Mar 6, 2025
8a685f6
sonar fix and update sonar exclusions
Mar 10, 2025
b1ebfb1
add coverage file path
Mar 11, 2025
3292ab3
reduce code duplication
Mar 11, 2025
fab4c16
add temp dir in workflow for coverage report
Mar 11, 2025
26a154f
update sonar config
Mar 11, 2025
a9535b9
use tox and pytest outside container
Mar 11, 2025
f069337
add missing tox.ini file
Mar 11, 2025
19a8418
separate pytest and build workflow
Mar 11, 2025
e93d76d
fix conda env name in workflow
Mar 11, 2025
989ffc5
update shell to use login mode for pytest workflow
Mar 11, 2025
8e6ac78
update conda config
Mar 11, 2025
301dd26
set PYTHONPATH inside tox.ini
Mar 11, 2025
9b041ff
update tox.ini
Mar 11, 2025
56550c4
include Coverage.py in tox
Mar 11, 2025
598a5e6
add passenv to tox
Mar 11, 2025
86a1c22
change build yaml to only run on PR merge
Mar 11, 2025
6719301
remove redundant deps in tox.ini
Mar 11, 2025
a9a804c
abort Sonarqube Scan if coverage.xml is missing
Mar 11, 2025
2d1c671
specify source and test files for sonar
Mar 11, 2025
f531635
add test_search_utils
Mar 11, 2025
4d06ba8
change build to docker_build
Mar 11, 2025
53b7aa3
Merge branch 'main' into pytest-ci
Mar 12, 2025
c1d7a1a
update tox usage in workflow and documentation
Mar 12, 2025
26cf273
add test for search_utils.py
Mar 12, 2025
bc6fa09
fix get_code_region_around_line
Mar 12, 2025
62bd169
update testcase (need to clarify class signature)
Mar 12, 2025
2d9a5fb
fix sonar issues and update README
Mar 12, 2025
9adf8e9
add empty test files for search subdir
Mar 12, 2025
001a354
add testcase for internal methods of SearchBackend
Mar 12, 2025
da9d622
Merge branch 'pytest-unit' into pytest-ci
Mar 12, 2025
3212f7e
update tox.ini for more accurate coverage percentage
Mar 12, 2025
a95c2ff
fix test_search_utils
Mar 13, 2025
d440a14
add tests and add `converage` to whitelist for tox testenv
Mar 13, 2025
d7fccde
update test cases
Mar 13, 2025
54d5fab
update test_saerch_backend
Mar 13, 2025
119e5b7
add testcases for search subdir
Mar 13, 2025
91dbdd2
update TESTING.md with setup instructions for adding `conda-forge`
Mar 13, 2025
527c889
update tox.ini
Mar 13, 2025
d410126
add empty test files for api subdir
Mar 13, 2025
7905a2c
implement fix from PR #81
WangGLJoseph Mar 13, 2025
d3fee77
Fake error
Marti2203 Mar 13, 2025
3600af3
Fix failing test
Marti2203 Mar 13, 2025
7acfa05
Fix fake error and add new one
Marti2203 Mar 13, 2025
d06e4e7
Update app/data_structures.py
Marti2203 Mar 13, 2025
ff7eb3b
update readme
Mar 14, 2025
1eb0bfb
improve coverage of search_manage.py
Mar 14, 2025
deee4aa
improve coverage for search_utils
Mar 14, 2025
f2d9d08
show only analysis cov
Mar 14, 2025
a58abf4
add empty test_sbfl
Mar 14, 2025
3abd273
remove redundant import stmts
Mar 14, 2025
77dba68
add test cases for sbfl.py
Mar 14, 2025
6714466
Merge branch 'pytest-ci' into pytest-unit
Mar 14, 2025
654acc4
run actions on pytest-unit branch
Mar 14, 2025
7ecd806
add testing for api/validation.py
Mar 14, 2025
3f81a68
refactor common test utils and make it a package, add test cases
Mar 14, 2025
5e050ac
ensure coverage on new code
Mar 14, 2025
f84ed47
add test cases for api/eval_helper.py
Mar 14, 2025
d419e68
enable printing branch coverage on CI
Mar 14, 2025
00a78d2
cover some missing branches in search_backend
Mar 14, 2025
2e1a6a1
complete coverage for search/search_backend.py
Mar 14, 2025
f78c8c8
remove redundant collection
Mar 17, 2025
e1b0272
add test for gpt.py
Mar 17, 2025
0dc92b7
update test for catching BadRequestError
Mar 17, 2025
507cc10
disable pytest output capturing to show stdout
Mar 17, 2025
b1dbf66
improve coverage of test_gpt.py
Mar 17, 2025
1769a89
refactor common test code to pytest_utils
Mar 18, 2025
7ff780f
add unit test for model/claude.py
Mar 18, 2025
a6720be
remove redundant declaration (refactored into pytest_utils)
Mar 18, 2025
dfefb9a
add tests for models
Mar 18, 2025
a54d0ec
add tests for azure.py
Mar 18, 2025
cb93f7f
test bedrock
Mar 18, 2025
bbe3e00
add problematic definition for Sonar scan
Mar 18, 2025
6d960dc
try changing sonar.sources to include test/
Mar 18, 2025
52b3565
modify sonar scan config
Mar 18, 2025
f8434f7
revert to previous sonar config for showing coverage data
Mar 18, 2025
01ccf2a
finish testing models submodule
Mar 18, 2025
a2081bc
add empty test agent files
Mar 18, 2025
70c131d
update ci
WangGLJoseph Mar 18, 2025
288cdbd
Merge branch 'pytest-latest' into pytest-agents
Mar 19, 2025
8ef4d69
improve coverage of test_agent_search
Mar 19, 2025
622a520
test_patch_utils
Mar 19, 2025
b970ddf
test_agent_reproducer
Mar 19, 2025
24d5278
test_agent_write_patch
Mar 19, 2025
6769ca6
test_agent_select
Mar 19, 2025
5389e8d
test_agent_reviewer
Mar 19, 2025
79d0bd2
test_agent_proxy and refactor DummyModel to pytest_utils
Mar 19, 2025
4bf1e02
test main app dir classes
Mar 19, 2025
a7320be
test_manage
Mar 19, 2025
38b2294
add unit test for GitHubTask and LocalTask
Mar 19, 2025
da95315
test_inference
Mar 19, 2025
c78c1da
move app test files
Mar 19, 2025
2ee78fe
add test files
Mar 20, 2025
e60b1a7
update build files for osx-arm64 envO
WangGLJoseph Mar 20, 2025
f65258e
add app level testing
Mar 20, 2025
29c5d93
add tests for running raw tasks
WangGLJoseph Mar 21, 2025
b509167
improve coverage
WangGLJoseph Mar 21, 2025
875588f
setup multi-env for tox pytest
WangGLJoseph Mar 21, 2025
c2fe5bc
update ci yaml
WangGLJoseph Mar 21, 2025
17c65d0
update ci yaml to refer to github secrets for LLM API keys
WangGLJoseph Mar 21, 2025
43f32b6
add anthropic integration test (negative case with dummy api key)
WangGLJoseph Mar 21, 2025
b43c55d
update integration test ci
WangGLJoseph Mar 21, 2025
aa20a8f
integration test with anthropic
WangGLJoseph Mar 21, 2025
24ccd38
remove logging
WangGLJoseph Mar 21, 2025
65d9ec2
add simple openai integration test
WangGLJoseph Mar 21, 2025
f4073bf
remove print
WangGLJoseph Mar 21, 2025
2013251
update integration
WangGLJoseph Mar 21, 2025
d680321
update ci branch names
WangGLJoseph Mar 21, 2025
3b33840
add missing eof `fi`
WangGLJoseph Mar 21, 2025
470ba7c
update logging
WangGLJoseph Mar 21, 2025
da009cd
update env setup files
WangGLJoseph Mar 24, 2025
13f1a2e
setup python black
WangGLJoseph Mar 24, 2025
59c878f
setup pyright
WangGLJoseph Mar 24, 2025
8176f2b
remove logging
WangGLJoseph Mar 25, 2025
db1ef69
Merge branch 'pytest-integration' into pytest-latest
WangGLJoseph Mar 25, 2025
95daf92
update ci
WangGLJoseph Mar 25, 2025
b807a00
update actions
WangGLJoseph Mar 25, 2025
28593f2
Merge branch 'main' into pytest-latest
WangGLJoseph Mar 25, 2025
2445bc9
update ci yml
WangGLJoseph Mar 26, 2025
fb34f85
update regex for test branches
WangGLJoseph Mar 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ on:
push:
branches:
- main
- pytest-ci
- pytest-latest
- pytest-integration
pull_request:
branches:
- main

jobs:
pytest:
runs-on: ubuntu-latest
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -41,7 +46,16 @@ jobs:
run: conda install -y tox

- name: Run tox tests
run: tox
run: |
branch="${{ github.ref_name }}"
echo "Current branch: $branch"
if [[ "$branch" =~ ^(main(-.*)?|feat/.*/integration-.*)$ ]]; then
echo "Running unit + integration tests."
tox -e unit,integration
else
echo "Running unit tests only."
tox -e unit
fi

- name: Check Coverage Report Exists
run: |
Expand All @@ -50,6 +64,13 @@ jobs:
exit 1
fi

- name: Print Branch Coverage
run: |
echo "Branch Coverage Details:"
echo "Total Branches: $(grep -o 'branches-valid="[0-9]*"' coverage.xml | sed 's/branches-valid="//;s/"//')"
echo "Branches Covered: $(grep -o 'branches-covered="[0-9]*"' coverage.xml | sed 's/branches-covered="//;s/"//')"
echo "Branch Rate: $(grep -o 'branch-rate="[0-9\.]*"' coverage.xml | sed 's/branch-rate="//;s/"//')"

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

output/
output/
setup/
1 change: 1 addition & 0 deletions ACR.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from app import main

if __name__ == "__main__":
main.main()
9 changes: 9 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ The testing suite uses the following libraries and tools:
- Pytest, to execute the tests
- Coverage, (the Coverage.py tool) to measure the code coverage


Creating the `auto-code-rover` environment using the `environment.yaml` file:
```bash
conda env create -f environment.yml
conda activate auto-code-rover
```


In the `auto-code-rover` environment, add `conda-forge` as a channel, then install the required libraries by running the following command:

```bash
conda config --add channels conda-forge
conda config --set channel_priority flexible
conda install -y tox
```

Expand Down
2 changes: 1 addition & 1 deletion app/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
)

def __str__(self):
return f"FunctionCallIntent(func_name={str(self.func_name)}, arguments={str(self.arg_values)})"
return f"FunctionCallIntent(func_name={self.func_name}, arguments={self.arg_values})"

def to_dict(self):
return {"func_name": self.func_name, "arguments": self.arg_values}
Expand Down
22 changes: 22 additions & 0 deletions environment.osx-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: auto-code-rover
channels:
- conda-forge
- defaults
dependencies:
- bzip2=1.0.8
- ca-certificates=2024.7.2
- libffi=3.4.4
- ncurses=6.5
- openssl=3.3.1
- pip=24.2
- python=3.10.11
- readline=8.2
- setuptools=68.2.2
- sqlite=3.46.0
- tk=8.6.14
- tzdata=2023d
- wheel=0.41.2
- xz=5.4.6
- rich=13.8.1
- pip:
- -r requirements.osx-arm64.txt
6 changes: 6 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"include": ["app"],
"exclude": ["venv"],
"pythonVersion": "3.10",
"typeCheckingMode": "basic"
}
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
norecursedirs = setup output
markers =
integration: mark a test as an integration test.
115 changes: 115 additions & 0 deletions requirements.osx-arm64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
aiohttp==3.10.2
aiosignal==1.3.1
annotated-types==0.6.0
antlr4-tools==0.2.1
anyio==4.2.0
astroid==3.2.3
attrs==23.2.0
beautifulsoup4==4.12.3
black==25.1.0
Brotli
certifi==2024.7.4
cffi
cfgv==3.4.0
charset-normalizer
click==8.1.7
coverage==7.5.3
Cython==3.0.8
dill==0.3.8
discord==2.3.2
discord.py==2.3.2
distlib==0.3.8
distro==1.9.0
docker==7.0.0
docstring-parser==0.15
emojis==0.7.0
filelock==3.13.1
frozenlist==1.4.1
fsspec==2024.6.1
h11==0.14.0
h2
hpack==4.0.0
httpcore==1.0.5
httpx==0.27.0
huggingface-hub==0.23.5
hyperframe
icecream==2.1.3
identify==2.5.33
idna==3.7
importlib-metadata==7.0.1
install-jdk==1.1.0
isort==5.13.2
javalang==0.13.0
Jinja2==3.1.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
libclang==18.1.1
linkify-it-py==2.0.2
litellm==1.44.8
loguru==0.7.2
lxml==5.1.0
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mccabe==0.7.0
mdit-py-plugins==0.4.0
mdurl==0.1.2
more-itertools==10.2.0
mpmath==1.3.0
multidict==6.0.4
networkx==3.2.1
nodeenv==1.8.0
numpy==1.26.4
natsort==8.4.0
ollama==0.3.3
openai==1.50.2
opt-einsum==3.3.0
packaging==23.2
platformdirs==4.1.0
polars==0.20.31
pre-commit==3.6.0
pycparser
pydantic==2.5.3
pydantic_core==2.14.6
Pygments==2.17.2
pylint==3.2.3
pyro-api==0.1.2
pyro-ppl==1.9.0
PySocks
pyright==1.1.397
pytest==8.3.4
pytest-cov==6.0.0
python-dotenv==1.0.0
PyYAML==6.0.1
referencing==0.32.1
regex==2024.5.15
rich==13.7.1
rpds-py==0.16.2
semver==3.0.2
slack_sdk==3.26.2
sniffio==1.3.0
soupsieve==2.5
sympy==1.13.0
tenacity==8.2.3
termcolor==2.4.0
textual==0.52.1
tiktoken==0.7.0
timeout-decorator==0.5.0
tokenizers==0.19.1
tomlkit==0.13.0
torch==2.2.1
tqdm==4.66.4
tree-sitter==0.21.3
tree-sitter-c==0.21.4
tree-sitter-cpp==0.22.2
tree-sitter-java==0.21.0
tree-sitter-languages==1.10.2
types-jsonschema==4.21.0.20240311
typing_extensions==4.12.2
uc-micro-py==1.0.2
unidiff==0.7.5
unittest-xml-reporting==3.2.0
urllib3
virtualenv==20.25.0
yarl==1.9.4
zipp==3.19.2
zstandard==0.22.0
Empty file added test/__init__.py
Empty file.
16 changes: 12 additions & 4 deletions test/app/agents/test_agent_common.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
from app.data_structures import MessageThread
from app.agents.agent_common import replace_system_prompt, InvalidLLMResponse


def test_replace_system_prompt():
# Setup: create a MessageThread with a system message and another message
original_prompt = "Original System Prompt"
new_prompt = "New System Prompt"
messages = [
{"role": "system", "content": original_prompt},
{"role": "user", "content": "Hello"}
{"role": "user", "content": "Hello"},
]
msg_thread = MessageThread(messages=messages)

# Execute: replace the system prompt
updated_thread = replace_system_prompt(msg_thread, new_prompt)

# Verify: first message should now have the new prompt
assert updated_thread.messages[0]["content"] == new_prompt, "System prompt was not replaced correctly."
assert (
updated_thread.messages[0]["content"] == new_prompt
), "System prompt was not replaced correctly."
# Verify: the rest of the messages remain unchanged
assert updated_thread.messages[1]["content"] == "Hello", "User message was unexpectedly modified."
assert (
updated_thread.messages[1]["content"] == "Hello"
), "User message was unexpectedly modified."


def test_replace_system_prompt_returns_same_object():
# Setup: create a MessageThread with a single system message
Expand All @@ -29,4 +35,6 @@ def test_replace_system_prompt_returns_same_object():
result = replace_system_prompt(msg_thread, new_prompt)

# Verify: the same MessageThread instance is returned (in-place modification)
assert result is msg_thread, "replace_system_prompt should return the same MessageThread object."
assert (
result is msg_thread
), "replace_system_prompt should return the same MessageThread object."
Loading