我编写了一个遍历每个目录的脚本,同时忽略了一些目录,然后执行了composer install
,phpunit
并且应该可以正常运行 - 大部分时间它都会运行 - 当我第二次运行它时。 ..
问题是phpunit
命令。该脚本来到该命令并打印出来:
...
+ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
+ phpunit
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
Usage: phpunit [options] UnitTest [UnitTest.php]
phpunit [options] <directory>
...
当我第二次运行它时:
...
+ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
+ phpunit
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)
...
我不应该两次运行脚本。该脚本的目标是:您是否有供应商目录?不,确定执行composer install
并运行phpunit
如果我们遇到一个包含routes-test.sh
文件的目录,我们就会做其他一些事情,但概念在结束时仍然是相同的一天。
所以,使用下面的脚本:
#!/usr/bin/env bash
set -eux
function run_tests() {
if [[ -f "composer.json" ]]; then
if [[ -d "vendor" ]]; then
composer update
phpunit
cd ../
else
composer install
phpunit
cd ../
fi
fi
}
function wordpress_routes() {
cd ../../
if [[ -d "trunk" ]]; then
cd trunk
if [[ -f "wp-tests-config.php" ]]; then
continue
else
cd ../Freya/Routes/
cp wp-tests-config.php ../../trunk/
fi
else
svn co http://develop.svn.wordpress.org/trunk/
cd Freya/Routes/
cp wp-tests-config.php ../../trunk/
fi
}
for f in *; do
if [[ -d $f ]]; then
if [[ $f != ".git" ]] && [[ $f != "bin" ]] && [[ $f != "docs" ]]; then
cd "$f/"
if [[ -f "routes-test" ]]; then
wordpress_routes
run_tests
fi
run_tests
fi
fi
done
为什么我要运行两次脚本才能让phpunit实际运行?
答案 0 :(得分:1)
之前我见过类似的东西。我遇到的问题是会话变量没有初始化,直到第一次运行之后 ...然后F5-refresh允许它正常工作。这可能是问题吗?