Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 从Rake任务调用guard会抑制输出_Ruby_Command Line_Rake_Guard - Fatal编程技术网

Ruby 从Rake任务调用guard会抑制输出

Ruby 从Rake任务调用guard会抑制输出,ruby,command-line,rake,guard,Ruby,Command Line,Rake,Guard,我试图将命令放置在Rakefile中调用测试,如下所示: desc 'Start tests' task :test do %x{ bundle exec guard --clear } end 尽管命令:bundle exec-guard--clear在其他情况下运行良好;当通过Rake任务调用测试输出时,它似乎被抑制。仅输出诸如运行规范或启动保护之类的通知 注意:我知道测试确实在工作,因为我有另一个通过tmux窗格颜色的通知系统 我想,我构建Rake任务的方式有问题吗?有什么想法吗?是

我试图将命令放置在Rakefile中调用测试,如下所示:

desc 'Start tests'
task :test do
  %x{ bundle exec guard --clear }
end
尽管命令:
bundle exec-guard--clear
在其他情况下运行良好;当通过Rake任务调用测试输出时,它似乎被抑制。仅输出诸如运行规范或启动保护之类的通知

注意:我知道测试确实在工作,因为我有另一个通过tmux窗格颜色的通知系统


我想,我构建Rake任务的方式有问题吗?有什么想法吗?

是的,在打印任何输出之前,%x将等待命令完成

例如:

puts %x{ sleep 1; echo "hello"; sleep 2; echo "world"; }
(在完成之前不会显示任何输出-然后立即显示所有内容。)

例2:

puts %x{ echo "hello"; sleep 100; }
(100秒后才会显示任何内容)

你想要的是:

Kernel.system("bundle exec guard --clear")


您的意思是说这会在命令完成之前一直打印输出吗?很抱歉,我真的不记得我现在用这个来测试它的是哪个项目。
Kernel.system(%w(bundle exec guard --clear))