-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
52 lines (41 loc) · 1.61 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
# use the tools as dev dependencies rather than installing them globaly
# it lets you handle specific versions of the tooling for each of your projects
MOCHA=node_modules/.bin/mocha
ISTANBUL=node_modules/.bin/istanbul
JSHINT=node_modules/.bin/jshint
# test files must end with ".test.js"
TESTS=$(shell find test/ -name "*.test.js")
clean:
rm -rf reports
test:
$(MOCHA) -R spec $(TESTS)
xunit:
@# check if reports folder exists, if not create it
@test -d reports || mkdir reports
XUNIT_FILE="reports/TESTS-xunit.xml" $(MOCHA) -R xunit-file $(TESTS)
coverage:
@# check if reports folder exists, if not create it
@test -d reports || mkdir reports
$(ISTANBUL) instrument --output src-cov src
@# move original src code and replace it by the instrumented one
mv src src-orig && mv src-cov src
@# tell istanbul to only generate the lcov file
ISTANBUL_REPORTERS=lcovonly $(MOCHA) -R mocha-istanbul $(TESTS)
@# place the lcov report in the report folder, remove instrumented code
@# and reput src at its place
mv lcov.info reports/coverage.lcov
rm -rf src
mv src-orig src
cobertura: coverage
python tools/lcov_cobertura.py reports/coverage.lcov -b src -o reports/coverage.xml
jshint:
$(JSHINT) src test --show-non-errors
checkstyle:
@# check if reports folder exists, if not create it
@test -d reports || mkdir reports
$(JSHINT) src test --reporter=checkstyle > reports/checkstyle.xml
sonar:
@# add the sonar sonar-runner executable to the PATH
PATH="$$PWD/tools/sonar-runner-2.2/bin:$$PATH" sonar-runner
ci: clean xunit cobertura checkstyle sonar
.PHONY: clean test xunit coverage cobertura jshint checkstyle sonar ci