我在测试/单元目录中有我的RbcTest.php 在bash脚本中,单词“test”是一个关键字吗? 我使用vi编辑器,它的单词是黄色的,只要我将测试更改为测试整个路径是紫色的吗?
export WORKSPACE=phoenix
export SYMFONY=$WORKSPACE/usr/share/php/data/symfony
(cd $WORKSPACE
echo ${PWD}
echo "6. Clearing the cache"
./symfony cc
echo "7. Run unit test"
php test/unit/RbcTest.php
)
警告和错误:
7. Run unit test
PHP Warning: require_once(/usr/share/php/symfony/autoload/sfCoreAutoload.class.php): failed to open stream: No such file or directory in /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/config/ProjectConfiguration.class.php on line 3
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/unit/RbcTest.php:0
PHP 2. require_once() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/unit/RbcTest.php:3
PHP 3. require_once() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/bootstrap/unit.php:14
PHP Fatal error: require_once(): Failed opening required '/usr/share/php/symfony/autoload/sfCoreAutoload.class.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/config/ProjectConfiguration.class.php on line 3
PHP Stack trace:
PHP 1. {main}() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/unit/RbcTest.php:0
PHP 2. require_once() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/unit/RbcTest.php:3
PHP 3. require_once() /var/lib/jenkins/workspace/b32b733b59ba6be9884da7427bee5c95/phoenix/test/bootstrap/unit.php:14
感谢
答案 0 :(得分:1)
在Bash脚本中,test
确实是一个关键字,尽管在这种情况下,vi只是混淆了。例如,您可以在test
子句中使用if
:
if test -f /etc/fstab; then
echo "/etc/fstab exists"
fi
我从不使用此键盘,因为您也可以使用[
代替,我发现它更漂亮:
if [ -f /etc/fstab ]; then
echo "/etc/fstab exists"
fi
要避免vi将其突出显示为关键字,请使用字符串:
php "test/unit/RbcTest.php"
至于为什么你的脚本不起作用,如果你能确切地说明你得到的错误会有所帮助。也许你可以试试这个:
chmod +x script.sh
#!/bin/bash