Class: Scoutui::Commands::Sleep

Inherits:
Command
  • Object
show all
Defined in:
lib/scoutui/commands/sleep.rb

Instance Attribute Summary

Attributes inherited from Command

#bm, #cmd, #description, #drv, #enableAssert, #executed, #executed_result, #locator, #rc, #stanza

Instance Method Summary collapse

Methods inherited from Command

#assert?, #disableAssert, #disableAsserts, #enableAsserts, #executedResult, #getLocator, #initialize, #passed?, #result, #run, #setBenchmark, #setLocator, #setResult, #wasExecuted?

Constructor Details

This class inherits a constructor from Scoutui::Commands::Command

Instance Method Details

#execute(drv = nil, e = nil) ⇒ Object



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
# File 'lib/scoutui/commands/sleep.rb', line 7

def execute(drv=nil, e=nil)
  rc=false
  _req = Scoutui::Utils::TestUtils.instance.getReq()

  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Sleep.execute(#{@cmd})"

  begin

    s=nil

    if @cmd.match(/sleep\s*\((.*)\)/)
      s = @cmd.match(/sleep\s*\((.*)\)/)[1].to_s.strip
    end

    msec = s.to_f

    puts __FILE__ + (__LINE__).to_s + " start sleep: #{Time.now}"
    sleep msec
    puts __FILE__ + (__LINE__).to_s + " end sleep: #{Time.now}"

    rc=true

  rescue => ex
    Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Error during processing: #{$!}"
    Scoutui::Logger::LogMgr.instance.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
  end

  setResult(rc)
end