У меня есть два сценария bash. Один работает отлично, пока не достигнет вызова другого скрипта, тогда он исполняет этот сценарий отлично, но никогда не будет продолжаться в исходном скрипте, и я не уверен, как это сделать.Bash Not Continuing после вызова скрипта?
Этот скрипт, который запускает тесты в каждой папке определенного каталога. Каждая подпапка содержит файл phpunit.xml, и когда мы вводим каждую папку, мы запускаем composer install
и phpunit
.
Если каталог должен быть, Loader, Routes или Loop, мы будем вводить их и запускать скрипт в стороне от этого каталога.
Давайте посмотрим на run-tests
сценарий:
#!/usr/bin/env bash
set -e
function run_tests() {
if [[ -f "composer.json" ]] && [[ -f "phpunit.xml" ]]; then
if [[ -d "vendor" ]]; then
composer update
phpunit > /dev/null
phpunit
cd ../
else
composer install
phpunit > /dev/null
phpunit
cd ../
fi
else
cd ../
fi
}
for f in *; do
if [[ -d $f ]]; then
if [[ $f != ".git" ]] && [[ $f != "bin" ]] && [[ $f != "docs" ]]; then
cd "$f/"
if [[ $f == "Loader" ]]; then
if [[ -d "Assets" ]]; then
cd Assets/
chmod +x asset-test
./asset-test
fi
fi
if [[ $f == "Loop" ]]; then
cd Loop/
chmod +x loop-test
./loop-test
cd ../
fi
if [[ $f == "Routes" ]]; then
cd Routes/
chmod +x routes-test
./routes-test
cd ../
fi
run_tests
fi
fi
done
# Go Home.
cd /vagrant/Freya/
## Clean up time!
## Remove all vendor and composer.lock folders - just because.
for f in *; do
if [[ -d $f ]]; then
if [[ $f != ".git" ]] && [[ $f != "bin" ]] && [[ $f != "docs" ]]; then
cd "$f/"
rm -rf vendor composer.lock
cd ../
fi
fi
done
Мы можем видеть, что когда-то ему ввести проверку, чтобы увидеть, если каталог мы в это «петли», мы затем проверить, если есть каталог под названием " Активы "внутри. Предполагая, что это проходит, мы затем войти в этот каталог и запустить следующий сценарий:
#!/usr/bin/env bash
set -e
# Run Composer Install if vendor doesnt exist.
if [[ -d "vendor" ]]; then
composer update
else
composer install
fi
# Move up to the root directories and then get wordpress
cd ../../../
# Determine if the trunk is checked out and if we have a wp-test-config.php
# If not we need to create both or one or the other then run the tests.
#
# We run phpunit twice because the second time is when it actually runs.
if [[ -d "trunk" ]]; then
cd "trunk/"
if [[ -f "wp-tests-config.php" ]]; then
cd ../Freya/Loader/Assets
phpunit > /dev/null
phpunit
else
cd ../Freya/Loader/Assets
cp wp-tests-config.php ../../trunk/
phpunit > /dev/null
phpunit
fi
else
sudo svn co http://develop.svn.wordpress.org/trunk/
cd Freya/Loader/Assets
cp wp-tests-config.php ../../trunk/
phpunit > /dev/null
phpunit
fi
не Выпуск раз этот скрипт заканчивает, остальная часть первого сценария я вывесил НИКОГДА продолжается. Это похоже на то, что он просто умирает здесь. Мне нужно, чтобы завершился «родительский» скрипт, он должен вернуться из Loader/Assets
и перейти к следующей проверке. Но это не так. Сценарий просто существует.
Почему?
Примечание: Во втором сценарии мы можем предположить, что это идет в первый гнездовой, если заявление, в котором он проверяет, в каталоге багажника для wp-tests-config.php
Мы можем предположить, что это из-за следующий вывод, который был взят в плен из запустив первый сценарий:
$ bin/run-tests
Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/Freya/Exceptions/phpunit.xml
.
Time: 451 ms, Memory: 13.25Mb
OK (1 test, 1 assertion)
Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/Freya/Factory/phpunit.xml
...........
Time: 711 ms, Memory: 13.25Mb
OK (11 tests, 11 assertions)
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing freya/freya-templates (dev-master a33ecdb)
Cloning a33ecdb231b06dc8a7eef363edb177b8c134d55b
Writing lock file
Generating autoload files
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/Freya/Form/phpunit.xml
...............................................................
Time: 647 ms, Memory: 15.25Mb
OK (63 tests, 63 assertions)
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/Freya/Loader/Assets/phpunit.xml
...........
Time: 1.76 seconds, Memory: 38.00Mb
OK (11 tests, 11 assertions)
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/Freya/Loader/Assets/phpunit.xml
...........
Time: 1.79 seconds, Memory: 38.00Mb
Мы видим две проблемы здесь:
/vagrant/Freya/Loader/Assets/
запускаемые дважды.- В первом скрипте он не продолжается.
Попробуйте опубликовать минимальный пример, так как большинство людей не захотят читать все это, так что вы вряд ли получите ответ. –
JID ++.И вы можете обнаружить, что в процессе сжатия вашего скрипта в минимальный пример вы сами находите проблему! – ghoti