Skip to content

Commit 5c245cd

Browse files
committed
update
1 parent 45bd7d3 commit 5c245cd

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

lib/stack-service-base/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module StackServiceBase
2-
VERSION = '0.0.93'
2+
VERSION = '0.0.94'
33
end

spec/safe_exec_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'open3'
2+
require 'rbconfig'
3+
4+
RSpec.describe 'SafeExec self-test' do
5+
let(:safe_exec_file) { File.expand_path('../lib/stack-service-base/safe_exec.rb', __dir__) }
6+
7+
it 'runs successfully when executed directly' do
8+
stdout, stderr, status = Open3.capture3({ 'RUBYOPT' => nil }, RbConfig.ruby, safe_exec_file)
9+
10+
aggregate_failures do
11+
expect(status.success?).to be(true), -> { "stderr: #{stderr}\nstdout: #{stdout}" }
12+
expect(stderr).to eq('')
13+
expect(stdout).to include('[self-test] capture with streaming')
14+
expect(stdout).to include('success?: true')
15+
expect(stdout).to include('stdout: "out\n"')
16+
expect(stdout).to include('stderr: "err\n"')
17+
expect(stdout).to include('[self-test] capture! exit error')
18+
expect(stdout).to include('exit_error: Command failed: bash -lc echo boom >&2; exit 7 with exit status 7')
19+
expect(stdout).to include('stderr: "boom\n"')
20+
expect(stdout).to include('[self-test] call data result')
21+
expect(stdout).to include('data: {ok: true, items: [1, 2, 3]}')
22+
expect(stdout).to include('[self-test] call timeout')
23+
expect(stdout).to match(/timeout: (SafeExec::TimeoutError|Timeout::Error): Timed out after 1s/)
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)