Skip to content

Commit 27f1d54

Browse files
author
Oleksii Korshenko
committed
MAGETWO-52616: Bug Fixes Contribution
Merge remote-tracking branch 'origin/MAGETWO-50237' into pull-request
2 parents 5b8b78d + dcef2ff commit 27f1d54

File tree

6 files changed

+118
-100
lines changed

6 files changed

+118
-100
lines changed

.travis.yml

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,39 @@
11
sudo: required
22
dist: trusty
3-
3+
addons:
4+
apt:
5+
packages:
6+
- mysql-server-5.6
7+
- mysql-client-core-5.6
8+
- mysql-client-5.6
9+
- postfix
410
language: php
511
php:
612
- 5.5
713
- 5.6
814
- 7.0
915
env:
10-
- TEST_SUITE=unit
11-
- TEST_SUITE=integration_part_1
12-
- TEST_SUITE=integration_part_2
13-
- TEST_SUITE=integration_integrity
14-
- TEST_SUITE=static
16+
global:
17+
- COMPOSER_BIN_DIR=~/bin
18+
- INTEGRATION_SETS=2
19+
matrix:
20+
- TEST_SUITE=unit
21+
- TEST_SUITE=integration INTEGRATION_INDEX=1
22+
- TEST_SUITE=integration INTEGRATION_INDEX=2
23+
- TEST_SUITE=static
1524
cache:
1625
apt: true
17-
directories:
18-
- $HOME/.composer/cache
19-
- $HOME/.cache/bin
26+
directories: $HOME/.composer/cache
2027
matrix:
2128
exclude:
2229
- php: 5.6
2330
env: TEST_SUITE=static
2431
- php: 7.0
2532
env: TEST_SUITE=static
26-
before_install:
27-
- sudo apt-get update -qq
28-
- sudo apt-get install -y -qq postfix
29-
- sh -c 'if [ "$CASHER_DIR" ]; then
30-
if [ -x $HOME/.cache/bin/composer ]; then
31-
$HOME/.cache/bin/composer self-update; echo '';
32-
else
33-
mkdir -p $HOME/.cache/bin;
34-
curl --connect-timeout 30 -sS https://getcomposer.org/installer
35-
| php -- --install-dir $HOME/.cache/bin/ --filename composer;
36-
fi
37-
fi'
38-
- export PATH="$HOME/.cache/bin:$PATH"
39-
before_script:
40-
# Mock mail
41-
- sudo service postfix stop
42-
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
43-
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
44-
# Disable xDebug
45-
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
46-
# Install MySQL 5.6, create DB for integration tests
47-
- >
48-
sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ] || [ '$TEST_SUITE' = 'integration_integrity' ]; then
49-
sudo apt-get remove -y -qq --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
50-
sudo apt-get -y -qq autoremove;
51-
sudo apt-get -y -qq autoclean;
52-
sudo apt-get install -y -qq mysql-server-5.6 mysql-client-5.6;
53-
mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;';
54-
mv dev/tests/integration/etc/install-config-mysql.travis.php.dist dev/tests/integration/etc/install-config-mysql.php;
55-
fi"
56-
# Change memory_limit for travis
57-
- echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
58-
- phpenv rehash;
59-
- composer install --no-interaction --prefer-dist
60-
script:
61-
# Unit tests
62-
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist; fi"
63-
# Integration tests
64-
- sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ]; then cd dev/tests/integration/; bash IntegationTestsForTravis.sh 2; fi"
65-
- sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.travis1; fi"
66-
- sh -c "if [ '$TEST_SUITE' = 'integration_part_2' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.travis2; fi"
67-
# Integration integrity tests
68-
- sh -c "if [ '$TEST_SUITE' = 'integration_integrity' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.dist testsuite/Magento/Test/Integrity; fi"
69-
# Static tests [Code Style]
70-
- sh -c "if [ '$TEST_SUITE' = 'static' ]; then cd dev/tests/static/; php get_github_changes.php --output-file='$TRAVIS_BUILD_DIR/dev/tests/static/testsuite/Magento/Test/_files/changed_files_ce.txt' --base-path='$TRAVIS_BUILD_DIR' --repo='https://github.com/magento/magento2.git' --branch='develop'; ./../../../vendor/bin/phpunit -c phpunit.xml.dist --filter 'Magento\\\\Test\\\\Php\\\\LiveCodeTest'; fi"
33+
before_install: ./dev/travis/before_install.sh
34+
install: composer install --no-interaction --prefer-dist
35+
before_script: ./dev/travis/before_script.sh
36+
script:
37+
- cd dev/tests/$TEST_SUITE
38+
- test $TEST_SUITE = "static" && TEST_FILTER='--filter "Magento\\Test\\Php\\LiveCodeTest"' || true
39+
- phpunit $TEST_FILTER

dev/tests/integration/IntegationTestsForTravis.sh

Lines changed: 0 additions & 44 deletions
This file was deleted.

dev/tests/integration/phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
</testsuite>
1919
<testsuite name="Magento Integration Tests">
2020
<directory suffix="Test.php">testsuite</directory>
21-
<exclude>testsuite/Magento/Test/Integrity</exclude>
2221
<exclude>testsuite/Magento/MemoryUsageTest.php</exclude>
2322
</testsuite>
2423
</testsuites>

dev/tests/integration/testsuite/Magento/DatabaseTest.php renamed to dev/tests/integration/testsuite/Magento/Test/Integrity/DatabaseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento;
6+
7+
namespace Magento\Test\Integrity;
78

89
use Magento\TestFramework\Helper\Bootstrap;
910

dev/travis/before_install.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright © 2016 Magento. All rights reserved.
4+
# See COPYING.txt for license details.
5+
6+
set -e
7+
trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR
8+
9+
# mock mail
10+
sudo service postfix stop
11+
echo # print a newline
12+
smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
13+
echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/sendmail.ini
14+
15+
# disable xdebug and adjust memory limit
16+
echo > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
17+
echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
18+
phpenv rehash;
19+
20+
# If env var is present, configure support for 3rd party builds which include private dependencies
21+
test -n "$GITHUB_TOKEN" && composer config github-oauth.github.com "$GITHUB_TOKEN" || true

dev/travis/before_script.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright © 2016 Magento. All rights reserved.
4+
# See COPYING.txt for license details.
5+
6+
set -e
7+
trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR
8+
9+
# prepare for test suite
10+
case $TEST_SUITE in
11+
integration)
12+
cd dev/tests/integration
13+
14+
test_set_list=$(find testsuite/* -maxdepth 1 -mindepth 1 -type d | sort)
15+
test_set_size=$(($(printf "$test_set_list" | wc -l)/INTEGRATION_SETS))
16+
17+
echo "==> preparing integration testsuite on index $INTEGRATION_INDEX with set size of $test_set_size"
18+
cp phpunit.xml.dist phpunit.xml
19+
20+
# remove memory usage tests if from any set other than the first
21+
if [[ $INTEGRATION_INDEX > 1 ]]; then
22+
echo " - removing testsuite/Magento/MemoryUsageTest.php"
23+
perl -pi -0e 's#^\s+<!-- Memory(.*?)</testsuite>\n##ims' phpunit.xml
24+
fi
25+
26+
# divide test sets up by indexed testsuites
27+
i=0; j=1
28+
for test_set in $test_set_list; do
29+
test_xml[j]+=" <directory suffix=\"Test.php\">$test_set</directory>\n"
30+
31+
if [[ $j -eq $INTEGRATION_INDEX ]]; then
32+
echo " + including $test_set"
33+
else
34+
echo " - excluding $test_set"
35+
fi
36+
37+
i=$((i+1))
38+
if [ $i -eq $test_set_size ] && [ $j -lt $INTEGRATION_SETS ]; then
39+
j=$((j+1))
40+
i=0
41+
fi
42+
done
43+
44+
# replace test sets for current index into testsuite
45+
perl -pi -e "s#\s+<directory.*>testsuite</directory>#${test_xml[INTEGRATION_INDEX]}#g" phpunit.xml
46+
47+
echo "==> testsuite preparation complete"
48+
49+
# create database and move db config into place
50+
mysql -uroot -e '
51+
SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION;
52+
CREATE DATABASE magento_integration_tests;
53+
'
54+
mv etc/install-config-mysql.travis.php.dist etc/install-config-mysql.php
55+
56+
cd ../../..
57+
;;
58+
static)
59+
cd dev/tests/static
60+
61+
echo "==> preparing changed files list"
62+
changed_files_ce="$TRAVIS_BUILD_DIR/dev/tests/static/testsuite/Magento/Test/_files/changed_files_ce.txt"
63+
php get_github_changes.php \
64+
--output-file="$changed_files_ce" \
65+
--base-path="$TRAVIS_BUILD_DIR" \
66+
--repo='https://github.com/magento/magento2.git' \
67+
--branch='develop'
68+
cat "$changed_files_ce" | sed 's/^/ + including /'
69+
70+
cd ../../..
71+
;;
72+
esac

0 commit comments

Comments
 (0)