<?xml version="1.0" encoding="windows-1252"?>
<node id="952969" title="Re^2: TDD of non-module code" created="2012-02-10 04:45:48" updated="2012-02-10 04:45:48">
<type id="11">
note</type>
<author id="436161">
davies</author>
<data>
<field name="doctext">
&lt;p&gt;Thanks, all, for the help. I've gone down the command line switch route and have got my code working. But the code has two areas that smell to me, so I come again pleading for help. :-)&lt;/p&gt;
&lt;p&gt;I have tests in three files that are called from a fourth, which is as follows:&lt;/p&gt;
&lt;c&gt;
use strict;
use warnings;
use Test::Harness;

runtests(["podext.t"], ["excelpod.bat"], ["ExcelPOD.t"]);
&lt;/c&gt;
&lt;p&gt;This works fine, but I don't like the business of having to run the .bat file. However, I can't find any way of putting a command such as &lt;c&gt;excelpod.pl -t&lt;/c&gt; with command line parameters into the list of test files to be run without getting an error. The second smell is in excelpod.pl, some of which is:&lt;/p&gt;
&lt;c&gt;
use if (1 == scalar @ARGV &amp;&amp; "-t" eq $ARGV[0]), "Test::More";

...

if (0 &lt; scalar @ARGV &amp;&amp; '-t' eq $ARGV[0]) {
    #Tests
    no warnings;
    eval {"plan tests =&gt; 63;"};
    use warnings;
&lt;/c&gt;
&lt;p&gt;If I write this without all the conditionals, everything works, but running in "live mode" (as opposed to test mode) I get a message saying that no test were run. This might be mistaken for an error message and cause confusion, so I want to suppress it. But writing the "use if" line means that running in live mode generates a compile time error when I give the test plan (and I can find no way of providing that in the "use if" command). Wrapping it in an "eval" command results in a warning of a useless use of a constant in void context, and the only way I can find to avoid that is to suppress warnings.&lt;/p&gt;
&lt;p&gt;As I say, the code is working and the tests are running, but I'd be a happier bunny either if I knew how to avoid the kludges or if I knew that they were unavoidable.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;John Davies&lt;/p&gt;</field>
<field name="root_node">
949648</field>
<field name="parent_node">
949990</field>
</data>
</node>
