/
Makefile
105 lines (80 loc) · 3.47 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
REPORTER = dot
TARGETS ?= unexpected.js
CHEWBACCA_THRESHOLD ?= 25
lint:
npm run lint
.PHONY: lint
unexpected.js: lib/*
(echo '/*!' && <LICENSE sed -e's/^/ * /' | sed -e's/\s+$$//' && echo ' */' && ./node_modules/.bin/browserify -p bundle-collapser/plugin -e lib -s weknowhow.expect) > $@
.PHONY: unexpected.js
create-html-runners: test/tests.tpl.html test/JasmineRunner.tpl.html
@for file in tests JasmineRunner ; do \
(sed '/test files/q' ./test/$${file}.tpl.html | sed '$$d' && \
find test -name '*.spec.js' | sed 's/test/ <script src="./' | sed 's/$$/"><\/script>/' && \
sed -n '/test files/,$$p' ./test/$${file}.tpl.html | sed '1d') > ./test/$${file}.html;\
done
.PHONY: create-html-runners
test-phantomjs: create-html-runners ${TARGETS}
phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/tests.html spec "`node -pe 'JSON.stringify({useColors:true,grep:process.env.grep})'`"
test-jest-if-supported-node-version:
ifeq ($(shell node --version | grep -vP '^v[0123]\.'),)
@echo Skipping, jest is unsupported with node $(shell node --version)
else
./node_modules/.bin/jest
endif
test-jasmine: ${TARGETS}
./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=test/support/jasmine.json
test-jasmine-browser: create-html-runners unexpected.js
@./node_modules/.bin/serve .
.PHONY: test
TEST_SOURCES = $(shell find test -name '*.spec.js') $(shell find documentation -name '*.md')
test: lint
@./node_modules/.bin/mocha $(TEST_SOURCES)
.PHONY: coverage
coverage:
@./node_modules/.bin/nyc --reporter=lcov --reporter=text --all -- mocha --compilers md:unexpected-markdown test/*.js $(TEST_SOURCES)
@echo google-chrome coverage/lcov-report/index.html
.PHONY: test-browser
test-browser: create-html-runners unexpected.js
@./node_modules/.bin/serve .
.PHONY: travis-chewbacca
travis-chewbacca:
./node_modules/.bin/chewbacca --threshold ${CHEWBACCA_THRESHOLD} `echo ${TRAVIS_COMMIT_RANGE} | sed -e 's/\.\.\..*//;'` -- test/benchmark.spec.js
travis: clean lint test travis-chewbacca test-phantomjs test-jasmine test-jest-if-supported-node-version coverage
ifneq ($(shell node --version | grep -vP '^v[0123]\.'),)
make site-build
endif
-<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js
.PHONY: git-dirty-check
git-dirty-check:
ifneq ($(shell git describe --always --dirty | grep -- -dirty),)
$(error Working tree is dirty, please commit or stash your changes, then try again)
endif
.PHONY: deploy-site
deploy-site: site-build
./node_modules/.bin/deploy-site.sh site-build && \
git push git@github.com:unexpectedjs/unexpectedjs.github.io.git +site-build:master
.PHONY: commit-unexpected
commit-unexpected: unexpected.js
git add unexpected.js
if [ "`git status --porcelain`" != "" ]; then \
git commit -m "Build unexpected.js" ; \
fi
.PHONY: release-%
release-%: git-dirty-check lint ${TARGETS} test-phantomjs test-jasmine test-jest-if-supported-node-version commit-unexpected deploy-site
./node_modules/.bin/chewbacca --threshold ${CHEWBACCA_THRESHOLD} `git describe --abbrev=0 --tags --match 'v*'` -- test/benchmark.spec.js
IS_MAKE_RELEASE=yes npm version $*
@echo $* release ready to be publised to NPM
@echo Remember to push tags
.PHONY: clean
clean:
-rm -fr ${TARGETS} coverage
.PHONY: site-build
site-build:
npm run generate-site
.PHONY: update-examples
update-examples:
npm run update-examples
.PHONY: benchmark
benchmark:
./node_modules/.bin/mocha --no-timeouts --ui chewbacca/mocha-benchmark-ui --reporter chewbacca/mocha-benchmark-reporter test/benchmark.spec.js