I have an RSpec file ./spec/pkg/abc_spec.rb
, using aruba
, with a test that routinely crashes when the command takes a long time, but does not crash if the command returns quickly.
It is failing with the stacktrace;
# <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)>'
The spec ./spec/pkg/abc_spec.rb
in question looks like this (the actual command has been replaced with a sleep that takes as long as it);
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
Is there some way to prevent it from erroring during the testing of a command that takes a long time?
Aruba tests can be configured to allow long running commands. The run_command
will respect the exit_timeout
configuration, which can be set in the spec file such as;
Aruba.configure do |config|
# some time longer than your run_command should take
config.exit_timeout = 21
end
For the provided block, a full example using this Aruba.configure
that works is;
require "aruba/rspec"
Aruba.configure do |config|
config.exit_timeout = 21
end
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