Skip to content

Commit

Permalink
Merge pull request #55 from common-workflow-language/release-refresh
Browse files Browse the repository at this point in the history
Release refresh
  • Loading branch information
mr-c authored Feb 9, 2018
2 parents f3a4276 + 7a3fefe commit 01baa72
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 30 deletions.
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include Makefile
include Makefile gittaggers.py
include tests/*
include tests/test-data/*
global-exclude *~
global-exclude *.pyc

10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ MODULE=cwltest
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
# `[[` conditional expressions.
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pep257 sloccount python-flake8
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
--max-count=1 --format=format:%cI`)
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

## all : default task
all:
./setup.py develop
pip install -e .

## help : print this help message and exit
help: Makefile
Expand Down Expand Up @@ -109,10 +109,7 @@ diff_pylint_report: pylint_report.txt
diff-quality --violations=pylint pylint_report.txt

.coverage: $(PYSOURCES) all
export COVERAGE_PROCESS_START=${mkfile_dir}.coveragerc; \
cd ${CWL}; ./run_test.sh RUNNER=cwltool
coverage run setup.py test
coverage combine ${CWL} ${CWL}/draft-3/ ./
coverage run ./setup.py test

coverage.xml: .coverage
python-coverage xml
Expand All @@ -135,6 +132,7 @@ diff-cover.html: coverage-gcovr.xml coverage.xml

## test : run the ${MODULE} test suite
test: FORCE
./setup.py test

sloccount.sc: ${PYSOURCES} Makefile
sloccount --duplicates --wide --details $^ > sloccount.sc
Expand Down
2 changes: 1 addition & 1 deletion release-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -x
package=cwltest
module=cwltest
repo=https://github.com/common-workflow-language/cwltest.git
run_tests="cwltest --help"
run_tests="py.test --pyarg ${module}"
pipver=8.0.1 # minimum required version of pip
setupver=20.10.1 # minimum required version of setuptools

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ ignore = E124,E128,E129,E201,E202,E225,E226,E231,E265,E271,E302,E303,F401,E402,E

[bdist_wheel]
universal = 1

[tool:pytest]
testpaths = tests

[aliases]
test=pytest
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
'six>=1.10.0'
]

needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []

if sys.version_info.major == 2:
install_requires.extend(['futures >= 3.0.5', 'subprocess32'])

Expand All @@ -37,10 +40,13 @@
url="https://github.com/common-workflow-language/cwltest",
download_url="https://github.com/common-workflow-language/cwltest",
license='Apache 2.0',
packages=["cwltest"],
packages=["cwltest", "cwltest.tests"],
package_dir={'cwltest.tests': 'tests'},
include_package_data=True,
install_requires=install_requires,
test_suite='tests',
tests_require=[],
setup_requires=[] + pytest_runner,
tests_require=['pytest'],
entry_points={
'console_scripts': ["cwltest=cwltest:main"]
},
Expand Down
20 changes: 6 additions & 14 deletions tests/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import unittest
from .util import get_data
from cwltest import CompareFail
from cwltest.utils import compare_file, compare


class TestCompare(unittest.TestCase):

def compare_success(self, expected, actual):
try:
compare(expected, actual)
except CompareFail:
self.fail("Comparison failed unexpectedly")


class TestCompareFile(TestCompare):
class TestCompareFile(unittest.TestCase):

def test_compare_file(self):
expected = {
"location": "cores.txt",
"size": 2,
"class": "File",
"checksum": "sha1$7448d8798a4380162d4b56f9b452e2f6f9e24e7a"
}
}

actual = {
"basename": "cores.txt",
Expand Down Expand Up @@ -48,10 +40,10 @@ def test_compare_contents_success(self):
"checksum": "sha1$7448d8798a4380162d4b56f9b452e2f6f9e24e7a",
"class": "File",
"location": "file:///var/folders/8x/2df05_7j20j6r8y81w4qf43r0000gn/T/tmpG0EkrS/cores.txt",
"path": "tests/test-data/cores.txt",
"path": get_data("tests/test-data/cores.txt"),
"size": 2
}
self.compare_success(expected, actual)
compare(expected, actual)

def test_compare_contents_failure(self):
expected = {
Expand All @@ -66,7 +58,7 @@ def test_compare_contents_failure(self):
"checksum": "sha1$7448d8798a4380162d4b56f9b452e2f6f9e24e7a",
"class": "File",
"location": "file:///var/folders/8x/2df05_7j20j6r8y81w4qf43r0000gn/T/tmpG0EkrS/cores.txt",
"path": "tests/test-data/cores.txt",
"path": get_data("tests/test-data/cores.txt"),
"size": 2
}
with self.assertRaises(CompareFail):
Expand Down
19 changes: 19 additions & 0 deletions tests/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import absolute_import
import os

from pkg_resources import (Requirement, ResolutionError, # type: ignore
resource_filename)


def get_data(filename):
filename = os.path.normpath(
filename) # normalizing path depending on OS or else it will cause problem when joining path
filepath = None
try:
filepath = resource_filename(
Requirement.parse("cwltest"), filename)
except ResolutionError:
pass
if not filepath or not os.path.isfile(filepath):
filepath = os.path.join(os.path.dirname(__file__), os.pardir, filename)
return filepath
15 changes: 9 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
#envlist = py35-lint,py34-lint,py33-lint,py27-lint,py35-unit,py34-unit,py33-unit,py27-unit
envlist = py27-lint, py27-unit, py35-mypy{2,3}
envlist = py27-lint, py{27,33,34,35}-unit, py35-mypy{2,3}
skipsdist = True

[travis]
Expand All @@ -12,7 +12,9 @@ python =
3.5: py35-mypy{2,3}

[testenv]
deps = -rrequirements.txt
deps =
pytest
-rrequirements.txt

[testenv:py35-mypy2]
commands = make mypy2
Expand Down Expand Up @@ -49,13 +51,14 @@ whitelist_externals = flake8
deps = flake8

[testenv:py35-unit]
commands = python setup.py test
commands = pytest {posargs} # substitute with tox' positional arguments

[testenv:py34-unit]
commands = python setup.py test
commands = pytest {posargs} # substitute with tox' positional arguments

[testenv:py33-unit]
commands = python setup.py test
commands = pytest {posargs} # substitute with tox' positional arguments

[testenv:py27-unit]
commands = python setup.py test
commands = pytest {posargs} # substitute with tox' positional arguments

0 comments on commit 01baa72

Please sign in to comment.