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)
|
|
|
|
|
2023-05-31 06:43:36 +08:00
|
|
|
.PHONY: default ruff env lint lint-incr style black test test_randomized pytest pytest_randomized test_ci coverage coverage_erase clean
|
2021-07-23 08:06:55 +08:00
|
|
|
|
2023-05-31 06:43:36 +08:00
|
|
|
default: ruff style lint-incr test ;
|
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:
|
2021-06-23 04:22:31 +08:00
|
|
|
pylint -rn qiskit test tools
|
2021-06-22 05:49:31 +08:00
|
|
|
tools/verify_headers.py qiskit test tools examples
|
2021-07-23 08:06:55 +08:00
|
|
|
pylint -rn --disable='invalid-name, missing-module-docstring, redefined-outer-name' examples/python/*.py
|
|
|
|
tools/find_optional_imports.py
|
2022-07-12 20:16:03 +08:00
|
|
|
tools/find_stray_release_notes.py
|
2021-07-23 08:06:55 +08:00
|
|
|
|
|
|
|
# Only pylint on files that have changed from origin/main. Also parallelize (disables cyclic-import check)
|
|
|
|
lint-incr:
|
|
|
|
-git fetch -q https://github.com/Qiskit/qiskit-terra.git :lint_incr_latest
|
|
|
|
tools/pylint_incr.py -j4 -rn -sn --paths :/qiskit/*.py :/test/*.py :/tools/*.py
|
|
|
|
tools/pylint_incr.py -j4 -rn -sn --disable='invalid-name, missing-module-docstring, redefined-outer-name' --paths ':(glob,top)examples/python/*.py'
|
|
|
|
tools/verify_headers.py qiskit test tools examples
|
2021-06-22 05:49:31 +08:00
|
|
|
tools/find_optional_imports.py
|
2017-12-29 07:41:24 +08:00
|
|
|
|
2023-05-31 06:43:36 +08:00
|
|
|
ruff:
|
|
|
|
ruff qiskit test tools examples setup.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:
|
2023-05-11 00:25:17 +08:00
|
|
|
QISKIT_TEST_CAPTURE_STREAMS=1 stestr run
|
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 ;
|