blob: 5934e4989c2b57fba69f0c997cb9dee57ca7ed2c [file] [log] [blame]
Joey Armstrong88fca722024-01-31 22:52:17 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Joey Armstrong88fca722024-01-31 22:52:17 -05004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
Joey Armstrongdc04c932024-04-01 12:14:21 -04009# http:#www.apache.org/licenses/LICENSE-2.0
Joey Armstrong88fca722024-01-31 22:52:17 -050010#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -040017# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# -----------------------------------------------------------------------
Joey Armstrong88fca722024-01-31 22:52:17 -050022
23$(if $(DEBUG),$(warning ENTER))
24
25##-------------------##
26##---] GLOBALS [---##
27##-------------------##
28.PHONY: lint-robot lint-robot-all lint-robot-mod lint-robot-src
29
30have-robot-files := $(if $(strip $(ROBOT_FILES)),true)
31ROBOT_FILES ?= $(error ROBOT_FILES= is required)
32
33robot-check = $(activate) && rflint
34robot-check-args ?= --verbose --configure LineTooLong:130 -e LineTooLong \
35 --configure TooManyTestSteps:65 -e TooManyTestSteps \
36 --configure TooManyTestCases:50 -e TooManyTestCases \
37 --configure TooFewTestSteps:1 \
38 --configure TooFewKeywordSteps:1 \
39 --configure FileTooLong:2000 -e FileTooLong \
40 -e TrailingWhitespace
41
42## -----------------------------------------------------------------------
43## Intent: Use the robot command to perform syntax checking.
44## -----------------------------------------------------------------------
45ifndef NO-LINT-ROBOT
46 lint-robot-mode := $(if $(have-robot-files),mod,all)
47 lint : lint-robot
48 lint-robot : lint-robot-$(lint-robot-mode)
49endif# NO-LINT-ROBOT
50
51## -----------------------------------------------------------------------
52## Intent: exhaustive robot syntax checking
53## -----------------------------------------------------------------------
54lint-robot-all:
55
56 $(call banner-enter,Target $@)
57
58 $(HIDE)$(MAKE) --no-print-directory lint-robot-version
59 @find . -iname '*.robot' -print0 \
60 | $(xargs-n1) bash -c "$(robot-check) $(robot-check-args)"
61 @echo "DONE"
62
63 $(call banner-leave,Target $@)
64
65## -----------------------------------------------------------------------
66## Intent: On-demand lint checking
67## -----------------------------------------------------------------------
68lint-robot-src:
69 ifndef ROBOT_SRC
70 @echo "ERROR: Usage: $(MAKE) $@ ROBOT_SRC="
71 @exit 1
72 endif
73
74 $(call banner-enter,Target $@)
75
76 $(HIDE)$(MAKE) --no-print-directory lint-robot-version
77 $(HIDE) $(robot-check-args) $(robot-check-args) $(ROBOT_SRC)
78
79 $(call banner-leave,Target $@)
80
81## -----------------------------------------------------------------------
82## Intent: Perform lint check on locally modified sources
83## -----------------------------------------------------------------------
84lint-robot-bygit = $(shell git ls-files -m -o | grep -i '\.robot')
85lint-robot-mod:
86 $(call banner-enter,Target $@)
87
88 $(HIDE)$(MAKE) --no-print-directory lint-robot-version
89 $(foreach fyl,$(lint-robot-bygit),$(robot-check) $(robot-check-args) $(fyl))
90
91 $(call banner-leave,Target $@)
92
93$(if $(DEBUG),$(warning LEAVE))
94
95# [EOF]