blob: 529e899f6740aba20b2a910bafe18d510cab76b7 (
plain)
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
|
class LeapTest
#
# works like pgrep command line
# return an array of hashes like so [{:pid => "1234", :process => "ls"}]
#
def pgrep(match)
output = `pgrep --full --list-name '#{match}'`
output.each_line.map{|line|
pid = line.split(' ')[0]
process = line.gsub(/(#{pid} |\n)/, '')
if process =~ /pgrep --full --list-name/
nil
else
{:pid => pid, :process => process}
end
}.compact
end
def assert_running(process)
assert pgrep(process).any?, "No running process for #{process}"
end
#
# runs the specified command, failing on a non-zero exit status.
#
def assert_run(command)
output = `#{command}`
if $?.exitstatus != 0
fail "Error running `#{command}`:\n#{output}"
end
end
end
|