Martin Cosyns | 0efdc87 | 2021-09-27 16:24:30 +0000 | [diff] [blame] | 1 | # Copyright 2020-present Open Networking Foundation |
| 2 | # Original copyright 2020-present ADTRAN, Inc. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | |
| 15 | # set default shell |
| 16 | SHELL = bash -e -o pipefail |
| 17 | |
| 18 | ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 19 | |
| 20 | # Variables |
| 21 | VERSION ?= $(shell cat ./VERSION) |
| 22 | LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \ |
| 23 | --configure TooManyTestSteps:60 -e TooManyTestSteps \ |
| 24 | --configure TooManyTestCases:50 -e TooManyTestCases \ |
| 25 | --configure TooFewTestSteps:1 \ |
| 26 | --configure TooFewKeywordSteps:1 \ |
| 27 | --configure FileTooLong:1500 -e FileTooLong \ |
| 28 | -e TrailingWhitespace |
| 29 | |
| 30 | ROBOT_FILES := $(shell find . -name test.robot -print) |
| 31 | DMI_SERVER_FILE ?= $(ROOT_DIR)/tests/servers/dmi/dmi_server.py |
| 32 | |
| 33 | # For each makefile target, add ## <description> on the target line and it will be listed by 'make help' |
| 34 | help: ## Print help for each Makefile target |
| 35 | @echo "Usage: make [<target>]" |
| 36 | @echo "where available targets are:" |
| 37 | @echo |
| 38 | @grep '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 39 | | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s : %s\n", $$1, $$2};' |
| 40 | |
| 41 | vst_venv: |
| 42 | virtualenv -p python3 $@ ;\ |
| 43 | source ./$@/bin/activate ;\ |
| 44 | python -m pip install -r requirements.txt |
| 45 | python $(DMI_SERVER_FILE) & echo $$! > server.PID |
| 46 | |
| 47 | test: vst_venv |
| 48 | source ./$</bin/activate ; set -u ;\ |
| 49 | rflint $(LINT_ARGS) $(ROBOT_FILES) |
| 50 | |
| 51 | clean: |
| 52 | find . -name output.xml -print |
| 53 | |
| 54 | clean-all: clean |
| 55 | rm -rf vst_venv |
| 56 | kill `cat server.PID` && rm server.PID |
| 57 | |
| 58 | # end file |