Skip to content

Commit a56f599

Browse files
committed
[update] makefile + code coverage
1 parent 712e4e7 commit a56f599

File tree

7 files changed

+93
-73
lines changed

7 files changed

+93
-73
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ Temporary Items
6767

6868
composer.lock
6969

70+
# =========================
71+
# PHPUnit
72+
# =========================
73+
74+
/coverage
75+

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@ cache:
99
directories:
1010
- $HOME/.composer/cache/files
1111

12-
php:
13-
- 5.5
14-
- 5.6
15-
- 7.0
16-
- 7.1
17-
- 7.2
18-
- nightly
19-
2012
# Matrix to test in every php version
2113
matrix:
2214
# Fast finish allows to set the build as "finished" even if the "allow_failures" matrix elements are not finished yet.
2315
fast_finish: true
16+
include:
17+
- php: 7.2
18+
- php: nightly
2419
allow_failures:
25-
- php: 5.5
26-
- php: 5.6
2720
- php: nightly
2821

2922
# Install composer dependencies
@@ -32,4 +25,4 @@ install:
3225

3326
# Run script
3427
script:
35-
- php -d memory-limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit
28+
- ./vendor/bin/simple-phpunit

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
### 2018-11-25
5+
- Updated Makefile
6+
- phpunit.xml.dist whitelist bug
7+
- gitignore /coverage
8+
- Updated README
9+
- Updated travis
10+
411
### 2018-10-10
512
- Travis continuous integration
613

Makefile

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,92 @@
11

22
# Run "make" to print help
33
# If you want to add a help message for your rule, just add : "## My help for this rule", on the previous line
4-
# You can give "make" arguments with this syntax: PARAMETER=VALUE
54

6-
.PHONY: help
5+
.PHONY: help tests coverage composer-install uninstall
76

87
# Colors
9-
COLOR_TITLE = \033[1;41m
10-
COLOR_CAPTION = \033[1;44m
11-
COLOR_BOLD = \033[1;34m
12-
COLOR_LABEL = \033[1;32m
13-
COLOR_DANGER = \033[31m
14-
COLOR_SUCCESS = \033[32m
15-
COLOR_WARNING = \033[33m
16-
COLOR_SECONDARY = \033[34m
17-
COLOR_INFO = \033[35m
18-
COLOR_PRIMARY = \033[36m
19-
COLOR_DEFAULT = \033[0m
20-
21-
# Date / Time
22-
DATE=$(shell date -I)
23-
DATETIME=$(shell date '+%Y-%m-%d %H:%M:%S')
24-
TIME=$(shell date -Ins)
25-
TIMESTAMP=$(shell date +%Y%m%d%H%M%S)
26-
EPOCH=$(shell date +%s)
27-
DAY=$(shell LANG=C date +%A)
28-
29-
# Local vars
30-
ifeq (${OS}, Windows_NT)
31-
SYSTEM=${OS}
32-
else
33-
SYSTEM=$(shell uname -s)
34-
endif
35-
36-
WHOAMI=$(shell whoami)
37-
38-
BASEDIR=$(shell basename `git rev-parse --show-toplevel 2>/dev/null` 2>/dev/null)
39-
# get lastest tag from git repository
40-
VERSION=$(shell echo `git describe --exact-match --abbrev=0 2>/dev/null`)
41-
42-
# parameters (usage parameter=value)
43-
parameter?=''
8+
COLOR_TITLE = \033[1;41m
9+
COLOR_CAPTION = \033[1;44m
10+
COLOR_LABEL = \033[1;32m
11+
COLOR_WARNING = \033[33m
12+
COLOR_INFO = \033[35m
13+
COLOR_PRIMARY = \033[36m
14+
COLOR_DEFAULT = \033[0m
15+
16+
# get correct console executable
17+
CONSOLE=$(shell if [ -f ./app/console ]; then echo './app/console'; elif [ -f ./bin/console ]; then echo './bin/console'; fi)
18+
# get correct public folder
19+
PUBLIC=$(shell if [ -d ./web ]; then echo './web'; elif [ -d ./public ]; then echo './public'; else echo './'; fi)
4420

4521
## Print this help
4622
help:
47-
@printf "${COLOR_TITLE}TangoMan ${BASEDIR} ${VERSION}${COLOR_DEFAULT}\n\n"
48-
49-
@printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}${DATETIME}${COLOR_DEFAULT}\n"
50-
@printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}${WHOAMI}${COLOR_DEFAULT}\n"
51-
@printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}${SYSTEM}${COLOR_DEFAULT}\n\n"
23+
@printf "${COLOR_TITLE}TangoMan $(shell basename ${CURDIR}) ${COLOR_DEFAULT}\n\n"
24+
@printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}$(shell date '+%Y-%m-%d %H:%M:%S')${COLOR_DEFAULT}\n"
25+
@printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}$(shell whoami)${COLOR_DEFAULT}\n"
26+
@printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}$(shell uname -s)${COLOR_DEFAULT}\n\n"
5227

5328
@printf "${COLOR_CAPTION}description:${COLOR_DEFAULT}\n\n"
5429
@printf "$(COLOR_WARNING) Callback Symfony Twig Extension Bundle${COLOR_DEFAULT}\n\n"
5530

5631
@printf "${COLOR_CAPTION}Usage:${COLOR_DEFAULT}\n\n"
57-
@printf "$(COLOR_WARNING) make tests${COLOR_DEFAULT}\n\n"
32+
@printf "$(COLOR_WARNING) make test${COLOR_DEFAULT}\n\n"
5833

5934
@printf "${COLOR_CAPTION}Available commands:${COLOR_DEFAULT}\n\n"
60-
@awk '/^### .+$$/ { printf "\n${COLOR_BOLD}%s${COLOR_DEFAULT}\n", substr($$0, 5) } \
61-
/^[a-zA-Z\-\_0-9\@]+:/ { \
35+
@awk '/^[a-zA-Z\-\_0-9\@]+:/ { \
6236
HELP_LINE = match(LAST_LINE, /^## (.*)/); \
6337
HELP_COMMAND = substr($$1, 0, index($$1, ":")); \
6438
HELP_MESSAGE = substr(LAST_LINE, RSTART + 3, RLENGTH); \
65-
printf " ${COLOR_LABEL}%-8s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \
39+
printf " ${COLOR_LABEL}%-16s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \
6640
} \
6741
{ LAST_LINE = $$0 }' ${MAKEFILE_LIST}
6842

69-
## Run test suite
70-
tests: update run
71-
72-
## Update composer dependencies
73-
update:
43+
## Run tests
44+
tests:
45+
@if [ ! -d ./vendor ]; then \
46+
make --no-print-directory composer-install; \
47+
fi
48+
@if [ -x ./bin/phpunit ]; then \
49+
php -d memory-limit=-1 ./bin/phpunit --stop-on-failure; \
50+
elif [ -x ./vendor/bin/phpunit ]; then \
51+
bash ./vendor/bin/phpunit --stop-on-failure; \
52+
elif [ -x ./vendor/bin/simple-phpunit ]; then \
53+
php -d memory-limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure; \
54+
else \
55+
printf 'error: phpunit executable not found\n'; \
56+
exit 1; \
57+
fi
58+
59+
## Dump coverage (requires XDebug)
60+
coverage:
61+
@if [ ! -d ./vendor ]; then \
62+
make --no-print-directory composer-install; \
63+
fi
64+
@if [ -x ./bin/phpunit ]; then \
65+
php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage; \
66+
elif [ -x ./vendor/bin/phpunit ]; then \
67+
bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage; \
68+
elif [ -x ./vendor/bin/simple-phpunit ]; then \
69+
php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage; \
70+
else \
71+
printf 'error: phpunit executable not found\n'; \
72+
exit 1; \
73+
fi
7474
ifeq (${OS}, Windows_NT)
75-
composer update
75+
@start "${PUBLIC}/coverage/index.html"
7676
else
77-
php -d memory_limit=-1 `which composer` update
77+
@nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1
7878
endif
7979

80-
## Run test suite
81-
run:
80+
## Composer install Symfony project
81+
composer-install:
8282
ifeq (${OS}, Windows_NT)
83-
php -d memory_limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit --stop-on-failure
83+
composer install
8484
else
85-
php -d memory_limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure
85+
php -d memory-limit=-1 $(shell which composer) install
8686
endif
8787

88-
## Delete vendors
89-
clean:
90-
rm -rf /vendor
91-
rm -f composer.lock
88+
## Remove vendors, var/cache, var/logs & var/sessions
89+
uninstall:
90+
rm -f ./composer.lock
91+
rm -rf ./coverage
92+
rm -rf ./vendor

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ $ make tests
109109

110110
On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) first to execute make script.
111111

112+
If you have XDebug installed, you can generate code coverage report with:
113+
```bash
114+
$ make coverage
115+
```
116+
112117
Note
113118
====
114119

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tangoman/callback-bundle",
33
"description": "Callback Symfony Twig Extension Bundle",
4-
"version": "2.1.2",
4+
"version": "2.2.0",
55
"license": "MIT",
66
"type": "library",
77
"keywords": [

phpunit.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
<directory>Tests/</directory>
1313
</testsuite>
1414
</testsuites>
15+
16+
<!-- whitelist is mandatory as of PHPUnit 5.0
17+
https://github.com/sebastianbergmann/phpunit-documentation/issues/335 -->
18+
<filter>
19+
<whitelist processUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">./TwigExtension/</directory>
21+
</whitelist>
22+
</filter>
1523
</phpunit>

0 commit comments

Comments
 (0)