Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 15 | # use bash for pushd/popd, and to fail quickly. virtualenv's activate |
| 16 | # has undefined variables, so no -u |
| 17 | SHELL = bash -e -o pipefail |
Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 18 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 19 | # Variables |
| 20 | LINT_ARGS ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15 |
| 21 | VERSION ?= $(shell cat ./VERSION) |
David Bainbridge | 8da6dd9 | 2019-10-08 18:58:12 +0000 | [diff] [blame] | 22 | ROBOT_OLT_SN = |
| 23 | ROBOT_ONU_SN = |
| 24 | |
| 25 | ifneq ($(BBSIM_OLT_SN),) |
| 26 | ROBOT_OLT_SN=-v BBSIM_OLT_SN:$(BBSIM_OLT_SN) |
| 27 | endif |
| 28 | |
| 29 | ifneq ($(BBSIM_ONU_SN),) |
| 30 | ROBOT_ONU_SN=-v BBSIM_ONU_SN:$(BBSIM_ONU_SN) |
| 31 | endif |
Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 32 | |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 33 | .PHONY: gendocs |
| 34 | |
| 35 | ## Variables for gendocs |
| 36 | TEST_SOURCE := $(wildcard tests/*/*.robot) |
| 37 | TEST_BASENAME := $(basename $(TEST_SOURCE)) |
| 38 | TEST_DIRS := $(dir $(TEST_SOURCE)) |
| 39 | |
| 40 | LIB_SOURCE := $(wildcard libraries/*.robot) |
| 41 | LIB_BASENAME := $(basename $(LIB_SOURCE)) |
| 42 | LIB_DIRS := $(dir $(LIB_SOURCE)) |
| 43 | |
| 44 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 45 | sanity-kind: ROBOT_PORT_ARGS ?= -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101 |
| 46 | sanity-kind: ROBOT_TEST_ARGS ?= --exclude notready --critical sanity |
| 47 | sanity-kind: ROBOT_MISC_ARGS ?= -v num_onus:1 |
| 48 | sanity-kind: sanity |
| 49 | |
| 50 | # virtualenv for the robot tools |
| 51 | vst_venv: |
| 52 | virtualenv $@ ;\ |
| 53 | source ./$@/bin/activate ;\ |
| 54 | pip install -r requirements.txt |
| 55 | |
| 56 | test: lint |
| 57 | |
| 58 | lint: vst_venv |
| 59 | source ./vst_venv/bin/activate ;\ |
| 60 | set -u ;\ |
| 61 | find . -name *.robot -exec rflint $(LINT_ARGS) {} + |
| 62 | |
| 63 | # tidy will be more useful once this issue with removing leading comments is |
| 64 | # resolved: https://github.com/robotframework/robotframework/issues/3263 |
| 65 | tidy: |
| 66 | source ./vst_venv/bin/activate ;\ |
| 67 | set -u ;\ |
| 68 | find . -name *.robot -exec python -m robot.tidy --inplace {} \; |
| 69 | |
| 70 | sanity: vst_venv |
| 71 | source ./vst_venv/bin/activate ;\ |
| 72 | set -u ;\ |
| 73 | cd tests/sanity ;\ |
David Bainbridge | 8da6dd9 | 2019-10-08 18:58:12 +0000 | [diff] [blame] | 74 | robot $(ROBOT_PORT_ARGS) $(ROBOT_TEST_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_OLT_SN) $(ROBOT_ONU_SN) sanity.robot |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 75 | |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 76 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 77 | gendocs: vst_venv |
| 78 | source ./vst_venv/bin/activate ;\ |
| 79 | set -u ;\ |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 80 | mkdir -p $@ ;\ |
| 81 | for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\ |
| 82 | for dir in ${LIB_BASENAME}; do\ |
| 83 | python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\ |
| 84 | done ;\ |
| 85 | for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\ |
| 86 | for dir in ${TEST_BASENAME}; do\ |
| 87 | python -m robot.testdoc $$dir.robot $@/$$dir.html ;\ |
| 88 | done |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 89 | |
| 90 | # explore use of --docformat REST - integration w/Sphinx? |
| 91 | clean: |
| 92 | find . -name output.xml -print |
| 93 | |
| 94 | clean-all: clean |
| 95 | rm -rf vst_venv gendocs |