forked from fluent-plugins-nursery/fluent-rubyprof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrubyprof_spec.rb
More file actions
53 lines (42 loc) · 1.51 KB
/
rubyprof_spec.rb
File metadata and controls
53 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'json'
require 'spec_helper'
require 'fluent/rubyprof'
describe Fluent::Rubyprof do
CONFIG_PATH = File.join(File.dirname(__FILE__), 'fluent.conf')
BIN_DIR = File.join(ROOT, 'bin')
OUTPUT_FILE = File.join(File.dirname(__FILE__), 'test.txt')
context '#parse_options' do
it 'incorrect subcommand' do
expect { Fluent::Rubyprof.new.parse_options(['foo']) }.to raise_error(OptionParser::InvalidOption)
end
it 'correct measure_mode' do
expect { Fluent::Rubyprof.new.parse_options(['start', '-m', 'PROCESS_TIME']) }.not_to raise_error
end
it 'incorrect measure_mode' do
expect { Fluent::Rubyprof.new.parse_options(['start', '-m', 'foo']) }.to raise_error(OptionParser::InvalidOption)
end
it 'correct printer' do
expect { Fluent::Rubyprof.new.parse_options(['start', '-P', 'graph']) }.not_to raise_error
end
it 'incorrect printer' do
expect { Fluent::Rubyprof.new.parse_options(['start', '-P', 'bar']) }.to raise_error(OptionParser::InvalidArgument)
end
end
context 'profiling' do
before :all do
@fluentd_pid = spawn('fluentd', '-c', CONFIG_PATH, out: '/dev/null')
sleep 2
system("#{File.join(BIN_DIR, 'fluent-rubyprof')} start")
sleep 2
system("#{File.join(BIN_DIR, 'fluent-rubyprof')} stop -o #{OUTPUT_FILE}")
sleep 1
end
after :all do
Process.kill(:TERM, @fluentd_pid)
Process.waitall
end
it 'should output' do
expect(File.size?(OUTPUT_FILE)).to be_truthy
end
end
end