Skip to content

Commit

Permalink
Techdebt: allow test & lint to run for specific service
Browse files Browse the repository at this point in the history
make test SERVICE_NAME=s3
  • Loading branch information
hans-d committed Mar 7, 2023
1 parent adfbff1 commit 02b516c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
SHELL := /bin/bash

SERVICE_NAME = "default"
TEST_NAMES = "*"
ifdef SERVICE_NAME
TEST_SERVICE = test_${SERVICE_NAME}
TF_SERVICE_NAME = ${SERVICE_NAME}
endif

TF_SERVICE_NAME ?= "default"
TEST_NAMES ?= "*"

ifeq ($(TEST_SERVER_MODE), true)
# exclude test_kinesisvideoarchivedmedia
Expand All @@ -20,34 +25,35 @@ init:

lint:
@echo "Running flake8..."
flake8 moto tests
flake8 moto/${SERVICE_NAME} tests/${TEST_SERVICE}
@echo "Running black... "
$(eval black_version := $(shell grep "^black==" requirements-dev.txt | sed "s/black==//"))
@echo "(Make sure you have black-$(black_version) installed, as other versions will produce different results)"
black --check moto/ tests/
black --check moto/${SERVICE_NAME} tests/${TEST_SERVICE}
@echo "Running pylint..."
pylint -j 0 moto tests
pylint -j 0 moto/${SERVICE_NAME} tests/${TEST_SERVICE}
@echo "Running MyPy..."
mypy --install-types --non-interactive
mypy --install-types --non-interactive moto/${SERVICE_NAME}

format:
black moto/ tests/

test-only:
rm -f .coverage
rm -rf cover
pytest -sv --cov=moto --cov-report xml ./tests/ $(TEST_EXCLUDE)
pytest -sv --cov=moto --cov-report xml ./tests/${TEST_SERVICE} $(TEST_EXCLUDE)
# https://github.com/aws/aws-xray-sdk-python/issues/196 - Run these tests separately without Coverage enabled
pytest -sv ./tests/test_xray
MOTO_CALL_RESET_API=false pytest --cov=moto --cov-report xml --cov-append -n 4 $(PARALLEL_TESTS)
if [[ "${SERVICE_NAME}" == "" || "${SERVICE_NAME}" == "xray" ]]; then pytest -sv ./tests/test_xray; else echo "Skipping"; fi
if [[ "$(filter %${SERVICE_NAME},$(PARALLEL_TESTS))" != "" ]]; then MOTO_CALL_RESET_API=false pytest --cov=moto --cov-report xml --cov-append -n 4 $(filter %${SERVICE_NAME},$(PARALLEL_TESTS)); else echo "Skipping"; fi

test: lint test-only
@echo "USAGE: make test [SERVICE_NAME=s3] (defaults to all)"

terraformtests:
@echo "Make sure that the MotoServer is already running on port 4566 (moto_server -p 4566)"
@echo "USAGE: make terraformtests SERVICE_NAME=acm TEST_NAMES=TestAccACMCertificate"
@echo ""
cd tests/terraformtests && bin/run_go_test $(SERVICE_NAME) "$(TEST_NAMES)"
cd tests/terraformtests && bin/run_go_test $(TF_SERVICE_NAME) "$(TF_TEST_NAMES)"

test_server:
@TEST_SERVER_MODE=true pytest -sv --cov=moto --cov-report xml ./tests/
Expand Down

0 comments on commit 02b516c

Please sign in to comment.