forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (116 loc) · 4.84 KB
/
Makefile
File metadata and controls
145 lines (116 loc) · 4.84 KB
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
PERL5LIB_:=../..:os-autoinst:lib:tests/installation:tests/x11:tests/qa_automation:tests/virt_autotest:$$PERL5LIB
.PHONY: all
all:
.PHONY: help
help:
echo "Call 'make test' to call tests"
.PHONY: prepare
prepare:
git clone git://github.com/os-autoinst/os-autoinst
$(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:
@# Get list of changed yaml files
$(eval YAMLS=$(shell sh -c "git --no-pager diff --diff-filter=dr --name-only master | grep '\(schedule\|test_data\)/.*\.y.\?ml$$'"))
if test -n "$(YAMLS)"; then \
export PERL5LIB=${PERL5LIB_} ; tools/test_yaml_valid $(YAMLS);\
which yamllint >/dev/null 2>&1 || echo "Command 'yamllint' not found, can not execute YAML syntax checks";\
yamllint -c .yamllint $(YAMLS);\
else \
echo "No yamls modified.";\
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 $$(git merge-base master HEAD) | 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 FETCH_HEAD master 2>/dev/null) ;\
if test -n "$$REV"; then \
FILES=$$(git diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD master 2>/dev/null` | 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 detect-nonexistent-testdata test-unused-modules test-soft_failure-no-reference test-spec test-invalid-syntax
.PHONY: test
ifeq ($(TESTS),compile)
test: test-compile
else ifeq ($(TESTS),static)
test: test-static
else ifeq ($(TESTS),unit)
test: unit-test perlcritic
else
test: unit-test test-static test-compile 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
test-unused-modules:
tools/detect_unused_modules
.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 $$(git merge-base master HEAD) | grep '^test*'`
.PHONY: detect-nonexistent-testdata
detect-nonexistent-testdata:
export PERL5LIB=${PERL5LIB_} ; tools/detect_nonexistent_testdata `git diff --name-only --exit-code --diff-filter=d $$(git merge-base master HEAD) | grep '^schedule/.*\.ya\?ml$$'`
.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-9]+|fate.suse.com/[0-9]|\$$[a-z]+)' lib/ tests/
.PHONY: test-invalid-syntax
test-invalid-syntax:
tools/check_invalid_syntax