Skip to content

Commit 796fb19

Browse files
committed
Added tests
1 parent 7d084e8 commit 796fb19

30 files changed

+2605
-1
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,32 @@ php:
99
- 7.1
1010

1111
before_install:
12+
- sudo ln -s /home/travis/.phpenv/versions/$(phpenv version-name)/bin/phpize /usr/bin/
13+
- sudo ln -s /home/travis/.phpenv/versions/$(phpenv version-name)/bin/php-config /usr/bin/
1214
- export PHP_MAJOR="$(echo $TRAVIS_PHP_VERSION | cut -d '.' -f 1,2)"
1315

1416
install:
1517
- travis_retry composer self-update
1618
- travis_retry composer install --prefer-source --no-interaction --ignore-platform-reqs
19+
- sudo apt-get -qq update
20+
- bash build-ci/install_prereqs_$PHP_MAJOR.sh
1721
- php -m
1822

23+
before_script:
24+
- ulimit -c unlimited -S || true
25+
- echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern &> /dev/null
26+
1927
script:
2028
- vendor/bin/phpunit -d memory_limit=1024M --coverage-text --coverage-clover=coverage.clover
2129

2230
after_script:
2331
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
2432
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
33+
34+
after_failure:
35+
- bash build-ci/install_failure.sh
36+
37+
addons:
38+
apt:
39+
packages:
40+
- gdb

build-ci/ini/ssh2.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=ssh2.so

build-ci/install_failure.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
shopt -s nullglob
7+
export LC_ALL=C
8+
9+
for i in /tmp/core_*.*; do
10+
if [ -f "$i" -a "$(file "$i" | grep -o 'core file')" ]; then
11+
gdb -q $(phpenv which php) "$i" <<EOF
12+
set pagination 0
13+
backtrace full
14+
info registers
15+
x/16i \$pc
16+
thread apply all backtrace
17+
quit
18+
EOF
19+
fi
20+
done
21+
22+
$(phpenv which php) -m
23+
$(phpenv which php) -i

build-ci/install_php_5.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
install_ssh2() {
10+
sudo apt-get install -y -qq libssh2-1-dev libssh2-1
11+
12+
git clone -q https://github.com/php/pecl-networking-ssh2 -b php5 /tmp/ssh2
13+
cd /tmp/ssh2
14+
15+
phpize &> /dev/null
16+
./configure &> /dev/null
17+
18+
make --silent -j4 &> /dev/null
19+
make --silent install
20+
21+
if [ -z $(php -m | grep ssh2) ]; then
22+
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/ssh2.ini"
23+
fi
24+
}

build-ci/install_php_7.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
install_ssh2() {
10+
sudo apt-get install -y -qq libssh2-1-dev libssh2-1
11+
12+
git clone -q https://github.com/php/pecl-networking-ssh2 -b master /tmp/ssh2
13+
cd /tmp/ssh2
14+
15+
phpize &> /dev/null
16+
./configure &> /dev/null
17+
18+
make --silent -j4 &> /dev/null
19+
make --silent install
20+
21+
if [ -z $(php -m | grep ssh2) ]; then
22+
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/ssh2.ini"
23+
fi
24+
}

build-ci/install_php_common.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
pecl channel-update pecl.php.net || true
10+
echo `whoami`":1234" | sudo chpasswd
11+
12+
enable_extension() {
13+
if [ -z $(php -m | grep "${1}") ] && [ -f "${TRAVIS_BUILD_DIR}/build-ci/ini/${1}.ini" ]; then
14+
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/${1}.ini"
15+
fi
16+
}
17+
18+
install_extension() {
19+
INSTALLED=$(pecl list "${1}" | grep 'not installed')
20+
21+
if [ -z "${INSTALLED}" ]; then
22+
printf "\n" | pecl upgrade "${1}" &> /dev/null
23+
else
24+
printf "\n" | pecl install "${1}" &> /dev/null
25+
fi
26+
27+
enable_extension "${1}"
28+
}

build-ci/install_prereqs_5.6.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh
10+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_5.sh
11+
12+
install_ssh2

build-ci/install_prereqs_7.0.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh
10+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_7.sh
11+
12+
install_ssh2

build-ci/install_prereqs_7.1.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This source file is subject to the MIT License that is bundled
4+
# with this package in the MIT license.
5+
6+
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"
8+
9+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh
10+
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_7.sh
11+
12+
install_ssh2

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"autoload": {
3737
"psr-4": {
38-
"Dazzle\\SSH\\": "src/Event",
38+
"Dazzle\\SSH\\": "src/SSH",
3939
"Dazzle\\SSH\\Test\\": "test"
4040
}
4141
},

0 commit comments

Comments
 (0)