diff --git a/.gitmodules b/.gitmodules index a8d767581..30ef58db1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,3 +11,6 @@ [submodule "tests/preprocessor"] path = tests/preprocessor url = https://github.com/pmmp/preprocessor.git +[submodule "tests/plugins/PocketMine-DevTools"] + path = tests/plugins/PocketMine-DevTools + url = https://github.com/pmmp/PocketMine-DevTools.git diff --git a/.travis.yml b/.travis.yml index 86ec50599..02a22c3a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,12 @@ php: - 7.0 before_script: - - mkdir plugins -# - curl -o DevTools.zip "https://jenkins.pmmp.io/job/PocketMine-MP%20DevTools/lastSuccessfulBuild/artifact/*zip*/artifacts.zip" -# - unzip DevTools.zip -# - mv *.phar plugins - pecl install channel://pecl.php.net/pthreads-3.1.6 - pecl install channel://pecl.php.net/weakref-0.3.2 - echo | pecl install channel://pecl.php.net/yaml-2.0.0 - - git clone https://github.com/pmmp/PocketMine-DevTools.git -b api3 - - php PocketMine-DevTools/src/DevTools/ConsoleScript.php --make "./PocketMine-DevTools" --relative "./PocketMine-DevTools" --out "./plugins/DevTools.phar" script: - - ./tests/lint.sh && ./tests/run.sh + - ./tests/travis.sh notifications: email: false diff --git a/tests/lint.sh b/tests/lint.sh index a2aa579a1..eaf6a9a21 100755 --- a/tests/lint.sh +++ b/tests/lint.sh @@ -1,8 +1,19 @@ #!/bin/bash + +PHP_BINARY="php" + +while getopts "p:" OPTION 2> /dev/null; do + case ${OPTION} in + p) + PHP_BINARY="$OPTARG" + ;; + esac +done + echo Running PHP lint scans... shopt -s globstar for file in src/pocketmine/*.php src/pocketmine/**/*.php; do - OUTPUT=`php -l "$file"` - [ $? -ne 0 ] && echo -n "$OUTPUT" && exit 1 + OUTPUT=`"$PHP_BINARY" -l "$file"` + [ $? -ne 0 ] && echo -n "$OUTPUT" && exit 1 done echo Lint scan completed successfully. \ No newline at end of file diff --git a/tests/plugins/PocketMine-DevTools b/tests/plugins/PocketMine-DevTools new file mode 160000 index 000000000..b4cdd6175 --- /dev/null +++ b/tests/plugins/PocketMine-DevTools @@ -0,0 +1 @@ +Subproject commit b4cdd61755f328ec6441e0216a67f80bf09162f4 diff --git a/tests/run.sh b/tests/run.sh deleted file mode 100755 index 89c037330..000000000 --- a/tests/run.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -echo -e "version\nmakeserver\nstop\n" | php src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline --debug.level=2 -if ls plugins/DevTools/PocketMine*.phar >/dev/null 2>&1; then - echo Server phar created successfully. -else - echo No phar created! - exit 1 -fi diff --git a/tests/travis.sh b/tests/travis.sh new file mode 100755 index 000000000..4f53ec0a6 --- /dev/null +++ b/tests/travis.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +PHP_BINARY="php" + +while getopts "p:" OPTION 2> /dev/null; do + case ${OPTION} in + p) + PHP_BINARY="$OPTARG" + ;; + esac +done + +./tests/lint.sh -p "$PHP_BINARY" + +if [ $? -ne 0 ]; then + echo Lint scan failed! + exit 1 +fi + +cp -r tests/plugins plugins +"$PHP_BINARY" ./plugins/PocketMine-DevTools/src/DevTools/ConsoleScript.php --make ./plugins/PocketMine-DevTools --relative ./plugins/PocketMine-DevTools --out ./plugins/DevTools.phar +rm -rf ./plugins/PocketMine-DevTools + +echo -e "version\nmakeserver\nstop\n" | "$PHP_BINARY" src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline --debug.level=2 +if ls plugins/DevTools/PocketMine*.phar >/dev/null 2>&1; then + echo Server phar created successfully. +else + echo No phar created! + exit 1 +fi