Skip to content

Commit

Permalink
added CI for existing detectors
Browse files Browse the repository at this point in the history
  • Loading branch information
chyanju committed Feb 28, 2024
1 parent 27a0bc6 commit 4c87595
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
46 changes: 44 additions & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,47 @@ jobs:
run: |
pip install networkx[default]
pip install lark
- name: test parsing.py
run: PYTHONPATH="./" python ./tests/scripts/parsing.py
- name: test divz
run: PYTHONPATH="./" python ./tests/scripts/test-divz.py

detector-test-infoleak:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: install dependencies
run: |
pip install networkx[default]
pip install lark
- name: test infoleak
run: PYTHONPATH="./" python ./tests/scripts/test-infoleak.py

detector-test-rtcnst:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: install dependencies
run: |
pip install networkx[default]
pip install lark
- name: test rtcnst
run: PYTHONPATH="./" python ./tests/scripts/test-rtcnst.py

detector-test-unused:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: install dependencies
run: |
pip install networkx[default]
pip install lark
- name: test unused
run: PYTHONPATH="./" python ./tests/scripts/test-unused.py
2 changes: 1 addition & 1 deletion tests/scripts/test-divz.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
main = env.main
fid = "ex0"
res, info = detector_divz(env, main.id, fid)
assert not res, f"Test failed for {fid}, expected: True, got: {res}"
assert res, f"Test failed for {fid}, expected: True, got: {res}"
11 changes: 11 additions & 0 deletions tests/scripts/test-infoleak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from vanguard.aleo.grammar import AleoEnvironment
from vanguard.aleo.detectors.infoleak import detector_infoleak

if __name__ == "__main__":
project_name = "infoleak0"
build_path = f"./tests/public/{project_name}/build/"
env = AleoEnvironment(build_path)
main = env.main
fid = "ex0"
res, info = detector_infoleak(env, main.id, fid)
assert res, f"Test failed for {fid}, expected: True, got: {res}"
11 changes: 11 additions & 0 deletions tests/scripts/test-rtcnst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from vanguard.aleo.grammar import AleoEnvironment
from vanguard.aleo.detectors.rtcnst import detector_rtcnst

if __name__ == "__main__":
project_name = "rtcnst0"
build_path = f"./tests/public/{project_name}/build/"
env = AleoEnvironment(build_path)
main = env.main
fid = "ex0"
res, info = detector_rtcnst(env, main.id, fid)
assert res, f"Test failed for {fid}, expected: True, got: {res}"
16 changes: 16 additions & 0 deletions tests/scripts/test-unused.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from vanguard.aleo.grammar import AleoEnvironment
from vanguard.aleo.detectors.unused import detector_unused

if __name__ == "__main__":
project_name = "unused0"
build_path = f"./tests/public/{project_name}/build/"
env = AleoEnvironment(build_path)
main = env.main

fid = "ex0"
res, info = detector_unused(env, main.id, fid)
assert not res, f"Test failed for {fid}, expected: True, got: {res}"

fid = "ex1"
res, info = detector_unused(env, main.id, fid)
assert res, f"Test failed for {fid}, expected: True, got: {res}"

0 comments on commit 4c87595

Please sign in to comment.