从bash脚本目录运行test / unit / RbcTest.php无效

时间:2012-02-20 11:43:26

标签: bash jenkins

我在测试/单元目录中有我的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

感谢

1 个答案:

答案 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"

至于为什么你的脚本不起作用,如果你能确切地说明你得到的错误会有所帮助。也许你可以试试这个:

  1. 将您的Bash脚本标记为可执行文件:chmod +x script.sh
  2. 通过将此权限放在脚本顶部来指定解释器:#!/bin/bash