Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/142493
Change subject: Add basic tests
......................................................................
Add basic tests
Use MW Code conventions. Thanks for MobileFrontend for dev-scripts :)
Change-Id: I41522d4287b8c10ee0273aaa1cc0f6b078b6d9b9
---
A .gitignore
A Makefile
A composer.json
A composer.lock
A composer.phar
A dev-scripts/phpcheck.sh
A dev-scripts/phplint.sh
A dev-scripts/pre-commit
8 files changed, 157 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleLogin
refs/changes/93/142493/1
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..208a599
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+vendor/*
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d780663
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,10 @@
+phpcheck:
+ @dev-scripts/phpcheck.sh
+
+phplint: phpcheck
+ @dev-scripts/phplint.sh
+
+tests: phplint
+
+installhooks:
+ ln -sf ${PWD}/dev-scripts/pre-commit .git/hooks/pre-commit
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..aff630b
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,5 @@
+{
+ "require-dev": {
+ "squizlabs/php_codesniffer": "1.*"
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..30dd701
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,101 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at
http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "hash": "b6f8674efff7c052a6d1a62583adf1a4",
+ "packages": [
+
+ ],
+ "packages-dev": [
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "1.5.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "396178ada8499ec492363587f037125bf7b07fcc"
+ },
+ "dist": {
+ "type": "zip",
+ "url":
"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/396178ada8499ec492363587f037125bf7b07fcc",
+ "reference": "396178ada8499ec492363587f037125bf7b07fcc",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "php": ">=5.1.2"
+ },
+ "suggest": {
+ "phpunit/php-timer": "dev-master"
+ },
+ "bin": [
+ "scripts/phpcs"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-phpcs-fixer": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "CodeSniffer.php",
+ "CodeSniffer/CLI.php",
+ "CodeSniffer/Exception.php",
+ "CodeSniffer/File.php",
+ "CodeSniffer/Report.php",
+ "CodeSniffer/Reporting.php",
+ "CodeSniffer/Sniff.php",
+ "CodeSniffer/Tokens.php",
+ "CodeSniffer/Reports/",
+ "CodeSniffer/CommentParser/",
+ "CodeSniffer/Tokenizers/",
+ "CodeSniffer/DocGenerators/",
+ "CodeSniffer/Standards/AbstractPatternSniff.php",
+ "CodeSniffer/Standards/AbstractScopeSniff.php",
+ "CodeSniffer/Standards/AbstractVariableSniff.php",
+ "CodeSniffer/Standards/IncorrectPatternException.php",
+ "CodeSniffer/Standards/Generic/Sniffs/",
+ "CodeSniffer/Standards/MySource/Sniffs/",
+ "CodeSniffer/Standards/PEAR/Sniffs/",
+ "CodeSniffer/Standards/PSR1/Sniffs/",
+ "CodeSniffer/Standards/PSR2/Sniffs/",
+ "CodeSniffer/Standards/Squiz/Sniffs/",
+ "CodeSniffer/Standards/Zend/Sniffs/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS
files and detects violations of a defined set of coding standards.",
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2014-05-01 03:07:07"
+ }
+ ],
+ "aliases": [
+
+ ],
+ "minimum-stability": "stable",
+ "stability-flags": [
+
+ ],
+ "platform": [
+
+ ],
+ "platform-dev": [
+
+ ]
+}
diff --git a/composer.phar b/composer.phar
new file mode 100755
index 0000000..c3711d6
--- /dev/null
+++ b/composer.phar
Binary files differ
diff --git a/dev-scripts/phpcheck.sh b/dev-scripts/phpcheck.sh
new file mode 100755
index 0000000..171db41
--- /dev/null
+++ b/dev-scripts/phpcheck.sh
@@ -0,0 +1,4 @@
+if [ ! -f composer.phar ]; then
+ curl -sS https://getcomposer.org/installer | php
+fi
+php composer.phar install
diff --git a/dev-scripts/phplint.sh b/dev-scripts/phplint.sh
new file mode 100755
index 0000000..583be01
--- /dev/null
+++ b/dev-scripts/phplint.sh
@@ -0,0 +1,22 @@
+command -v vendor/bin/phpcs >/dev/null 2>&1 || { echo >&2 "phpcs required but
it's not installed. Aborting. Run 'make phpcheck'"; exit 1; }
+
+if [ -z ${MEDIAWIKI_CODESNIFFER_CONFIG_DIR+x} ]
+ then
+ echo "MEDIAWIKI_CODESNIFFER_CONFIG_DIR is unset"
+ echo "Please setup mediawiki/tools/codesniffer"
+ echo "Then add 'export
MEDIAWIKI_CODESNIFFER_CONFIG_DIR=path/MediaWiki'"
+ exit 1
+fi
+
+for file in `find . -name '*.php' -not -path './admin/src/*' -not -path
'./admin/lib/*' -not -path './vendor/*'`; do
+ RESULTS=`php -l $file`
+ if [ "$RESULTS" != "No syntax errors detected in $file" ]; then
+ echo $RESULTS
+ exit 1
+ fi
+
+ vendor/bin/phpcs $file --standard=$MEDIAWIKI_CODESNIFFER_CONFIG_DIR
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+done
diff --git a/dev-scripts/pre-commit b/dev-scripts/pre-commit
new file mode 100755
index 0000000..6d18ee5
--- /dev/null
+++ b/dev-scripts/pre-commit
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# Enable this pre-commit hook by executing the following from the project root
directory
+# $ ln -s $PWD/dev-scripts/pre-commit .git/hooks/pre-commit
+# Copied from Extension:MobileFrontend and edited. Thanks!
+
+# check for trailing whitespace
+if [[ `git diff --cached --check` ]]; then
+ git diff --cached --check
+ exit 1
+fi
+
+if git diff --name-only --cached | grep -P '\.*php$' ; then
+ make phplint || exit 1
+fi
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/142493
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41522d4287b8c10ee0273aaa1cc0f6b078b6d9b9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GoogleLogin
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits