-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
87 lines (69 loc) · 2 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
.PHONY: help clean coverage-check browse-coverage coverage-report coverage-html-report test test-tap test-dot test-spec npm-test travis-test browser-test
BIN = ./node_modules/.bin
all: lint test coverage-html-report coverage-report coverage-check
help:
@echo
@echo "To run tests:"
@echo " npm test [--dot | --spec] [--phantom] [--grep=<test file pattern>]"
@echo
@echo "To run tests in all browsers:"
@echo " npm run browser-test"
@echo
@echo "To see coverage:"
@echo " npm run coverage [--html]"
@echo
npm-test:
ifdef npm_config_grep
@make lint test
else
ifdef npm_config_phantom
@make lint test
else
@make lint test coverage-check
endif
endif
travis-test: lint test
@(cat coverage/lcov.info | coveralls) || exit 0
browser-test:
@$(BIN)/zuul -- test/*.js
npm-coverage: coverage-report coverage-html-report
ifdef npm_config_html
@make browse-coverage
endif
lint:
@$(BIN)/standard
test:
$(if $(npm_config_grep), @echo "Running test files that match pattern: $(npm_config_grep)\n",)
ifdef npm_config_dot
@make test-dot
else
ifdef npm_config_spec
@make test-spec
else
@make test-tap
endif
endif
test-tap:
ifdef npm_config_phantom
@find ./test -maxdepth 1 -name "*.js" -type f | grep ""$(npm_config_grep) | xargs $(BIN)/zuul --phantom --
else
@find ./test -maxdepth 1 -name "*.js" -type f | grep ""$(npm_config_grep) | xargs $(BIN)/istanbul cover --report lcovonly --print none $(BIN)/tape --
endif
test-dot:
@make test-tap | $(BIN)/tap-dot
test-spec:
@make test-tap | $(BIN)/tap-spec
coverage:
@make test
coverage-check: coverage
@rm -f coverage/error
@$(BIN)/istanbul check-coverage --statements 100 --branches 100 --functions 100 --lines 100 2>&1 | cat > coverage/error
$(if $(npm_config_grep),,@if [ -s coverage/error ]; then echo; grep ERROR coverage/error; echo; exit 1; fi)
coverage-report: coverage
@$(BIN)/istanbul report text
coverage-html-report: coverage
@$(BIN)/istanbul report html > /dev/null
browse-coverage: coverage-html-report
@$(BIN)/opn coverage/index.html
clean:
@rm -rf coverage