-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from KeerthiVasudevan/main
Added execution invariance test
- Loading branch information
Showing
21 changed files
with
488 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: execution invariance tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
os: ["ubuntu-latest"] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install hatch | ||
pip install pytest-json-report | ||
- name: Install DynaPyt | ||
run: | | ||
pip install -e . | ||
- name: Run the test script | ||
run: | | ||
hatch run exec_invariance_test:run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024-present Aryaz Eghbali <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# DYNAPYT: DO NOT INSTRUMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024-present Keerthi <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# analysis | ||
|
||
[![PyPI - Version](https://img.shields.io/pypi/v/analysis.svg)](https://pypi.org/project/analysis) | ||
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/analysis.svg)](https://pypi.org/project/analysis) | ||
|
||
----- | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [License](#license) | ||
|
||
## Installation | ||
|
||
```console | ||
pip install analysis | ||
``` | ||
|
||
## License | ||
|
||
`analysis` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "analysis" | ||
dynamic = ["version"] | ||
description = '' | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = "MIT" | ||
keywords = [] | ||
authors = [ | ||
{ name = "Keerthi", email = "[email protected]" }, | ||
] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dependencies = [] | ||
|
||
[project.urls] | ||
Documentation = "https://github.com/Keerthi/analysis#readme" | ||
Issues = "https://github.com/Keerthi/analysis/issues" | ||
Source = "https://github.com/Keerthi/analysis" | ||
|
||
[tool.hatch.version] | ||
path = "src/analysis/__about__.py" | ||
|
||
[tool.hatch.envs.default] | ||
dependencies = [ | ||
"pytest-json-report", | ||
] | ||
|
||
[tool.hatch.envs.types] | ||
extra-dependencies = [ | ||
"mypy>=1.0.0", | ||
] | ||
[tool.hatch.envs.types.scripts] | ||
check = "mypy --install-types --non-interactive {args:src/analysis tests}" | ||
|
||
[tool.coverage.run] | ||
source_pkgs = ["analysis", "tests"] | ||
branch = true | ||
parallel = true | ||
omit = [ | ||
"src/analysis/__about__.py", | ||
] | ||
|
||
[tool.coverage.paths] | ||
analysis = ["src/analysis", "*/analysis/src/analysis"] | ||
tests = ["tests", "*/analysis/tests"] | ||
|
||
[tool.coverage.report] | ||
exclude_lines = [ | ||
"no cov", | ||
"if __name__ == .__main__.:", | ||
"if TYPE_CHECKING:", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024-present Keerthi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2024-present Keerthi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
from dynapyt.analyses.BaseAnalysis import BaseAnalysis | ||
|
||
|
||
class Analysis(BaseAnalysis): | ||
|
||
def runtime_event(self, dyn_ast: str, iid: int) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2024-present Keerthi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024-present Keerthi <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# simple-test | ||
|
||
[![PyPI - Version](https://img.shields.io/pypi/v/simple-test.svg)](https://pypi.org/project/simple-test) | ||
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/simple-test.svg)](https://pypi.org/project/simple-test) | ||
|
||
----- | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [License](#license) | ||
|
||
## Installation | ||
|
||
```console | ||
pip install simple-test | ||
``` | ||
|
||
## License | ||
|
||
`simple-test` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. |
61 changes: 61 additions & 0 deletions
61
execution_invariance_test/projects/simple-test/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "simple-test" | ||
dynamic = ["version"] | ||
description = '' | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = "MIT" | ||
keywords = [] | ||
authors = [ | ||
{ name = "Keerthi", email = "[email protected]" }, | ||
] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dependencies = [] | ||
|
||
[project.urls] | ||
Documentation = "https://github.com/Keerthi/simple-test#readme" | ||
Issues = "https://github.com/Keerthi/simple-test/issues" | ||
Source = "https://github.com/Keerthi/simple-test" | ||
|
||
[tool.hatch.version] | ||
path = "src/simple_test/__about__.py" | ||
|
||
[tool.hatch.envs.types] | ||
extra-dependencies = [ | ||
"mypy>=1.0.0", | ||
] | ||
[tool.hatch.envs.types.scripts] | ||
check = "mypy --install-types --non-interactive {args:src/simple_test tests}" | ||
|
||
[tool.coverage.run] | ||
source_pkgs = ["simple_test", "tests"] | ||
branch = true | ||
parallel = true | ||
omit = [ | ||
"src/simple_test/__about__.py", | ||
] | ||
|
||
[tool.coverage.paths] | ||
simple_test = ["src/simple_test", "*/simple-test/src/simple_test"] | ||
tests = ["tests", "*/simple-test/tests"] | ||
|
||
[tool.coverage.report] | ||
exclude_lines = [ | ||
"no cov", | ||
"if __name__ == .__main__.:", | ||
"if TYPE_CHECKING:", | ||
] |
5 changes: 5 additions & 0 deletions
5
execution_invariance_test/projects/simple-test/src/simple_test/__about__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2024-present Aryaz Eghbali <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# DYNAPYT: DO NOT INSTRUMENT | ||
__version__ = "0.0.1" |
4 changes: 4 additions & 0 deletions
4
execution_invariance_test/projects/simple-test/src/simple_test/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024-present Aryaz Eghbali <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# DYNAPYT: DO NOT INSTRUMENT |
17 changes: 17 additions & 0 deletions
17
execution_invariance_test/projects/simple-test/src/simple_test/simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import traceback | ||
import os.path | ||
|
||
def add_one(x: int) -> int: | ||
return x + 1 | ||
|
||
|
||
def multiply_two(x: int) -> int: | ||
return x * 2 | ||
|
||
|
||
def add_together(x: int, y: int) -> int: | ||
return x + y | ||
|
||
|
||
def get_stack(): | ||
return traceback.extract_stack() |
10 changes: 10 additions & 0 deletions
10
execution_invariance_test/projects/simple-test/tests/stack_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import traceback | ||
from simple_test.simple import get_stack | ||
|
||
def test_stack(): | ||
trace = get_stack() | ||
trace_list = traceback.format_list(trace) | ||
trace_length = len(trace_list) | ||
expected_trace_str_length = 34 | ||
assert trace_length == expected_trace_str_length | ||
|
25 changes: 25 additions & 0 deletions
25
execution_invariance_test/projects/simple-test/tests/test_simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from simple_test.simple import add_one, multiply_two, add_together | ||
|
||
|
||
def test_add_one_1(): | ||
assert add_one(1) == 2 | ||
|
||
|
||
def test_add_one_2(): | ||
assert add_one(2) == 3 | ||
|
||
|
||
def test_multiply_two_1(): | ||
assert multiply_two(1) == 2 | ||
|
||
|
||
def test_multiply_two_2(): | ||
assert multiply_two(2) == 4 | ||
|
||
|
||
def test_add_together_1_2(): | ||
assert add_together(1, 2) == 3 | ||
|
||
|
||
def test_add_together_2_3(): | ||
assert add_together(2, 3) == 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
python3 -m venv venv | ||
source venv/bin/activate | ||
pip install -U pip setuptools | ||
SCRIPTS_DIR=$(dirname $(realpath "$0")) | ||
PARENT_DIR=$(dirname $SCRIPTS_DIR) | ||
ANALYSIS_DIR=$SCRIPTS_DIR/analysis | ||
pip install -e $ANALYSIS_DIR | ||
pip install pytest-json-report | ||
pip install $PARENT_DIR | ||
uniqueID=$(python -c "import uuid; print(uuid.uuid4())") | ||
export DYNAPYT_SESSION_ID=$uniqueID | ||
echo "DYNAPYT_SESSION_ID=$DYNAPYT_SESSION_ID" | ||
temp_dir="${TMPDIR:-/tmp}" | ||
file_path=$temp_dir/dynapyt_analyses-$uniqueID.txt | ||
touch $file_path | ||
echo "analysis.analysis.Analysis" > $file_path | ||
cat $file_path | ||
python $SCRIPTS_DIR/test.py | ||
deactivate | ||
rm $temp_dir/dynapyt_analyses-$uniqueID.txt | ||
rm -rf venv | ||
|
Oops, something went wrong.