Added "time(interval)" method. Also fixed some spelling errors.

This commit is contained in:
Johan Holmberg 2009-05-10 21:57:26 +00:00 committed by holmberg556
parent c4acd10b1e
commit 36eb26efb0
3 changed files with 26 additions and 6 deletions

View File

@ -547,7 +547,7 @@ $ cmdtest . t # all CMDTEST_*.rb files in both dirs
<td>Be more verbose.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--fast</span></kbd></td>
<td>Run fast without ensuring that timestamps of newly created/modfied
<td>Run fast without ensuring that timestamps of newly created/modified
files are unique. This could make it impossible for Cmdtest to detect
all side-effects of commands.</td></tr>
<tr><td class="option-group">
@ -556,11 +556,11 @@ all side-effects of commands.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--xml=<var>FILE</var></span></kbd></td>
<td>Write summary on JUnit XML format.
Useful when running under a continuouos integration server that
Useful when running under a continuous integration server that
understands JUnit reports.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-i</span></kbd></td>
<td>Run in &quot;incermental&quot; mode. <strong>experimental</strong>
<td>Run in &quot;incremental&quot; mode. <strong>experimental</strong>
Cmdtest will try to run only those test methods that are failed or
have changed since last time.</td></tr>
</tbody>
@ -666,6 +666,9 @@ For more details and examples see the section &quot;Matching standard output con
<dt><tt class="docutils literal"><span class="pre">assert(flag,</span> <span class="pre">msg=nil)</span></tt></dt>
<dd>Assert that <tt class="docutils literal"><span class="pre">flag</span></tt> is true. This assertion is a last resort, when no other
assertion fits. Should normally not be used.</dd>
<dt><tt class="docutils literal"><span class="pre">time(interval)</span></tt></dt>
<dd>Assert that executing the command took a number of seconds inside the
interval given as argument.</dd>
</dl>
</div>
<div class="section" id="helper-functions">

View File

@ -248,7 +248,7 @@ Options
Be more verbose.
--fast
Run fast without ensuring that timestamps of newly created/modfied
Run fast without ensuring that timestamps of newly created/modified
files are unique. This could make it impossible for Cmdtest to detect
all side-effects of commands.
@ -257,11 +257,11 @@ Options
--xml=FILE
Write summary on JUnit XML format.
Useful when running under a continuouos integration server that
Useful when running under a continuous integration server that
understands JUnit reports.
-i
Run in "incermental" mode. **experimental**
Run in "incremental" mode. **experimental**
Cmdtest will try to run only those test methods that are failed or
have changed since last time.
@ -377,6 +377,9 @@ Assertions - misc
Assert that ``flag`` is true. This assertion is a last resort, when no other
assertion fits. Should normally not be used.
``time(interval)``
Assert that executing the command took a number of seconds inside the
interval given as argument.
Helper functions
++++++++++++++++

View File

@ -69,6 +69,7 @@ module Cmdtest
@_in_cmd = false
@_comment_str = nil
@_prepend_path_dirs = []
@_t1 = @_t2 = 0
end
#------------------------------
@ -184,6 +185,17 @@ module Cmdtest
#------------------------------
def time(time_interval)
_process_after do
diff = @_t2 - @_t1
_assert diff >= time_interval.begin && diff <= time_interval.end do
"expected time in interval #{time_interval}"
end
end
end
#------------------------------
def exit_zero
_process_after do
@_checked_status = true
@ -490,7 +502,9 @@ module Cmdtest
@_runner.notify("cmdline", @_cmdline, @_comment_str)
@_comment_str = nil
@_runner.prepend_path_dirs(@_prepend_path_dirs)
@_t1 = Time.now
@_effects = @_work_dir.run_cmd(@_cmdline)
@_t2 = Time.now
@_checked_status = false