diff --git a/README.html b/README.html index 9be7ec3..ce25c41 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> <title>Cmdtest - a program for testing executable programs</title> <style type="text/css"> @@ -295,54 +295,54 @@ ul.auto-toc { <div class="document" id="cmdtest-a-program-for-testing-executable-programs"> <h1 class="title">Cmdtest - a program for testing executable programs</h1> -<p><a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a> is a program to test executable programs. Tests are written in +<p><a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a> is a program to test executable programs. Tests are written in an "xunit style", using assertions about created files, content of -standard output, exit code, etc. <a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a> is written in Ruby. +standard output, exit code, etc. <a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a> is written in Ruby. It consists of a main program and a number of library files.</p> <div class="section" id="documentation"> <h1>Documentation</h1> -<p>A "Cmdtest User Guide" can be found in the file <a class="reference external" href="doc/cmdtest.html">doc/cmdtest.html</a>. -It is generated from the file <tt class="docutils literal"><span class="pre">cmdtest.txt</span></tt> which is written in -<a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> format. There is also an <a class="reference external" href="examples">examples</a> directory with -some real-world examples of using <a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a>.</p> +<p>A <a class="reference external" href="http://holmberg556.bitbucket.org/cmdtest/doc/cmdtest.html">Cmdtest User Guide</a> is available. +It is generated from the file <tt class="docutils literal">cmdtest.txt</tt> which is written in +<a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> format. There is also an <tt class="docutils literal">examples</tt> directory with +some real-world examples of using <a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a>.</p> </div> <div class="section" id="installation"> <h1>Installation</h1> -<p>No installation is needed to use <a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a>. The file <tt class="docutils literal"><span class="pre">cmdtest.rb</span></tt> can +<p>No installation is needed to use <a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a>. The file <tt class="docutils literal">cmdtest.rb</tt> can be executed directly from where it is checked out or unpacked. But the program can also be installed. Use the following command:</p> <pre class="literal-block"> -$ hg clone https://cmdtest.googlecode.com/hg/ cmdtest +$ hg clone https://bitbucket.org/holmberg556/cmdtest cmdtest $ cd cmdtest $ ruby setup.rb # sudo may be needed </pre> -<p>For details about options to <tt class="docutils literal"><span class="pre">setup.rb</span></tt> use <tt class="docutils literal"><span class="pre">ruby</span> <span class="pre">setup.rb</span> <span class="pre">--help</span></tt> +<p>For details about options to <tt class="docutils literal">setup.rb</tt> use <tt class="docutils literal">ruby setup.rb <span class="pre">--help</span></tt> or see <<a class="reference external" href="http://i.loveruby.net/en/projects/setup/doc/usage.html">http://i.loveruby.net/en/projects/setup/doc/usage.html</a>>.</p> </div> <div class="section" id="license"> <h1>License</h1> -<p><a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a> is released under the GNU General Public License version 3. -For details see the file <a class="reference external" href="COPYING.txt">COPYING.txt</a> in the same directory as this file.</p> +<p><a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a> is released under the GNU General Public License version 3. +For details see the file <tt class="docutils literal">COPYING.txt</tt> in the same directory as this file.</p> </div> <div class="section" id="history"> <h1>History</h1> -<p>I got the idea to create <a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a> when I was using and making changes to <a class="reference external" href="http://www.dsmit.com/cons/">Cons</a>, +<p>I got the idea to create <a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a> when I was using and making changes to <a class="reference external" href="http://www.dsmit.com/cons/">Cons</a>, the make-replacement written in Perl. The program had tests written using the Perl module Test::Cmd. Later I developed other programs that also needed some kind of "unit tests" for the executables. I looked for existing tools but could not find anything that I was completely comfortable with. So I started to develop my own tool, and the result was -<a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a>.</p> +<a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a>.</p> </div> <div class="section" id="author"> <h1>Author</h1> -<p><a class="reference external" href="http://cmdtest.googlecode.com">Cmdtest</a> was created by Johan Holmberg <holmberg556 at gmail dot com>.</p> +<p><a class="reference external" href="https://bitbucket.org/holmberg556/cmdtest">Cmdtest</a> was created by Johan Holmberg <holmberg556 at gmail dot com>.</p> </div> </div> <div class="footer"> <hr class="footer" /> -<a class="reference external" href="README.txt">View document source</a>. -Generated on: 2009-06-16. +<a class="reference external" href="README.rst">View document source</a>. +Generated on: 2013-08-13. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div> diff --git a/README.rst b/README.rst index 0af4480..3903ee9 100644 --- a/README.rst +++ b/README.rst @@ -10,9 +10,9 @@ It consists of a main program and a number of library files. Documentation ------------- -A "Cmdtest User Guide" can be found in the file `<doc/cmdtest.html>`_. +A `Cmdtest User Guide`_ is available. It is generated from the file ``cmdtest.txt`` which is written in -reStructuredText_ format. There is also an `<examples>`_ directory with +reStructuredText_ format. There is also an ``examples`` directory with some real-world examples of using Cmdtest_. Installation @@ -22,7 +22,7 @@ No installation is needed to use Cmdtest_. The file ``cmdtest.rb`` can be executed directly from where it is checked out or unpacked. But the program can also be installed. Use the following command:: - $ hg clone https://cmdtest.googlecode.com/hg/ cmdtest + $ hg clone https://bitbucket.org/holmberg556/cmdtest cmdtest $ cd cmdtest $ ruby setup.rb # sudo may be needed @@ -33,7 +33,7 @@ License ------- Cmdtest_ is released under the GNU General Public License version 3. -For details see the file `<COPYING.txt>`_ in the same directory as this file. +For details see the file ``COPYING.txt`` in the same directory as this file. History ------- @@ -53,5 +53,7 @@ Cmdtest_ was created by Johan Holmberg <holmberg556 at gmail dot com>. .. _reStructuredText: http://docutils.sourceforge.net/rst.html -.. _Cmdtest: http://cmdtest.googlecode.com +.. _Cmdtest: https://bitbucket.org/holmberg556/cmdtest .. _Cons: http://www.dsmit.com/cons/ + +.. _`Cmdtest User Guide`: http://holmberg556.bitbucket.org/cmdtest/doc/cmdtest.html diff --git a/doc/cmdtest.html b/doc/cmdtest.html index 28ef34d..8084551 100644 --- a/doc/cmdtest.html +++ b/doc/cmdtest.html @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> <title>Cmdtest User Guide</title> <style type="text/css"> @@ -307,7 +307,7 @@ ul.auto-toc { <li><a class="reference internal" href="#specifying-files-directories" id="id7">Specifying files / directories</a></li> <li><a class="reference internal" href="#path-handling" id="id8">PATH handling</a></li> <li><a class="reference internal" href="#matching-standard-output-content" id="id9">Matching standard output content</a></li> -<li><a class="reference internal" href="#invoking-cmdtest" id="id10">Invoking <tt class="docutils literal"><span class="pre">cmdtest</span></tt></a><ul> +<li><a class="reference internal" href="#invoking-cmdtest" id="id10">Invoking <tt class="docutils literal">cmdtest</tt></a><ul> <li><a class="reference internal" href="#options" id="id11">Options</a></li> <li><a class="reference internal" href="#commandline-examples" id="id12">Commandline Examples</a></li> </ul> @@ -329,7 +329,7 @@ ul.auto-toc { In other test frameworks the "unit" tested is often a class (e.g. in Java's <a class="reference external" href="http://en.wikipedia.org/wiki/JUnit">JUnit</a> or Ruby's <a class="reference external" href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit</a>), but in Cmdtest the unit is an executable. Apart from this difference Cmdtest borrows many ideas from the other frameworks. -The program <tt class="docutils literal"><span class="pre">cmdtest</span></tt> runs the tests and reports the success or failure +The program <tt class="docutils literal">cmdtest</tt> runs the tests and reports the success or failure in different ways, e.g. by writing to standard output or producing an XML-file on Ant/JUnit format. The testcases are written in Ruby code. Assertions can be made about the side effects performed by a command:</p> @@ -362,10 +362,10 @@ end </pre> <p>This example shows the basic structure of a testcase file. First we make a subclass of <tt class="docutils literal"><span class="pre">Cmdtest::Testcase</span></tt>. All methods of the new class with a -name like <tt class="docutils literal"><span class="pre">test_*</span></tt> will be considered testcases. -Inside a method we can call the <tt class="docutils literal"><span class="pre">cmd</span></tt> method. It will +name like <tt class="docutils literal">test_*</tt> will be considered testcases. +Inside a method we can call the <tt class="docutils literal">cmd</tt> method. It will execute the command given as argument and then check the assertions -given in the do-block. When <tt class="docutils literal"><span class="pre">cmdtest</span></tt> is run, it will find all +given in the do-block. When <tt class="docutils literal">cmdtest</tt> is run, it will find all <tt class="docutils literal"><span class="pre">CMDTEST_*.rb</span></tt> files in the current directory and run the tests in the files. The output looks like:</p> <pre class="literal-block"> @@ -402,17 +402,17 @@ where some larger examples of Cmdtest usage can be found.</p> <p>Normally Cmdtest writes lines on standard output to show the progress of the testing. As long as no error occurs, the lines will be prefixed by "###". Error messages will instead have a "---" prefix. This makes it easy -to spot errors just by looking in the left margin. Each call to <tt class="docutils literal"><span class="pre">cmd</span></tt> +to spot errors just by looking in the left margin. Each call to <tt class="docutils literal">cmd</tt> will give one line on standard output. Normally the command executed will be shown (after the "###" prefix). But one can also replace the string -written by calling the <tt class="docutils literal"><span class="pre">comment</span></tt> method inside the do-block of a <tt class="docutils literal"><span class="pre">cmd</span></tt> +written by calling the <tt class="docutils literal">comment</tt> method inside the do-block of a <tt class="docutils literal">cmd</tt> call.</p> <p>When an error occurs in a test-method, the rest of the method will be skipped. But all errors occurring at the same command will be reported.</p> <p>Cmdtest can also be directed to write an XML file on the same format as that used by Ant/JUnit. This makes it possible to use Cmdtest together with <a class="reference external" href="http://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a> servers like <a class="reference external" href="https://hudson.dev.java.net">Hudson</a>.</p> -<p>The exit status of <tt class="docutils literal"><span class="pre">cmdtest</span></tt> will be non-zero if some errors occurred, +<p>The exit status of <tt class="docutils literal">cmdtest</tt> will be non-zero if some errors occurred, otherwise zero. If errors should not affect exit code, the command line option <tt class="docutils literal"><span class="pre">--no-exit-code</span></tt> can be used.</p> </div> @@ -421,25 +421,25 @@ command line option <tt class="docutils literal"><span class="pre">--no-exit-cod <p>Each test-file can contain one or more subclasses to <tt class="docutils literal"><span class="pre">Cmdtest::Testcase</span></tt>. The methods that are special are:</p> <dl class="docutils"> -<dt><tt class="docutils literal"><span class="pre">test_*</span></tt></dt> +<dt><tt class="docutils literal">test_*</tt></dt> <dd>These are the methods that will run tests. For each method, a newly created object of the class will be used.</dd> -<dt><tt class="docutils literal"><span class="pre">setup</span></tt></dt> -<dd>This method is called before each <tt class="docutils literal"><span class="pre">test_*</span></tt> method is called. +<dt><tt class="docutils literal">setup</tt></dt> +<dd>This method is called before each <tt class="docutils literal">test_*</tt> method is called. It gives the user a chance to initialize the "environment" of all -the <tt class="docutils literal"><span class="pre">test_*</span></tt> methods of the class. It can be seen as a "user level" +the <tt class="docutils literal">test_*</tt> methods of the class. It can be seen as a "user level" constructor.</dd> -<dt><tt class="docutils literal"><span class="pre">teardown</span></tt></dt> -<dd>This method is called after each <tt class="docutils literal"><span class="pre">test_*</span></tt> method was called. It +<dt><tt class="docutils literal">teardown</tt></dt> +<dd>This method is called after each <tt class="docutils literal">test_*</tt> method was called. It gives the user a chance to cleanup the "environment" of all the -<tt class="docutils literal"><span class="pre">test_*</span></tt> methods of the class, e.g. release some resource acquired -by the <tt class="docutils literal"><span class="pre">setup</span></tt> method. It can be seen as a "user level" destructor.</dd> +<tt class="docutils literal">test_*</tt> methods of the class, e.g. release some resource acquired +by the <tt class="docutils literal">setup</tt> method. It can be seen as a "user level" destructor.</dd> </dl> </div> <div class="section" id="structure-of-a-test-method"> <h1><a class="toc-backref" href="#id5">Structure of a test-method</a></h1> -<p>Each test-method (named <tt class="docutils literal"><span class="pre">test_*</span></tt>) should contain a number of calls to -the <tt class="docutils literal"><span class="pre">cmd</span></tt> method. Inside the do-block of the <tt class="docutils literal"><span class="pre">cmd</span></tt> calls, a number of +<p>Each test-method (named <tt class="docutils literal">test_*</tt>) should contain a number of calls to +the <tt class="docutils literal">cmd</tt> method. Inside the do-block of the <tt class="docutils literal">cmd</tt> calls, a number of assertions can be made about the outcome of the command. The simplest possible call looks like:</p> <pre class="literal-block"> @@ -459,12 +459,12 @@ cmd "true" do removed_files [] end </pre> -<p>The idea is that all differences in behaviour from the trivial <tt class="docutils literal"><span class="pre">true</span></tt> +<p>The idea is that all differences in behaviour from the trivial <tt class="docutils literal">true</tt> command should be described as an assertion in the do-block. The list -of possible assertions includes: <tt class="docutils literal"><span class="pre">exit_zero</span></tt>, <tt class="docutils literal"><span class="pre">exit_nonzero</span></tt>, -<tt class="docutils literal"><span class="pre">exit_status</span></tt>, <tt class="docutils literal"><span class="pre">created_files</span></tt>, <tt class="docutils literal"><span class="pre">changed_files</span></tt>, <tt class="docutils literal"><span class="pre">removed_files</span></tt>, -<tt class="docutils literal"><span class="pre">written_files</span></tt>, <tt class="docutils literal"><span class="pre">affected_files</span></tt>, <tt class="docutils literal"><span class="pre">file_equal</span></tt>, <tt class="docutils literal"><span class="pre">stdout_equal</span></tt> -and <tt class="docutils literal"><span class="pre">stderr_equal</span></tt>.</p> +of possible assertions includes: <tt class="docutils literal">exit_zero</tt>, <tt class="docutils literal">exit_nonzero</tt>, +<tt class="docutils literal">exit_status</tt>, <tt class="docutils literal">created_files</tt>, <tt class="docutils literal">changed_files</tt>, <tt class="docutils literal">removed_files</tt>, +<tt class="docutils literal">written_files</tt>, <tt class="docutils literal">affected_files</tt>, <tt class="docutils literal">file_equal</tt>, <tt class="docutils literal">stdout_equal</tt> +and <tt class="docutils literal">stderr_equal</tt>.</p> <p>In addition to the assertions there are other helper-functions to set up the "environment" for the commands and assertions. An example is the creation of files:</p> @@ -480,14 +480,14 @@ end ... </pre> <p>The list of such helper functions includes: -<tt class="docutils literal"><span class="pre">create_file</span></tt>, <tt class="docutils literal"><span class="pre">touch_file</span></tt>, <tt class="docutils literal"><span class="pre">import_file</span></tt> and <tt class="docutils literal"><span class="pre">ignore_file</span></tt>. +<tt class="docutils literal">create_file</tt>, <tt class="docutils literal">touch_file</tt>, <tt class="docutils literal">import_file</tt> and <tt class="docutils literal">ignore_file</tt>. Beside these methods the test can of course also contain arbitrary Ruby-code.</p> </div> <div class="section" id="work-directory"> <h1><a class="toc-backref" href="#id6">Work directory</a></h1> <p>All tests are performed in a "clean" temporary directory, here called the "work directory". -When the <tt class="docutils literal"><span class="pre">setup</span></tt>, <tt class="docutils literal"><span class="pre">test_*</span></tt> and <tt class="docutils literal"><span class="pre">teardown</span></tt> methods are called the current directory -will be the "work directory" (unless <tt class="docutils literal"><span class="pre">Dir.chdir</span></tt> is called by the methods themselves).</p> +When the <tt class="docutils literal">setup</tt>, <tt class="docutils literal">test_*</tt> and <tt class="docutils literal">teardown</tt> methods are called the current directory +will be the "work directory" (unless <tt class="docutils literal">Dir.chdir</tt> is called by the methods themselves).</p> <p>Several of the assertions and helper functions take filename arguments that are evaluated relative to the "work directory" (or sometimes the current directory if they differ).</p> @@ -495,7 +495,7 @@ current directory if they differ).</p> <div class="section" id="specifying-files-directories"> <h1><a class="toc-backref" href="#id7">Specifying files / directories</a></h1> <p>Several methods take files or directories as argument (e.g. -<tt class="docutils literal"><span class="pre">created_files</span></tt>, <tt class="docutils literal"><span class="pre">modified_files</span></tt> and <tt class="docutils literal"><span class="pre">ignore_file</span></tt>). Instead of +<tt class="docutils literal">created_files</tt>, <tt class="docutils literal">modified_files</tt> and <tt class="docutils literal">ignore_file</tt>). Instead of having two sets of methods, one for files and one for directories, an argument with a trailing "/" denotes a directory:</p> <pre class="literal-block"> @@ -505,33 +505,33 @@ create_files "build" # the file "build" ignore_file "build/" # the directory "build" (and everything below) ignore_file "build" # the file "build" </pre> -<p>As can be seen in the example above, the <tt class="docutils literal"><span class="pre">ignore_file</span></tt> method is +<p>As can be seen in the example above, the <tt class="docutils literal">ignore_file</tt> method is special, because an ignored directory means that all files below the directory are -ignored too. Another peculiarity with <tt class="docutils literal"><span class="pre">ignore_file</span></tt> is that the +ignored too. Another peculiarity with <tt class="docutils literal">ignore_file</tt> is that the argument can be a Regexp:</p> <pre class="literal-block"> ignore_file /\.o$/ # all files *.o </pre> -<p>This is quite natural, since the "job" of <tt class="docutils literal"><span class="pre">ignore_file</span></tt> is to single +<p>This is quite natural, since the "job" of <tt class="docutils literal">ignore_file</tt> is to single out a subset of all files.</p> </div> <div class="section" id="path-handling"> <h1><a class="toc-backref" href="#id8">PATH handling</a></h1> <p>Cmdtest is used to test commands, so an important question is how the commands are found and executed. Normally commands are found via the -<tt class="docutils literal"><span class="pre">PATH</span></tt> environment variable, and Cmdtest is no exception. The commands -executed in the <tt class="docutils literal"><span class="pre">cmd</span></tt> calls are evaluated in a shell script (on -UN*X) or in a BAT file (on Windows). The <tt class="docutils literal"><span class="pre">PATH</span></tt> in effect when -<tt class="docutils literal"><span class="pre">cmdtest</span></tt> is invoked is kept intact, with one addition: the current -directory at the time of invocation is prepended to the <tt class="docutils literal"><span class="pre">PATH</span></tt>. If -further changes to the <tt class="docutils literal"><span class="pre">PATH</span></tt> are needed the methods <tt class="docutils literal"><span class="pre">prepend_path</span></tt>, -<tt class="docutils literal"><span class="pre">prepend_local_path</span></tt> or <tt class="docutils literal"><span class="pre">set_path</span></tt> can be used. Such path modifications +<tt class="docutils literal">PATH</tt> environment variable, and Cmdtest is no exception. The commands +executed in the <tt class="docutils literal">cmd</tt> calls are evaluated in a shell script (on +UN*X) or in a BAT file (on Windows). The <tt class="docutils literal">PATH</tt> in effect when +<tt class="docutils literal">cmdtest</tt> is invoked is kept intact, with one addition: the current +directory at the time of invocation is prepended to the <tt class="docutils literal">PATH</tt>. If +further changes to the <tt class="docutils literal">PATH</tt> are needed the methods <tt class="docutils literal">prepend_path</tt>, +<tt class="docutils literal">prepend_local_path</tt> or <tt class="docutils literal">set_path</tt> can be used. Such path modifications does not survive between test methods. Each new test method starts with the -original value of <tt class="docutils literal"><span class="pre">PATH</span></tt>.</p> +original value of <tt class="docutils literal">PATH</tt>.</p> </div> <div class="section" id="matching-standard-output-content"> <h1><a class="toc-backref" href="#id9">Matching standard output content</a></h1> -<p>An assertion like <tt class="docutils literal"><span class="pre">stdout_equal</span></tt> compares the actual standard output of a +<p>An assertion like <tt class="docutils literal">stdout_equal</tt> compares the actual standard output of a command with the expected outcome. The expected value can be specified in different ways, and is best explained by example:</p> <pre class="literal-block"> @@ -550,7 +550,7 @@ end </pre> <p>In the example we see how the content can be specified:</p> <ol class="arabic simple"> -<li>as a string, with a newline (<tt class="docutils literal"><span class="pre">\n</span></tt>) character for each new line</li> +<li>as a string, with a newline (<tt class="docutils literal">\n</tt>) character for each new line</li> <li>as an array of lines</li> <li>as a regexp that should match the file content given as a string</li> <li>as an array of lines where some lines should match a regexp rather than be compared @@ -558,15 +558,15 @@ for string equality</li> </ol> </div> <div class="section" id="invoking-cmdtest"> -<h1><a class="toc-backref" href="#id10">Invoking <tt class="docutils literal"><span class="pre">cmdtest</span></tt></a></h1> -<p><tt class="docutils literal"><span class="pre">cmdtest</span></tt> can be called without any arguments at all. It will then look +<h1><a class="toc-backref" href="#id10">Invoking <tt class="docutils literal">cmdtest</tt></a></h1> +<p><tt class="docutils literal">cmdtest</tt> can be called without any arguments at all. It will then look for <tt class="docutils literal"><span class="pre">CMDTEST_*.rb</span></tt> files in the following places:</p> <ol class="arabic simple"> <li>first <tt class="docutils literal"><span class="pre">t/CMDTEST_*.rb</span></tt></li> <li>second <tt class="docutils literal"><span class="pre">test/CMDTEST_*.rb</span></tt></li> <li>otherwise <tt class="docutils literal"><span class="pre">CMDTEST_*.rb</span></tt></li> </ol> -<p>If some command line arguments have been given, <tt class="docutils literal"><span class="pre">cmdtest</span></tt> will use +<p>If some command line arguments have been given, <tt class="docutils literal">cmdtest</tt> will use them instead of searching by itself. Some examples:</p> <pre class="literal-block"> $ cmdtest CMDTEST_foo.rb # just one file @@ -668,7 +668,7 @@ servers such as <a class="reference external" href="https://hudson.dev.java.net" <h1><a class="toc-backref" href="#id13">Reference Part</a></h1> <div class="section" id="cmd"> <h2><a class="toc-backref" href="#id14">cmd</a></h2> -<p>The <tt class="docutils literal"><span class="pre">cmd</span></tt> method is the central method of the whole Cmdtest framework. +<p>The <tt class="docutils literal">cmd</tt> method is the central method of the whole Cmdtest framework. It should always be called with a block like this:</p> <pre class="literal-block"> cmd "some_prog ..." do @@ -696,12 +696,12 @@ end <div class="section" id="assertions-exit-status"> <h2><a class="toc-backref" href="#id15">Assertions - exit status</a></h2> <dl class="docutils"> -<dt><tt class="docutils literal"><span class="pre">exit_nonzero</span></tt></dt> +<dt><tt class="docutils literal">exit_nonzero</tt></dt> <dd>The command should have exited with a non-zero exit status (i.e. it should have failed).</dd> -<dt><tt class="docutils literal"><span class="pre">exit_status(status)</span></tt></dt> +<dt><tt class="docutils literal">exit_status(status)</tt></dt> <dd>The command should have exited with the specified exit status.</dd> -<dt><tt class="docutils literal"><span class="pre">exit_zero</span></tt></dt> +<dt><tt class="docutils literal">exit_zero</tt></dt> <dd>The command should have exited with a zero exit status (i.e. it should have succeeded). This is the default if none of the other exit-related methods have been called.</dd> @@ -713,8 +713,8 @@ exit-related methods have been called.</dd> <dt><tt class="docutils literal"><span class="pre">affected_files(file1,...,fileN)</span></tt></dt> <dd>The specified files should have been created, removed or modified by the command. This assertion can be used when it doesn't matter which -of <tt class="docutils literal"><span class="pre">created_files</span></tt>, <tt class="docutils literal"><span class="pre">removed_files</span></tt> or <tt class="docutils literal"><span class="pre">changed_files</span></tt> that apply -(cf. <tt class="docutils literal"><span class="pre">written_files</span></tt>).</dd> +of <tt class="docutils literal">created_files</tt>, <tt class="docutils literal">removed_files</tt> or <tt class="docutils literal">changed_files</tt> that apply +(cf. <tt class="docutils literal">written_files</tt>).</dd> <dt><tt class="docutils literal"><span class="pre">changed_files(file1,...,fileN)</span></tt></dt> <dd>The specified files should have been modified by the command. A file is considered modified if it existed before the command, and @@ -727,43 +727,43 @@ number, modification date or content).</dd> <dt><tt class="docutils literal"><span class="pre">written_files(file1,...,fileN)</span></tt></dt> <dd>The specified files should have been created or modified by the command. This assertion can be used when it doesn't matter which -of <tt class="docutils literal"><span class="pre">created_files</span></tt> or <tt class="docutils literal"><span class="pre">changed_files</span></tt> that apply. A typical scenario is +of <tt class="docutils literal">created_files</tt> or <tt class="docutils literal">changed_files</tt> that apply. A typical scenario is in a test method where repeated operations are done on the same -file. By using <tt class="docutils literal"><span class="pre">written_files</span></tt> we don't have to treat the first +file. By using <tt class="docutils literal">written_files</tt> we don't have to treat the first case special (when the file is created).</dd> </dl> </div> <div class="section" id="assertions-stdout-stderr-file-content"> <h2><a class="toc-backref" href="#id17">Assertions - stdout/stderr/file content</a></h2> <dl class="docutils"> -<dt><tt class="docutils literal"><span class="pre">file_equal(file,</span> <span class="pre">content)</span></tt></dt> +<dt><tt class="docutils literal">file_equal(file, content)</tt></dt> <dd>Assert that the specified file matches the given content. See "stdout_equal" for how "content" can be specified.</dd> -<dt><tt class="docutils literal"><span class="pre">file_not_equal(file,</span> <span class="pre">content)</span></tt></dt> -<dd>Like <tt class="docutils literal"><span class="pre">file_equal</span></tt> but with inverted test.</dd> -<dt><tt class="docutils literal"><span class="pre">stderr_equal(content)</span></tt></dt> +<dt><tt class="docutils literal">file_not_equal(file, content)</tt></dt> +<dd>Like <tt class="docutils literal">file_equal</tt> but with inverted test.</dd> +<dt><tt class="docutils literal">stderr_equal(content)</tt></dt> <dd>Assert that the standard error of the command matches the given content. See "stdout_equal" for how "content" can be specified.</dd> -<dt><tt class="docutils literal"><span class="pre">stderr_not_equal(content)</span></tt></dt> -<dd>Like <tt class="docutils literal"><span class="pre">stderr_equal</span></tt> but with inverted test.</dd> -<dt><tt class="docutils literal"><span class="pre">stdout_equal(content)</span></tt></dt> +<dt><tt class="docutils literal">stderr_not_equal(content)</tt></dt> +<dd>Like <tt class="docutils literal">stderr_equal</tt> but with inverted test.</dd> +<dt><tt class="docutils literal">stdout_equal(content)</tt></dt> <dd>Assert that the standard output of the command matches the given content. The content can be given in several different forms: 1) as a string that should be equal to the entire file, 2) as an array of lines that should be equal to the entire file, 3) as a regexp that should match the entire file (given as one string). For more details and examples see the section "Matching standard output content".</dd> -<dt><tt class="docutils literal"><span class="pre">stdout_not_equal(content)</span></tt></dt> -<dd>Like <tt class="docutils literal"><span class="pre">stdout_equal</span></tt> but with inverted test.</dd> +<dt><tt class="docutils literal">stdout_not_equal(content)</tt></dt> +<dd>Like <tt class="docutils literal">stdout_equal</tt> but with inverted test.</dd> </dl> </div> <div class="section" id="assertions-misc"> <h2><a class="toc-backref" href="#id18">Assertions - misc</a></h2> <dl class="docutils"> -<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 +<dt><tt class="docutils literal">assert(flag, msg=nil)</tt></dt> +<dd>Assert that <tt class="docutils literal">flag</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> +<dt><tt class="docutils literal">time(interval)</tt></dt> <dd>Assert that executing the command took a number of seconds inside the interval given as argument.</dd> </dl> @@ -771,7 +771,7 @@ interval given as argument.</dd> <div class="section" id="helper-functions"> <h2><a class="toc-backref" href="#id19">Helper functions</a></h2> <dl class="docutils"> -<dt><tt class="docutils literal"><span class="pre">create_file(filename,</span> <span class="pre">content)</span></tt></dt> +<dt><tt class="docutils literal">create_file(filename, content)</tt></dt> <dd>Create a file inside the "work directory". If the filename contains a directory part, intermediate directories are created if needed. @@ -779,32 +779,32 @@ The content can be specified either as an array of lines or as a string with the content of the whole file. The filename is evaluated relative to the current directory at the time of the call.</dd> -<dt><tt class="docutils literal"><span class="pre">ignore_file(file)</span></tt></dt> +<dt><tt class="docutils literal">ignore_file(file)</tt></dt> <dd>Ignore the specified file when looking for differences in the filesystem. A subdirectory can be ignored by giving a trailing "/" to the name.</dd> -<dt><tt class="docutils literal"><span class="pre">ignore_files(file1,</span> <span class="pre">...,</span> <span class="pre">fileN)</span></tt></dt> +<dt><tt class="docutils literal">ignore_files(file1, <span class="pre">...,</span> fileN)</tt></dt> <dd>Ignore the specified files when looking for differences in the filesystem.</dd> -<dt><tt class="docutils literal"><span class="pre">import_file(src,</span> <span class="pre">tgt)</span></tt></dt> +<dt><tt class="docutils literal">import_file(src, tgt)</tt></dt> <dd>Copy a file from outside of the "work directory" to inside. -The <tt class="docutils literal"><span class="pre">src</span></tt> path is evaluated relative to the current directory -when <tt class="docutils literal"><span class="pre">cmdtest</span></tt> was called. The <tt class="docutils literal"><span class="pre">tgt</span></tt> is evaluated relative to +The <tt class="docutils literal">src</tt> path is evaluated relative to the current directory +when <tt class="docutils literal">cmdtest</tt> was called. The <tt class="docutils literal">tgt</tt> is evaluated relative to the current directory inside the "work directory" at the time of the call.</dd> -<dt><tt class="docutils literal"><span class="pre">prepend_local_path(dir)</span></tt></dt> -<dd>Prepend the given directory to the <tt class="docutils literal"><span class="pre">PATH</span></tt> so commands executed via <tt class="docutils literal"><span class="pre">cmd</span></tt> -are looked up using the modified <tt class="docutils literal"><span class="pre">PATH</span></tt>. The argument <tt class="docutils literal"><span class="pre">dir</span></tt> is evaluated +<dt><tt class="docutils literal">prepend_local_path(dir)</tt></dt> +<dd>Prepend the given directory to the <tt class="docutils literal">PATH</tt> so commands executed via <tt class="docutils literal">cmd</tt> +are looked up using the modified <tt class="docutils literal">PATH</tt>. The argument <tt class="docutils literal">dir</tt> is evaluated relative to the current directory in effect at the time of the call (i.e. typically the "work directory" during the test).</dd> -<dt><tt class="docutils literal"><span class="pre">prepend_path(dir)</span></tt></dt> -<dd>Prepend the given directory to the <tt class="docutils literal"><span class="pre">PATH</span></tt> so commands executed via <tt class="docutils literal"><span class="pre">cmd</span></tt> -are looked up using the modified <tt class="docutils literal"><span class="pre">PATH</span></tt>. A typical use is to add the directory -where the executable tested is located. The argument <tt class="docutils literal"><span class="pre">dir</span></tt> is evaluated -relative to the current directory in effect when <tt class="docutils literal"><span class="pre">cmdtest</span></tt> was invoked.</dd> -<dt><tt class="docutils literal"><span class="pre">set_path(dir1,</span> <span class="pre">...,</span> <span class="pre">dirN)</span></tt></dt> -<dd>Set <tt class="docutils literal"><span class="pre">PATH</span></tt> to the given directories, so commands executed via <tt class="docutils literal"><span class="pre">cmd</span></tt> -are looked up using the modified <tt class="docutils literal"><span class="pre">PATH</span></tt>. This method sets the whole <tt class="docutils literal"><span class="pre">PATH</span></tt> -rather than modifying it (in contrast to <tt class="docutils literal"><span class="pre">prepend_path</span></tt> and <tt class="docutils literal"><span class="pre">prepend_local_path</span></tt>).</dd> -<dt><tt class="docutils literal"><span class="pre">touch_file(filename)</span></tt></dt> +<dt><tt class="docutils literal">prepend_path(dir)</tt></dt> +<dd>Prepend the given directory to the <tt class="docutils literal">PATH</tt> so commands executed via <tt class="docutils literal">cmd</tt> +are looked up using the modified <tt class="docutils literal">PATH</tt>. A typical use is to add the directory +where the executable tested is located. The argument <tt class="docutils literal">dir</tt> is evaluated +relative to the current directory in effect when <tt class="docutils literal">cmdtest</tt> was invoked.</dd> +<dt><tt class="docutils literal">set_path(dir1, <span class="pre">...,</span> dirN)</tt></dt> +<dd>Set <tt class="docutils literal">PATH</tt> to the given directories, so commands executed via <tt class="docutils literal">cmd</tt> +are looked up using the modified <tt class="docutils literal">PATH</tt>. This method sets the whole <tt class="docutils literal">PATH</tt> +rather than modifying it (in contrast to <tt class="docutils literal">prepend_path</tt> and <tt class="docutils literal">prepend_local_path</tt>).</dd> +<dt><tt class="docutils literal">touch_file(filename)</tt></dt> <dd>"touch" a file inside the "work directory". The filename is evaluated relative to the current directory at the time of the call.</dd> @@ -815,7 +815,7 @@ time of the call.</dd> <div class="footer"> <hr class="footer" /> <a class="reference external" href="cmdtest.txt">View document source</a>. -Generated on: 2009-11-19. +Generated on: 2013-08-13. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div>