From 8fd61aaca7a7c982c85f014e6388c615130f7acb Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Sat, 4 Feb 2017 15:25:59 -0600 Subject: [PATCH] more makefile work --- Makefile | 51 +++++++++++++++++++++++++++++------------- conda/common/compat.py | 12 +++++----- conda/exports.py | 4 ++-- setup.cfg | 5 ++--- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index daf0b6a6370..6486e36b65f 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,22 @@ -PYTHON ?= $(shell which python) -BIN := $(shell dirname $(PYTHON)) -TEST_PLATFORM := $(shell python -c "import sys; print('win' if 'win' in sys.platform else 'unix')") -PYTHON_MAJOR_VERSION := $(shell $(PYTHON) -c "import sys; print(sys.version_info[0])") -PYTEST := PYTHON_MAJOR_VERSION=$(PYTHON_MAJOR_VERSION) TEST_PLATFORM=$(TEST_PLATFORM) $(BIN)/py.test +PYTEST_EXE := $(shell which py.test) +PYTEST_PYTHON := $(shell which py.test | xargs head -1 | sed 's/^\#!//') +PYTHON_MAJOR_VERSION := $(shell $(PYTEST_PYTHON) -c "import sys; print(sys.version_info[0])") +TEST_PLATFORM := $(shell $(PYTEST_PYTHON) -c "import sys; print('win' if sys.platform.startswith('win') else 'unix')") +PYTHONHASHSEED := $(shell python -c "import random as r; print(r.randint(0,4294967296))") + +PYTEST_VARS := PYTHONHASHSEED=$(PYTHONHASHSEED) PYTHON_MAJOR_VERSION=$(PYTHON_MAJOR_VERSION) TEST_PLATFORM=$(TEST_PLATFORM) +PYTEST := $(PYTEST_VARS) $(PYTEST_EXE) + +ADD_COV := --cov-report xml --cov-report term-missing --cov-append --cov conda + clean: - find . -name \*.py[cod] -delete - find . -name __pycache__ -delete - rm -rf *.egg-info* .cache build - rm -f .coverage .coverage.* junit.xml tmpfile.rc conda/.version tempfile.rc coverage.xml - rm -rf auxlib bin conda/progressbar - rm -rf conda-forge\:\: file\: https\: local\:\: r\:\: aprefix + @find . -name \*.py[cod] -delete + @find . -name __pycache__ -delete + @rm -rf *.egg-info* .cache build + @rm -f .coverage .coverage.* junit.xml tmpfile.rc conda/.version tempfile.rc coverage.xml + @rm -rf auxlib bin conda/progressbar + @rm -rf conda-forge\:\: file\: https\: local\:\: r\:\: aprefix clean-all: clean @@ -50,10 +56,25 @@ toolz: rm -rf conda/_vendor/toolz/curried conda/_vendor/toolz/sandbox conda/_vendor/toolz/tests +pytest-version: + $(PYTEST) --version + + smoketest: - py.test tests/test_create.py::test_create_install_update_remove + $(PYTEST) tests/test_create.py -k test_create_install_update_remove + + +unit: clean + time $(PYTEST) $(ADD_COV) -m "not integration and not installed" + + +integration: clean pytest-version + time $(PYTEST) $(ADD_COV) -m "not installed" + + +test-installed: + time $(PYTEST) $(ADD_COV) -m "installed" --shell=bash --shell=zsh -unit: - time $(PYTEST) -m "not integration" -.PHONY : clean clean-all anaconda-submit anaconda-submit-upload auxlib boltons toolz smoketest +.PHONY : clean clean-all anaconda-submit anaconda-submit-upload auxlib boltons toolz \ + pytest-version smoketest unit integration test-installed diff --git a/conda/common/compat.py b/conda/common/compat.py index 05f55357286..f79f00811a7 100644 --- a/conda/common/compat.py +++ b/conda/common/compat.py @@ -21,7 +21,7 @@ # equivalent commands # ############################# -if PY3: +if PY3: # pragma: py2 no cover string_types = str, integer_types = int, class_types = type, @@ -30,7 +30,7 @@ input = input range = range -elif PY2: +elif PY2: # pragma: py3 no cover from types import ClassType string_types = basestring, integer_types = (int, long) @@ -45,10 +45,10 @@ # equivalent imports # ############################# -if PY3: +if PY3: # pragma: py2 no cover from io import StringIO from itertools import zip_longest -elif PY2: +elif PY2: # pragma: py3 no cover from cStringIO import StringIO from itertools import izip as zip, izip_longest as zip_longest @@ -61,7 +61,7 @@ # equivalent functions # ############################# -if PY3: +if PY3: # pragma: py2 no cover def iterkeys(d, **kw): return iter(d.keys(**kw)) @@ -89,7 +89,7 @@ def lchmod(path, mode): def isiterable(obj): return not isinstance(obj, string_types) and isinstance(obj, Iterable) -elif PY2: +elif PY2: # pragma: py3 no cover def iterkeys(d, **kw): return d.iterkeys(**kw) diff --git a/conda/exports.py b/conda/exports.py index 627d36686d6..d7ab7afe003 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -111,9 +111,9 @@ if PY3: - import configparser # NOQA + import configparser # NOQA # pragma: py2 no cover else: - import ConfigParser as configparser # NOQA + import ConfigParser as configparser # NOQA # pragma: py3 no cover configparser = configparser diff --git a/setup.cfg b/setup.cfg index a2934df0439..4e51a4eda05 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,10 @@ [tool:pytest] minversion = 3.0 -testpaths = tests conda +testpaths = conda tests norecursedirs = .* *.egg* build dist conda/_vendor/* conda_env/* addopts = --ignore setup.py --ignore conda/__main__.py - --cov conda --tb native --strict --durations 8 @@ -49,7 +48,7 @@ omit = exclude_lines = pragma: no cover pragma: py$PYTHON_MAJOR_VERSION no cover - pragma: py$PYTHON_MAJOR_VERSION no cover + pragma: $TEST_PLATFORM no cover raise AssertionError raise NotImplementedError if __name__ == .__main__.: