2019-04-30 22:36:47 +08:00
|
|
|
# This code is part of Qiskit.
|
2017-05-12 00:12:57 +08:00
|
|
|
#
|
2019-04-30 22:36:47 +08:00
|
|
|
# (C) Copyright IBM 2017.
|
|
|
|
#
|
|
|
|
# This code is licensed under the Apache License, Version 2.0. You may
|
|
|
|
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
|
|
|
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
#
|
|
|
|
# Any modifications or derivative works of this code must retain this
|
|
|
|
# copyright notice, and modified files need to carry a notice indicating
|
|
|
|
# that they have been altered from the originals.
|
2018-06-08 21:00:58 +08:00
|
|
|
|
2019-04-06 02:17:50 +08:00
|
|
|
OS := $(shell uname -s)
|
|
|
|
|
|
|
|
ifeq ($(OS), Linux)
|
|
|
|
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
|
|
|
|
else ifeq ($(OS), Darwin)
|
|
|
|
NPROCS := 2
|
|
|
|
else
|
|
|
|
NPROCS := 0
|
|
|
|
endif # $(OS)
|
|
|
|
|
|
|
|
ifeq ($(NPROCS), 2)
|
|
|
|
CONCURRENCY := 2
|
|
|
|
else ifeq ($(NPROCS), 1)
|
|
|
|
CONCURRENCY := 1
|
|
|
|
else ifeq ($(NPROCS), 3)
|
|
|
|
CONCURRENCY := 3
|
|
|
|
else ifeq ($(NPROCS), 0)
|
|
|
|
CONCURRENCY := 0
|
|
|
|
else
|
|
|
|
CONCURRENCY := $(shell echo "$(NPROCS) 2" | awk '{printf "%.0f", $$1 / $$2}')
|
|
|
|
endif
|
|
|
|
|
2019-06-03 00:06:24 +08:00
|
|
|
.PHONY: env lint test test_ci
|
2017-05-08 21:25:14 +08:00
|
|
|
|
2017-06-20 23:17:11 +08:00
|
|
|
# Dependencies need to be installed on the Anaconda virtual environment.
|
2017-05-08 21:25:14 +08:00
|
|
|
env:
|
2019-01-21 20:03:51 +08:00
|
|
|
if test $(findstring qiskitenv, $(shell conda info --envs | tr '[:upper:]' '[:lower:]')); then \
|
|
|
|
bash -c "source activate Qiskitenv;pip install -r requirements.txt"; \
|
2017-08-08 04:44:17 +08:00
|
|
|
else \
|
2019-01-21 20:03:51 +08:00
|
|
|
conda create -y -n Qiskitenv python=3; \
|
|
|
|
bash -c "source activate Qiskitenv;pip install -r requirements.txt"; \
|
2017-08-08 04:44:17 +08:00
|
|
|
fi;
|
2017-06-20 23:17:11 +08:00
|
|
|
|
2017-05-11 18:59:08 +08:00
|
|
|
# Ignoring generated ones with .py extension.
|
2017-05-08 21:25:14 +08:00
|
|
|
lint:
|
2019-05-13 22:04:50 +08:00
|
|
|
pylint -rn qiskit test
|
2021-06-22 05:49:31 +08:00
|
|
|
tools/verify_headers.py qiskit test tools examples
|
2020-05-09 05:06:59 +08:00
|
|
|
pylint -rn --disable='C0103, C0114, W0621' examples/python/*.py
|
2021-06-22 05:49:31 +08:00
|
|
|
tools/find_optional_imports.py
|
2017-12-29 07:41:24 +08:00
|
|
|
|
|
|
|
style:
|
2021-06-22 05:49:31 +08:00
|
|
|
black --check qiskit test tools examples setup.py
|
2021-05-05 21:53:39 +08:00
|
|
|
|
|
|
|
black:
|
2021-06-22 05:49:31 +08:00
|
|
|
black qiskit test tools examples setup.py
|
2017-05-08 21:25:14 +08:00
|
|
|
|
2018-01-05 03:21:21 +08:00
|
|
|
# Use the -s (starting directory) flag for "unittest discover" is necessary,
|
|
|
|
# otherwise the QuantumCircuit header will be modified during the discovery.
|
2017-05-09 04:17:43 +08:00
|
|
|
test:
|
2020-11-26 10:28:17 +08:00
|
|
|
@echo ================================================
|
|
|
|
@echo Consider using tox as suggested in the CONTRIBUTING.MD guideline. For running the tests as the CI, use test_ci
|
|
|
|
@echo ================================================
|
2020-09-04 05:07:36 +08:00
|
|
|
python3 -m unittest discover -s test/python -t . -v
|
2020-11-26 10:28:17 +08:00
|
|
|
@echo ================================================
|
|
|
|
@echo Consider using tox as suggested in the CONTRIBUTING.MD guideline. For running the tests as the CI, use test_ci
|
|
|
|
@echo ================================================
|
2017-07-05 21:05:19 +08:00
|
|
|
|
2020-05-19 22:17:41 +08:00
|
|
|
# Use pytest to run tests
|
|
|
|
pytest:
|
|
|
|
pytest test/python
|
|
|
|
|
|
|
|
# Use pytest to run randomized tests
|
|
|
|
pytest_randomized:
|
|
|
|
pytest test/randomized
|
|
|
|
|
2019-02-06 05:28:16 +08:00
|
|
|
test_ci:
|
2020-11-26 10:28:17 +08:00
|
|
|
@echo Detected $(NPROCS) CPUs running with $(CONCURRENCY) workers
|
2020-09-10 07:01:54 +08:00
|
|
|
QISKIT_TEST_CAPTURE_STREAMS=1 stestr run --concurrency $(CONCURRENCY)
|
2018-08-21 02:42:23 +08:00
|
|
|
|
2019-06-17 22:36:20 +08:00
|
|
|
test_randomized:
|
2020-09-04 05:07:36 +08:00
|
|
|
python3 -m unittest discover -s test/randomized -t . -v
|
2019-06-17 22:36:20 +08:00
|
|
|
|
2018-03-06 03:38:13 +08:00
|
|
|
coverage:
|
2019-06-17 22:36:20 +08:00
|
|
|
coverage3 run --source qiskit -m unittest discover -s test/python -q
|
2018-03-06 03:38:13 +08:00
|
|
|
coverage3 report
|
|
|
|
|
|
|
|
coverage_erase:
|
|
|
|
coverage erase
|
|
|
|
|
2019-02-08 02:29:37 +08:00
|
|
|
clean: coverage_erase ;
|