Skip to content

Commit

Permalink
CI: Get coverage of filecheck tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webmiche committed Dec 7, 2022
1 parent c864833 commit 847de6c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ omit =
xdsl/_version.py
concurrency = multiprocessing
parallel = True
source =
xdsl/


[report]
# Regexes for lines to exclude from consideration
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ jobs:
pip install --upgrade pip
- name: Install the package locally
run: pip install -e .[extras]
- name: Test with pytest and check code coverage
- name: Test with pytest and generate code coverage
run: |
pytest --cov --cov-config=.coveragerc --cov-report=xml tests/
coverage run -m pytest tests/
- name: Execute lit tests
run: |
export PYTHONPATH=$(pwd)
lit -v tests/filecheck/
- name: Combine coverage data
run: |
coverage combine
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest<8.0
filecheck<0.0.23
lit<16.0.0
frozenlist<1.4.*
coverage<7.0.0
26 changes: 26 additions & 0 deletions xdsl/tools/xdsl-opt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import argparse
from xdsl.xdsl_opt_main import xDSLOptMain
import coverage
import os


class OptMain(xDSLOptMain):
Expand All @@ -15,6 +17,30 @@ class OptMain(xDSLOptMain):
def register_all_arguments(self, arg_parser: argparse.ArgumentParser):
super().register_all_arguments(arg_parser)

#arg_parser.add_argument(
# "--check-coverage",
# default=False,
# action='store_true',
# help="Generate the xDSL code coverage for this run.")

def run(self):
# In order to find the `.coverage` file, as well as the `.coveragerc`,
# we need to step up to the `xdsl` directory. Notice that lit runs tests
# within the folder their are contained in.
while (os.getcwd().split('/')[-1] != 'xdsl'):
os.chdir('../')

cov = coverage.Coverage(check_preimported=True,
config_file='.coveragerc',
branch=True,
auto_data=True)

cov.start()

super().run()

cov.stop()


def __main__():
xdsl_main = OptMain()
Expand Down

0 comments on commit 847de6c

Please sign in to comment.