2014-01-22 155 views

回答

3

转到“疥方案”,并选择方案,然后展开“测试”,然后选择“预动作”,并增加了新的运行脚本:

enter image description here

选择“提供编译器的设置:” enter image description here

我认为你正在寻找的变量是${SRCROOT}

+0

答案与图片让我快乐! – Groot

+0

你知道我可以如何访问ruby脚本吗?它目前位于proyect_root/Tests/server.rb下。有没有指向根的环境变量? 谢谢 – bilby91

+1

我添加了另一张照片让@Filip更加快乐! – Sebastian

2

除了@Sebastian答案,确保在ruby命令后添加&,因为没有它,sinatra将阻止您的测试执行。

此外,在需要杀死ruby进程的情况下关注后续操作也很有用。 以下示例使用bundler和rackup启动sinatra。

例预动作脚本:

exec > /tmp/tests-pre-actions.log 2>&1 
source ~/.bash_profile 

SERVER_PATH="${PROJECT_DIR}"/"Server" 
cd "$SERVER_PATH" 
bundle exec rackup > /tmp/server.log 2>&1 & 

#get the PID of the process 
PID=$! 

#save PID to file 
echo $PID > /tmp/sinatra.pid 

的动作后脚本示例:

exec > /tmp/tests-pre-actions.log 2>&1 
source ~/.bash_profile 

PID=$(</tmp/sinatra.pid) 
echo "Sinatra server pid $PID" 
kill -9 $PID 

config.ru为rackup宝石:

require './server' 
trap('TERM') {Process.kill 'INT', Process.pid} 
puts 'Run sinatra' 
run Sinatra::Application 
相关问题