Skip to content

Commit

Permalink
update CI and testing suite
Browse files Browse the repository at this point in the history
  • Loading branch information
chyanju committed Feb 28, 2024
1 parent db43e80 commit 004d622
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test hello.py
run: python tests/scripts/hello.py
- name: test dep.py
Expand All @@ -37,6 +38,7 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test parsing.py
run: PYTHONPATH="./" python ./tests/scripts/parsing.py

Expand All @@ -52,6 +54,7 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test divz
run: PYTHONPATH="./" python ./tests/scripts/test-divz.py

Expand All @@ -67,6 +70,7 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test infoleak
run: PYTHONPATH="./" python ./tests/scripts/test-infoleak.py

Expand All @@ -82,6 +86,7 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test rtcnst
run: PYTHONPATH="./" python ./tests/scripts/test-rtcnst.py

Expand All @@ -97,5 +102,6 @@ jobs:
pip install networkx[default]
pip install lark
pip install beautifulsoup4
pip install pandas
- name: test unused
run: PYTHONPATH="./" python ./tests/scripts/test-unused.py
2 changes: 2 additions & 0 deletions tests/scripts/dep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import lark
import networkx
import bs4
import pandas

if __name__ == "__main__":
print("Hello World!")
14 changes: 12 additions & 2 deletions tests/test4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "a983f9b5-286c-4748-b2c7-b450ff0d7948",
"metadata": {},
"outputs": [
Expand All @@ -119,7 +119,17 @@
"# [✓][test] pid: unused0.aleo, fid: ex4, expected: True, actual: True\n",
"# [✗][test] pid: unused0.aleo, fid: ex5, expected: False, actual: True\n",
"# [✓][test] pid: unused0.aleo, fid: ex6, expected: True, actual: True\n",
"# [test] accuracy: 5/7 (0.7143)\n"
"# [test] accuracy: 5/7 (0.7143)\n",
"# [test] confusion matrix:\n",
" actual False True \n",
"expected \n",
"False 1 2\n",
"True 0 4\n",
"# [test] normalized confusion matrix:\n",
" actual False True \n",
"expected \n",
"False 0.333333 0.666667\n",
"True 0.000000 1.000000\n"
]
}
],
Expand Down
10 changes: 10 additions & 0 deletions vanguard/aleo/testing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import time
import json
import pandas as pd

from bs4 import BeautifulSoup

Expand Down Expand Up @@ -32,6 +33,15 @@ def run_test_suite(build_path, detector, verbose=False):

if verbose:
print(f"# [test] accuracy: {ncorrect}/{len(actual_labels)} ({ncorrect/len(actual_labels):.4f})")

if verbose:
pd_expected = pd.Series(expected_labels, name="expected")
pd_actual = pd.Series(actual_labels, name="actual")
mtx =pd.crosstab(pd_expected, pd_actual)
mtx_norm = mtx.div(mtx.sum(axis=1), axis="index")
print(f"# [test] confusion matrix:\n {mtx}")
print(f"# [test] normalized confusion matrix:\n {mtx_norm}")

return (expected_labels, expected_infos, actual_labels, actual_infos)

def crawl_from_haruka_explorer(istart, iend, folder):
Expand Down

0 comments on commit 004d622

Please sign in to comment.