Skip to content

Commit

Permalink
Merge pull request #65 from aig-upf/codecov_integration
Browse files Browse the repository at this point in the history
Integrate Tarski with codecov to track progress in test coverage
  • Loading branch information
gfrances authored Jul 17, 2019
2 parents f073f94 + 9b37961 commit 8d47bef
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ notebooks/exploratory/.ipynb_checkpoints/From_RDDL_to_Functional_STRIPS-checkpoi
.idea/vcs.xml
.idea/workspace.xml
.idea/misc.xml

# Code coverage reports
.coverage
coverage.xml
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ matrix:

# Run the standard pytest tests with different python versions
- python: 3.6
env: TOXENV=py36
env: TOXENV=pycoverage # We check code coverage only with python 3.6

- python: 3.7
env: TOXENV=py37
Expand All @@ -36,12 +36,13 @@ before_install:
# Install Gringo only for the ASP-based grounding & rechability tests
- if [[ $TOXENV == py* ]]; then sudo apt-get install -y --no-install-recommends gringo; fi

# Install curl for running the codecov script
- if [[ $TOXENV == pycoverage ]]; then sudo apt-get install -y --no-install-recommends curl; fi

install:
- python -m pip install --upgrade pip setuptools wheel
- pip install tox
- python -m pip install --upgrade tox pip setuptools wheel
- tox --version
# Download benchmarks only if necessary
- if [[ $TOXENV == py* ]]; then ./scripts/get-benchmarks; fi
- if [[ $TOXENV == py* ]]; then ./scripts/get-benchmarks; fi # Download benchmarks only if necessary

script:
- tox
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

# Tarski - An AI Planning Modeling Framework [![Build Status](https://travis-ci.com/aig-upf/tarski.svg?branch=master)](https://travis-ci.com/aig-upf/tarski)
# Tarski - An AI Planning Modeling Framework
[![Build Status](https://travis-ci.com/aig-upf/tarski.svg?branch=master)](https://travis-ci.com/aig-upf/tarski)
[![codecov](https://codecov.io/gh/aig-upf/tarski/branch/master/graph/badge.svg)](https://codecov.io/gh/aig-upf/tarski)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tarski.svg?style=popout)
![PyPI](https://img.shields.io/pypi/v/tarski.svg?style=popout)


## What is Tarski
Tarski is a framework for the specification, modeling and manipulation of
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -ex

pylint --version

Expand Down
9 changes: 9 additions & 0 deletions scripts/report-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e
set -x

# python -m coverage combine
# python -m coverage xml
# python -m coverage report -m
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml
20 changes: 9 additions & 11 deletions tests/fol/test_syntactic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ def test_formula_flattening():

b1, b2, b3, clear = lang.get('b1', 'b2', 'b3', 'clear')
f1 = land(clear(b1), clear(b2), clear(b3), clear(b1), flat=True)
f2 = land(clear(b1), clear(b2), clear(b3), clear(b1), flat=False)

f3 = lor(clear(b1), clear(b2), clear(b3), clear(b1), flat=True)
f4 = lor(clear(b1), clear(b2), clear(b3), clear(b1), flat=False)

f2 = lor(clear(b1), clear(b2), clear(b3), clear(b1), flat=True)
assert f1 == flatten(f1) # both are already flat - this tests for syntactic identity
assert f3 == flatten(f3)
assert f2 == flatten(f2)

# In contrast, f3 and f4 are not flat, so flattening them will change their syntactic form
z = flatten(f2)
assert f2 != z and len(z.subformulas) == 4
# Now test formulas which are not flat, so flattening them will change their syntactic form
f1 = land(clear(b1), clear(b2), clear(b3), clear(b1), flat=False)
f2 = lor(clear(b1), f1, clear(b3), (clear(b3) | clear(b1)), flat=False)
z = flatten(f1)
assert f1 != z and len(z.subformulas) == 4

z = flatten(f4)
assert f4 != z and len(z.subformulas) == 4
z = flatten(f2)
assert f2 != z and len(z.subformulas) == 5

43 changes: 34 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@

[tox]
# Don't care too much about these, as they will be overriden by Travis
envlist = py36,stylechecks
envlist = coverage

[testenv]
deps=
pytest

[testenv]
passenv = PYTHONPATH FSBENCHMARKS DOWNWARD_BENCHMARKS
deps= pytest
commands= pytest

commands=

[testenv:pycoverage]
passenv = PYTHONPATH FSBENCHMARKS DOWNWARD_BENCHMARKS CODECOV_TOKEN CI TRAVIS TRAVIS_*
whitelist_externals = /bin/bash
deps=
pytest
pytest-cov
commands=
# Report both on screen and generate the xml file
pytest --cov --cov-report term --cov-report xml
{toxinidir}/scripts/report-coverage


[testenv:antlrgrammars]
# Test the building of the different parser ANTLR grammars only
commands = {toxinidir}/scripts/build-grammars


[testenv:stylechecks]
deps =
pylint
deps = pylint
commands = {toxinidir}/scripts/lint


### Some coverage.py configuration options ###
[coverage:paths]
source =
src
*/site-packages/tarski


[coverage:run]
branch = true
source =
tarski
tests

;commands = pylint src/tarski --rcfile={toxinidir}/.pylintrc
commands = {toxinidir}/scripts/lint
[coverage:report]
; show_missing = true
precision = 2

0 comments on commit 8d47bef

Please sign in to comment.