blob: ce5a8335a21cbc2d709241a7ef5fc2241bd9f14d [file] [log] [blame]
Kailash92764922019-07-25 08:21:39 -07001# 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 Williamsec53a1b2019-09-16 15:50:52 -070015# use bash for pushd/popd, and to fail quickly. virtualenv's activate
16# has undefined variables, so no -u
17SHELL = bash -e -o pipefail
Andy Bavierba9866b2019-10-11 07:11:53 -070018ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
Kailash92764922019-07-25 08:21:39 -070019
Zack Williamsec53a1b2019-09-16 15:50:52 -070020# Variables
Gilles Depatie6c727ff2019-10-21 16:23:13 -040021LINT_ARGS ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15 \
22 --configure TooFewTestSteps:1 --configure TooFewKeywordSteps:1
Zack Williamsec53a1b2019-09-16 15:50:52 -070023VERSION ?= $(shell cat ./VERSION)
Andy Bavierba9866b2019-10-11 07:11:53 -070024ROBOT_VAR_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
Kailash92764922019-07-25 08:21:39 -070025
hwchiu0601ec72019-10-08 00:04:43 +000026.PHONY: gendocs
27
28## Variables for gendocs
29TEST_SOURCE := $(wildcard tests/*/*.robot)
30TEST_BASENAME := $(basename $(TEST_SOURCE))
31TEST_DIRS := $(dir $(TEST_SOURCE))
32
33LIB_SOURCE := $(wildcard libraries/*.robot)
34LIB_BASENAME := $(basename $(LIB_SOURCE))
35LIB_DIRS := $(dir $(LIB_SOURCE))
36
Andy Bavierba9866b2019-10-11 07:11:53 -070037ROBOT_MISC_ARGS ?=
hwchiu0601ec72019-10-08 00:04:43 +000038
Andy Bavierba9866b2019-10-11 07:11:53 -070039sanity-kind: ROBOT_MISC_ARGS += -i sanity
40sanity-kind: bbsim-kind
41
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -070042bbsim-kind: ROBOT_MISC_ARGS += -X
Andy Bavierba9866b2019-10-11 07:11:53 -070043bbsim-kind: voltha-podtest
Zack Williamsec53a1b2019-09-16 15:50:52 -070044
45# virtualenv for the robot tools
46vst_venv:
47 virtualenv $@ ;\
48 source ./$@/bin/activate ;\
49 pip install -r requirements.txt
50
51test: lint
52
53lint: vst_venv
54 source ./vst_venv/bin/activate ;\
55 set -u ;\
56 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
57
58# tidy will be more useful once this issue with removing leading comments is
59# resolved: https://github.com/robotframework/robotframework/issues/3263
60tidy:
61 source ./vst_venv/bin/activate ;\
62 set -u ;\
63 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
64
Andy Bavierba9866b2019-10-11 07:11:53 -070065voltha-podtest: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -070066 source ./vst_venv/bin/activate ;\
67 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -070068 cd tests/functional ;\
69 robot -V $(ROBOT_VAR_FILE) $(ROBOT_MISC_ARGS) Voltha_PODTests.robot
hwchiu0601ec72019-10-08 00:04:43 +000070
Zack Williamsec53a1b2019-09-16 15:50:52 -070071gendocs: vst_venv
72 source ./vst_venv/bin/activate ;\
73 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +000074 mkdir -p $@ ;\
75 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
76 for dir in ${LIB_BASENAME}; do\
77 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
78 done ;\
79 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
80 for dir in ${TEST_BASENAME}; do\
81 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
82 done
Zack Williamsec53a1b2019-09-16 15:50:52 -070083
84# explore use of --docformat REST - integration w/Sphinx?
85clean:
86 find . -name output.xml -print
87
88clean-all: clean
89 rm -rf vst_venv gendocs