From a56f599c7786ee7a8134e4f7752da427036f8002 Mon Sep 17 00:00:00 2001 From: Matthias Morin Date: Sun, 25 Nov 2018 02:33:58 +0100 Subject: [PATCH] [update] makefile + code coverage --- .gitignore | 6 +++ .travis.yml | 15 ++---- CHANGELOG.md | 7 +++ Makefile | 123 ++++++++++++++++++++++++----------------------- README.md | 5 ++ composer.json | 2 +- phpunit.xml.dist | 8 +++ 7 files changed, 93 insertions(+), 73 deletions(-) diff --git a/.gitignore b/.gitignore index f016360..1d1982c 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,9 @@ Temporary Items composer.lock +# ========================= +# PHPUnit +# ========================= + +/coverage + diff --git a/.travis.yml b/.travis.yml index 1207049..e0524aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,21 +9,14 @@ cache: directories: - $HOME/.composer/cache/files -php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - nightly - # Matrix to test in every php version matrix: # Fast finish allows to set the build as "finished" even if the "allow_failures" matrix elements are not finished yet. fast_finish: true + include: + - php: 7.2 + - php: nightly allow_failures: - - php: 5.5 - - php: 5.6 - php: nightly # Install composer dependencies @@ -32,4 +25,4 @@ install: # Run script script: - - php -d memory-limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit + - ./vendor/bin/simple-phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index f615b81..5f3d6ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +### 2018-11-25 + - Updated Makefile + - phpunit.xml.dist whitelist bug + - gitignore /coverage + - Updated README + - Updated travis + ### 2018-10-10 - Travis continuous integration diff --git a/Makefile b/Makefile index c1e944a..204d1ce 100644 --- a/Makefile +++ b/Makefile @@ -1,91 +1,92 @@ # Run "make" to print help # If you want to add a help message for your rule, just add : "## My help for this rule", on the previous line -# You can give "make" arguments with this syntax: PARAMETER=VALUE -.PHONY: help +.PHONY: help tests coverage composer-install uninstall # Colors -COLOR_TITLE = \033[1;41m -COLOR_CAPTION = \033[1;44m -COLOR_BOLD = \033[1;34m -COLOR_LABEL = \033[1;32m -COLOR_DANGER = \033[31m -COLOR_SUCCESS = \033[32m -COLOR_WARNING = \033[33m -COLOR_SECONDARY = \033[34m -COLOR_INFO = \033[35m -COLOR_PRIMARY = \033[36m -COLOR_DEFAULT = \033[0m - -# Date / Time -DATE=$(shell date -I) -DATETIME=$(shell date '+%Y-%m-%d %H:%M:%S') -TIME=$(shell date -Ins) -TIMESTAMP=$(shell date +%Y%m%d%H%M%S) -EPOCH=$(shell date +%s) -DAY=$(shell LANG=C date +%A) - -# Local vars -ifeq (${OS}, Windows_NT) - SYSTEM=${OS} -else - SYSTEM=$(shell uname -s) -endif - -WHOAMI=$(shell whoami) - -BASEDIR=$(shell basename `git rev-parse --show-toplevel 2>/dev/null` 2>/dev/null) -# get lastest tag from git repository -VERSION=$(shell echo `git describe --exact-match --abbrev=0 2>/dev/null`) - -# parameters (usage parameter=value) -parameter?='' +COLOR_TITLE = \033[1;41m +COLOR_CAPTION = \033[1;44m +COLOR_LABEL = \033[1;32m +COLOR_WARNING = \033[33m +COLOR_INFO = \033[35m +COLOR_PRIMARY = \033[36m +COLOR_DEFAULT = \033[0m + +# get correct console executable +CONSOLE=$(shell if [ -f ./app/console ]; then echo './app/console'; elif [ -f ./bin/console ]; then echo './bin/console'; fi) +# get correct public folder +PUBLIC=$(shell if [ -d ./web ]; then echo './web'; elif [ -d ./public ]; then echo './public'; else echo './'; fi) ## Print this help help: - @printf "${COLOR_TITLE}TangoMan ${BASEDIR} ${VERSION}${COLOR_DEFAULT}\n\n" - - @printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}${DATETIME}${COLOR_DEFAULT}\n" - @printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}${WHOAMI}${COLOR_DEFAULT}\n" - @printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}${SYSTEM}${COLOR_DEFAULT}\n\n" + @printf "${COLOR_TITLE}TangoMan $(shell basename ${CURDIR}) ${COLOR_DEFAULT}\n\n" + @printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}$(shell date '+%Y-%m-%d %H:%M:%S')${COLOR_DEFAULT}\n" + @printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}$(shell whoami)${COLOR_DEFAULT}\n" + @printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}$(shell uname -s)${COLOR_DEFAULT}\n\n" @printf "${COLOR_CAPTION}description:${COLOR_DEFAULT}\n\n" @printf "$(COLOR_WARNING) Callback Symfony Twig Extension Bundle${COLOR_DEFAULT}\n\n" @printf "${COLOR_CAPTION}Usage:${COLOR_DEFAULT}\n\n" - @printf "$(COLOR_WARNING) make tests${COLOR_DEFAULT}\n\n" + @printf "$(COLOR_WARNING) make test${COLOR_DEFAULT}\n\n" @printf "${COLOR_CAPTION}Available commands:${COLOR_DEFAULT}\n\n" - @awk '/^### .+$$/ { printf "\n${COLOR_BOLD}%s${COLOR_DEFAULT}\n", substr($$0, 5) } \ - /^[a-zA-Z\-\_0-9\@]+:/ { \ + @awk '/^[a-zA-Z\-\_0-9\@]+:/ { \ HELP_LINE = match(LAST_LINE, /^## (.*)/); \ HELP_COMMAND = substr($$1, 0, index($$1, ":")); \ HELP_MESSAGE = substr(LAST_LINE, RSTART + 3, RLENGTH); \ - printf " ${COLOR_LABEL}%-8s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \ + printf " ${COLOR_LABEL}%-16s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \ } \ { LAST_LINE = $$0 }' ${MAKEFILE_LIST} -## Run test suite -tests: update run - -## Update composer dependencies -update: +## Run tests +tests: + @if [ ! -d ./vendor ]; then \ + make --no-print-directory composer-install; \ + fi + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure; \ + else \ + printf 'error: phpunit executable not found\n'; \ + exit 1; \ + fi + +## Dump coverage (requires XDebug) +coverage: + @if [ ! -d ./vendor ]; then \ + make --no-print-directory composer-install; \ + fi + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage; \ + else \ + printf 'error: phpunit executable not found\n'; \ + exit 1; \ + fi ifeq (${OS}, Windows_NT) - composer update + @start "${PUBLIC}/coverage/index.html" else - php -d memory_limit=-1 `which composer` update + @nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1 endif -## Run test suite -run: +## Composer install Symfony project +composer-install: ifeq (${OS}, Windows_NT) - php -d memory_limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit --stop-on-failure + composer install else - php -d memory_limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure + php -d memory-limit=-1 $(shell which composer) install endif -## Delete vendors -clean: - rm -rf /vendor - rm -f composer.lock +## Remove vendors, var/cache, var/logs & var/sessions +uninstall: + rm -f ./composer.lock + rm -rf ./coverage + rm -rf ./vendor diff --git a/README.md b/README.md index e51b9f8..ea94435 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,11 @@ $ make tests 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. +If you have XDebug installed, you can generate code coverage report with: +```bash +$ make coverage +``` + Note ==== diff --git a/composer.json b/composer.json index 9dd88a1..5fadfac 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "tangoman/callback-bundle", "description": "Callback Symfony Twig Extension Bundle", - "version": "2.1.2", + "version": "2.2.0", "license": "MIT", "type": "library", "keywords": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 17cbf3f..cd002b7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,4 +12,12 @@ Tests/ + + + + + ./TwigExtension/ + +