Class: Test::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/systemtest.rb

Instance Method Summary collapse

Instance Method Details

#assert_coredump(app, *args) {|out, err, status| ... } ⇒ Object

Yields:

  • (out, err, status)


55
56
57
58
59
60
# File 'lib/test/unit/systemtest.rb', line 55

def assert_coredump(app, *args)
  out, err, status = run_app(app, args)
  assert_equal(true, status.coredump?,
    "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} did not coredump.")
  yield(out, err, status) if block_given?
end

#assert_failure(app, *args) {|out, err, status| ... } ⇒ Object

Yields:

  • (out, err, status)


48
49
50
51
52
53
# File 'lib/test/unit/systemtest.rb', line 48

def assert_failure(app, *args)
  out, err, status = run_app(app, args)
  assert_equal(false, status.success?,
    "No failure running #{[app,args].delete_if { |i| i.empty? }.join(" ")}.")
  yield(out, err, status) if block_given?
end

#assert_no_coredump(app, *args) {|out, err, status| ... } ⇒ Object

Yields:

  • (out, err, status)


61
62
63
64
65
66
# File 'lib/test/unit/systemtest.rb', line 61

def assert_no_coredump(app, *args)
  out, err, status = run_app(app, args)
  assert_equal(false, status.coredump?,
    "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} caused coredump.")
  yield(out, err, status) if block_given?
end

#assert_stopped(app, *args) {|out, err, status| ... } ⇒ Object

Yields:

  • (out, err, status)


68
69
70
71
72
73
# File 'lib/test/unit/systemtest.rb', line 68

def assert_stopped(app, *args)
  out, err, status = run_app(app, args)
  assert_equal(true, status.stopped?,
    "Running #{[app,args].delete_if { |i| i.empty? }.join(" ")} not stopped.")
  yield(out, err, status) if block_given?
end

#assert_success(app, *args) {|out, err, status| ... } ⇒ Object

Yields:

  • (out, err, status)


39
40
41
42
43
44
45
46
# File 'lib/test/unit/systemtest.rb', line 39

def assert_success(app, *args)
  args.compact!
  out, err, status = run_app(app, args)
  assert_equal(true, status.success?, 
    "Failure running #{[app,args].delete_if { |i| i.empty? }.join(" ")} "+
    "with error(s):\n => stderr: '#{err}'\n => stdout: '#{out}'.")
  yield(out, err, status) if block_given?
end

#run_app(app, *args) ⇒ Object

the above is having problems. I don’t know why



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/test/unit/systemtest.rb', line 29

def run_app(app, *args)
  cmd = [app, args].flatten.join(" ")
  out = nil
  err = nil
  Timeout::timeout(5) {
  status = Open4.popen4(cmd) { |cid, stdin, stdout, stderr|
    out = stdout.read
    err = stderr.read
    stdin.close_write
  }
  }
rescue(Timeout::Error) => err
  puts "ERROR running #{app} #{args}"
  puts err
  puts err.backtrace
  [out, err, status]
end