| Class | Test::Unit::TestCase |
| In: |
lib/test/unit/systemtest.rb
|
| Parent: | Object |
# File lib/test/unit/systemtest.rb, line 55
55: def assert_coredump(app, *args)
56: out, err, status = run_app(app, args)
57: assert_equal(true, status.coredump?,
58: "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} did not coredump.")
59: yield(out, err, status) if block_given?
60: end
# File lib/test/unit/systemtest.rb, line 48
48: def assert_failure(app, *args)
49: out, err, status = run_app(app, args)
50: assert_equal(false, status.success?,
51: "No failure running #{[app,args].delete_if { |i| i.empty? }.join(" ")}.")
52: yield(out, err, status) if block_given?
53: end
# File lib/test/unit/systemtest.rb, line 61
61: def assert_no_coredump(app, *args)
62: out, err, status = run_app(app, args)
63: assert_equal(false, status.coredump?,
64: "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} caused coredump.")
65: yield(out, err, status) if block_given?
66: end
# File lib/test/unit/systemtest.rb, line 68
68: def assert_stopped(app, *args)
69: out, err, status = run_app(app, args)
70: assert_equal(true, status.stopped?,
71: "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} not stopped.")
72: yield(out, err, status) if block_given?
73: end
# File lib/test/unit/systemtest.rb, line 39
39: def assert_success(app, *args)
40: args.compact!
41: out, err, status = run_app(app, args)
42: assert_equal(true, status.success?,
43: "Failure running #{[app,args].delete_if { |i| i.empty? }.join(" ")} "+
44: "with error(s):\n => stderr: '#{err}'\n => stdout: '#{out}'.")
45: yield(out, err, status) if block_given?
46: end
the above is having problems. I don‘t know why
# File lib/test/unit/systemtest.rb, line 29
29: def run_app(app, *args)
30: cmd = "#{app} #{args.join(" ")}"
31: puts "==> Command: #{cmd}" if $DEBUG
32: out = `#{cmd} 2> stderr.txt`
33: status = $?
34: err = File.read("stderr.txt")
35: File.delete("stderr.txt")
36: [out, err, status]
37: end
# File lib/test/unit/systemtest.rb, line 9
9: def run_app(app, *args)
10: cmd = [app, args].flatten.join(" ")
11: out = nil
12: err = nil
13: Timeout::timeout(5) {
14: status = Open4.popen4(cmd) { |cid, stdin, stdout, stderr|
15: out = stdout.read
16: err = stderr.read
17: stdin.close_write
18: }
19: }
20: rescue(Timeout::Error) => err
21: puts "ERROR running #{app} #{args}"
22: puts err
23: puts err.backtrace
24: [out, err, status]
25: end