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-02-08 02:29:37 +08:00
|
|
|
.PHONY: env lint test test_record test_mock 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-04-27 06:37:21 +08:00
|
|
|
pylint -j 2 -rn qiskit test
|
2017-12-29 07:41:24 +08:00
|
|
|
|
|
|
|
style:
|
2018-02-05 18:47:53 +08:00
|
|
|
pycodestyle --max-line-length=100 qiskit test
|
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:
|
2019-02-06 05:28:16 +08:00
|
|
|
python3 -m unittest discover -s test -v
|
2017-07-05 21:05:19 +08:00
|
|
|
|
2018-08-21 02:42:23 +08:00
|
|
|
test_mock:
|
2019-02-06 05:28:16 +08:00
|
|
|
env QISKIT_TESTS=mock_online python3 -m unittest discover -s test -v
|
2018-08-21 02:42:23 +08:00
|
|
|
|
|
|
|
test_recording:
|
|
|
|
-rm test/cassettes/*
|
2019-02-06 05:28:16 +08:00
|
|
|
env QISKIT_TESTS=rec python3 -m unittest discover -s test -v
|
|
|
|
|
|
|
|
test_ci:
|
2019-04-06 02:17:50 +08:00
|
|
|
echo "Detected $(NPROCS) CPUs running with $(CONCURRENCY) workers"
|
|
|
|
stestr run --concurrency $(CONCURRENCY)
|
2018-08-21 02:42:23 +08:00
|
|
|
|
2018-03-06 03:38:13 +08:00
|
|
|
coverage:
|
2019-02-06 05:28:16 +08:00
|
|
|
coverage3 run --source qiskit -m unittest discover -s test -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 ;
|