我有一个使用aruba
的RSpec文件./spec/pkg/abc_spec.rb
,其中包含一个测试,当命令花费很长时间时,该测试通常会崩溃,但如果命令快速返回,则不会崩溃。
堆栈跟踪失败;
# <GEM_PATH>/aruba-2.1.0/lib/aruba/rspec.rb:35:in `block (3 levels) in <top (required)>'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/platforms/local_environment.rb:22:in `call'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/platforms/unix_platform.rb:79:in `with_environment'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/api/core.rb:222:in `block in with_environment'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/platforms/unix_environment_variables.rb:189:in `nest'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/api/core.rb:220:in `with_environment'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/rspec.rb:34:in `block (2 levels) in <top (required)>'
# <GEM_PATH>/aruba-2.1.0/lib/aruba/rspec.rb:25:in `block (2 levels) in <top (required)>'
有问题的规范./spec/pkg/abc_spec.rb
看起来像这样(实际的命令已经被替换为一个sleep,它需要的时间和它一样长);
require "aruba/rspec"
RSpec.describe "long running test", :type => :aruba do
context "long command" do
before { run_command('bash -c "sleep 20 && echo yikes"') }
it { expect(last_command_started).to have_output "yikes" }
end
end
在测试一个需要很长时间的命令时,有没有什么方法可以防止它出错?
1条答案
按热度按时间dgiusagp1#
Aruba测试可以配置为允许长时间运行命令。
run_command
将遵循exit_timeout
配置,可以在spec文件中设置,例如;对于所提供的块,使用此
Aruba.configure
的完整示例是: