【发布时间】:2018-09-21 18:49:15
【问题描述】:
我遇到了与列出的几乎相同的问题 (Why is Rake not able to invoke multiple tasks consecutively?),但他们的解决方案对我不起作用!随着我的代码库的增长,我会定期收到误报,我希望只重新运行失败的测试。
以下内容在下一行完成后退出 Rake::Task['test:example_1'].execute (并且不会碰到 byebyg / binding.pry )。
SPEC_PATH = 'spec/platform/**/*.rb'
namespace :test do
RSpec::Core::RakeTask.new('example_1') do |t|
t.rspec_opts = ["-Ilib","--format documentation","--color --tty"]
t.pattern = SPEC_PATH
end
RSpec::Core::RakeTask.new('example_2') do |t|
t.rspec_opts = ["-Ilib","--format documentation","--color --tty", "--only-failures"]
t.pattern = SPEC_PATH
end
desc 'Run "test" task, then rerun failed tests'
RSpec::Core::RakeTask.new('rerun') do |t|
Rake::Task['test:example_1'].execute
Rake::Task['test:example_2'].execute
end
end
包括--dry-run 到test:example_1 将同时运行,但显然不会产生任何故障,因此没有任何帮助。是否需要设置配置以防止完成后退出?如果是这样的话,我还没有找到。
谢谢。
*编辑:
在我的执行显示中包含--trace:
** Invoke test:rerun (first_time)
** Execute test:rerun
** Execute test:test_1
开始但退出时什么都没有。
**edit:这是另一个例子,几乎完全符合我正在尝试做的事情,就像我正在尝试做的一样 (https://sourcediving.com/a-better-way-to-tame-your-randomly-failing-specs-29040dc0ed24)。 对于它的价值,我正在运行 Ruby 2.3.1 和 RSpec 3.6
【问题讨论】: