forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (130 loc) · 5.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
PERL5LIB_:=../..:os-autoinst:lib:tests/installation:tests/x11:tests/qa_automation:tests/virt_autotest:tests/cpu_bugs:$$PERL5LIB
.PHONY: all
all:
.PHONY: help
help:
echo "Call 'make test' to call tests"
.PHONY: prepare
prepare:
git clone https://github.com/os-autoinst/os-autoinst.git
$(MAKE) check-links
cd os-autoinst && cpanm -nq --installdeps .
cpanm -nq --installdeps .
os-autoinst/:
@test -d os-autoinst || (echo "Missing test requirements, \
link a local working copy of 'os-autoinst' into this \
folder or call 'make prepare' to install download a copy necessary for \
testing" && exit 2)
tools/tidy: os-autoinst/
@test -e tools/tidy || ln -s ../os-autoinst/tools/tidy tools/
@test -e tools/absolutize || ln -s ../os-autoinst/tools/absolutize tools/
@test -e .perltidyrc || ln -s os-autoinst/.perltidyrc ./
tools/lib/: os-autoinst/
@test -e tools/lib || ln -s ../os-autoinst/tools/lib tools/
.PHONY: check-links
check-links: tools/tidy tools/lib/ os-autoinst/
.PHONY: check-links
tidy-check: check-links
tools/tidy --check
.PHONY: tidy
tidy: tools/tidy
$< --only-changed
@echo "[make] Tidy called over modified/new files only. For a full run use make tidy-full"
.PHONY: tidy-full
tidy-full: tools/tidy
$<
.PHONY: unit-test
unit-test:
prove -l -Ios-autoinst/ t/
.PHONY: test-compile
test-compile: check-links
export PERL5LIB=${PERL5LIB_} ; ( git ls-files "*.pm" || find . -name \*.pm|grep -v /os-autoinst/ ) | parallel perl -c 2>&1 | grep -v " OK$$" && exit 2; true
.PHONY: test-compile-changed
test-compile-changed: os-autoinst/
export PERL5LIB=${PERL5LIB_} ; for f in `git diff --name-only | grep '.pm'` ; do perl -c $$f 2>&1 | grep -v " OK$$" && exit 2; done ; true
.PHONY: test-yaml-valid
test-yaml-valid:
$(eval YAMLS=$(shell sh -c "git ls-files schedule/ test_data/ | grep '\\.ya\?ml$$'"))
if test -n "$(YAMLS)"; then \
export PERL5LIB=${PERL5LIB_} ; echo "$(YAMLS)" | xargs tools/test_yaml_valid ;\
else \
echo "No yamls modified.";\
fi
if test -n "$(YAMLS)"; then \
which yamllint >/dev/null 2>&1 || echo "Command 'yamllint' not found, can not execute YAML syntax checks";\
echo "$(YAMLS)" | xargs yamllint -c .yamllint;\
fi
.PHONY: test-modules-in-yaml-schedule
test-modules-in-yaml-schedule:
export PERL5LIB=${PERL5LIB_} ; tools/detect_nonexistent_modules_in_yaml_schedule `git diff --diff-filter=d --name-only --exit-code origin/master | grep '^schedule/*'`
.PHONY: test-metadata
test-metadata:
tools/check_metadata $$(git ls-files "tests/**.pm")
.PHONY: test-metadata-changed
test-metadata-changed:
tools/check_metadata $$(git diff --name-only | grep 'tests.*pm')
.PHONY: test-merge
test-merge:
@REV=$$(git merge-base origin/master 2>/dev/null) ;\
if test -n "$$REV"; then \
FILES=$$(git diff --name-only origin/master | grep 'tests.*pm') ;\
for file in $$FILES; do if test -f $$file; then \
tools/check_metadata $$file || touch failed; \
git --no-pager grep wait_idle $$file && touch failed; \
${PERLCRITIC} $$file || (echo $$file ; touch failed) ;\
fi ; done; \
fi
@test ! -f failed
.PHONY: test-dry
test-dry:
export PERL5LIB=${PERL5LIB_} ; tools/detect_code_dups
.PHONY: test-no-wait_idle
test-no-wait_idle:
@! git --no-pager grep wait_idle lib/ tests/
.PHONY: test-spec
test-spec:
tools/update_spec --check
.PHONY: test-static
test-static: tidy-check test-yaml-valid test-modules-in-yaml-schedule test-merge test-dry test-no-wait_idle test-deleted-renamed-referenced-files test-unused-modules-changed test-soft_failure-no-reference test-spec test-invalid-syntax test-code-style test-metadata
.PHONY: test
ifeq ($(TESTS),compile)
test: test-compile
else ifeq ($(TESTS),static)
test: test-static
else ifeq ($(TESTS),unit)
test: unit-test perlcritic
else ifeq ($(TESTS),isotovideo)
test: test-isotovideo
else
test: unit-test test-static test-compile test-isotovideo perlcritic
endif
PERLCRITIC=PERL5LIB=tools/lib/perlcritic:$$PERL5LIB perlcritic --quiet --stern --include "strict" --include Perl::Critic::Policy::HashKeyQuote
.PHONY: perlcritic
perlcritic: tools/lib/
${PERLCRITIC} $$(git ls-files -- '*.p[ml]' ':!:data/')
.PHONY: test-unused-modules-changed
test-unused-modules-changed:
@echo "[make] Unused modules check called over modified/new files only. For a full run use make test-unused-modules-full"
tools/detect_unused_modules -m ` (\
git --no-pager diff --name-only --diff-filter=d origin/master | grep '^tests/*' | grep -v '^tests/test_pods/'; \
git --no-pager diff --unified=0 origin/master products/* | sed -n "s~^-.*loadtest\s\+\([\"']\)\([^\"']\+\)\1.*~tests/\2.pm~p"; \
git --no-pager diff --unified=0 origin/master schedule/* | sed -n "s~^-\s\+-\s\+\([\"']\)\([^\"']\+\)\1.*~tests/\2.pm~p" | grep -v '{{' ) \
| sort -u`
.PHONY: test-unused-modules-full
test-unused-modules-full:
tools/detect_unused_modules -a
.PHONY: test-deleted-renamed-referenced-files
test-deleted-renamed-referenced-files:
tools/test_deleted_renamed_referenced_files `git diff --name-only --exit-code --diff-filter=DR origin/master | grep '^test*'`
.PHONY: test-soft_failure-no-reference
test-soft_failure-no-reference:
@! git --no-pager grep -E -e 'soft_failure\>.*\;' --and --not -e '([$$0-9a-z]+#[$$0-9a-zA-Z]+|fate.suse.com/[0-9]|\$$[a-z]+)' lib/ tests/
.PHONY: test-invalid-syntax
test-invalid-syntax:
tools/check_invalid_syntax
.PHONY: test-code-style
test-code-style:
tools/check_code_style
.PHONY: test-isotovideo
test-isotovideo:
tools/test_isotovideo