From 3ab9722a9f10d66f49783a1a428e946afcbee95e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 22 Jan 2017 15:26:16 +0000 Subject: [PATCH] Add DevTools as submodule, build DevTools for Travis Test --- .gitmodules | 3 +++ .travis.yml | 4 +--- tests/lint.sh | 15 +++++++++++++-- tests/plugins/PocketMine-DevTools | 1 + tests/run.sh | 8 -------- tests/travis.sh | 30 ++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 13 deletions(-) create mode 160000 tests/plugins/PocketMine-DevTools delete mode 100755 tests/run.sh create mode 100755 tests/travis.sh 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 0e290e326..b519207a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,12 @@ php: - 7.0 before_script: - - mkdir plugins - - wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.11.0/DevTools_v1.11.0.phar - 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 script: - - ./tests/lint.sh && ./tests/run.sh + - ./tests/travis.sh notifications: email: false \ No newline at end of file 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