Skip to content

Commit

Permalink
feat: run pytest in pr workflow to check function test coverage (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
scgkiran authored Jan 7, 2025
1 parent 203e6e4 commit 7bfc37c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,19 @@ jobs:
node-version: "20"
- run: ./ci/release/dry_run.sh
python-style:
name: Style-check and lint Python files
name: Style-check and lint Python files, and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1
run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1 pytest antlr4-python3-runtime==4.13.2
- name: Black
run: python3 -m black --diff --check .
- name: Flake8
run: python3 -m flake8 .
- name: Run tests including test_substrait_extension_coverage
run: |
pytest
check-proto-prefix:
name: Check proto-prefix.py
runs-on: ubuntu-latest
Expand Down
15 changes: 11 additions & 4 deletions tests/coverage/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,31 +213,38 @@ def test_parse_aggregate_func_max():
]


def get_absolute_path(relative_path):
script_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.join(script_dir, relative_path)


def test_parse_file_add():
test_file = parse_one_file("../cases/arithmetic/add.test")
test_file = parse_one_file(get_absolute_path("../cases/arithmetic/add.test"))
assert len(test_file.testcases) == 15
assert test_file.testcases[0].func_name == "add"
assert test_file.testcases[0].base_uri == "/extensions/functions_arithmetic.yaml"
assert test_file.include == "/extensions/functions_arithmetic.yaml"


def test_parse_file_max():
test_file = parse_one_file("../cases/arithmetic/max.test")
test_file = parse_one_file(get_absolute_path("../cases/arithmetic/max.test"))
assert len(test_file.testcases) == 12
assert test_file.testcases[0].func_name == "max"
assert test_file.testcases[0].base_uri == "/extensions/functions_arithmetic.yaml"
assert test_file.include == "/extensions/functions_arithmetic.yaml"


def test_parse_file_lt_datetime():
test_file = parse_one_file("../cases/datetime/lt_datetime.test")
test_file = parse_one_file(get_absolute_path("../cases/datetime/lt_datetime.test"))
assert len(test_file.testcases) == 13
assert test_file.testcases[0].func_name == "lt"
assert test_file.testcases[0].base_uri == "/extensions/functions_datetime.yaml"


def test_parse_file_power_decimal():
test_file = parse_one_file("../cases/arithmetic_decimal/power.test")
test_file = parse_one_file(
get_absolute_path("../cases/arithmetic_decimal/power.test")
)
assert len(test_file.testcases) == 9
assert test_file.testcases[0].func_name == "power"
assert (
Expand Down

0 comments on commit 7bfc37c

Please sign in to comment.