mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
Show process name during inspec output
Signed-off-by: Juan Carlos Castillo Cano <jccastillocano@gmail.com>
This commit is contained in:
parent
1cd2519d90
commit
58ef61f1f4
2 changed files with 13 additions and 2 deletions
|
@ -21,9 +21,10 @@ module Inspec::Resources
|
|||
:states
|
||||
|
||||
def initialize(grep)
|
||||
@grep = grep
|
||||
# turn into a regexp if it isn't one yet
|
||||
if grep.class == String
|
||||
grep = '(/[^/]*)*'+grep if grep[0] != '/'
|
||||
grep = '(/[^/]*)*' + grep if grep[0] != '/'
|
||||
grep = Regexp.new('^' + grep + '(\s|$)')
|
||||
end
|
||||
all_cmds = ps_axo
|
||||
|
@ -38,7 +39,7 @@ module Inspec::Resources
|
|||
end
|
||||
|
||||
def to_s
|
||||
'Processes'
|
||||
"Processes #{@grep.class == String ? @grep : @grep.inspect}"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -70,4 +70,14 @@ describe 'Inspec::Resources::Processes' do
|
|||
_(resource.users.sort).must_equal ['opscode-pgsql']
|
||||
_(resource.states.sort).must_equal ['Ss']
|
||||
end
|
||||
|
||||
it 'command name matches with output (string)' do
|
||||
resource = MockLoader.new(:centos6).load_resource('processes', 'mysqld')
|
||||
_(resource.to_s).must_equal 'Processes mysqld'
|
||||
end
|
||||
|
||||
it 'command name matches with output (regex)' do
|
||||
resource = MockLoader.new(:centos6).load_resource('processes', /mysqld/)
|
||||
_(resource.to_s).must_equal 'Processes /mysqld/'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue