Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Thoughts on making modules

by Juerd (Abbot)
on Dec 22, 2003 at 19:14 UTC ( #316455=note: print w/replies, xml ) Need Help??


in reply to Thoughts on making modules

perhaps a new h2xs mode that worked with an existing .pm, or a different tool.

I always write the .pm first, test it and then use h2xs. After using h2xs, I copy the module over.

Then, if I am going to submit it to CPAN, I make things a little shinier by removing silly comments from Makefile.PL and t/1.t.

So why not just use h2xs and then replace the .pm it generated? There's no need for a new tool to do that, I think :)

Now if only there was something that automated writing regression tests...

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Automating Writing Regression Tests
by chromatic (Archbishop) on Dec 22, 2003 at 20:07 UTC

    I have a tool for that, too. It's ~/bin/newtest:

    #!/usr/bin/perl -w use strict; use File::Path; use File::Basename; my $progfile = basename( $0 ); die "$progfile <modname> <test filename>\n" unless @ARGV >= 2; my ($modname, $filename) = @ARGV; my $filepath = dirname( $filename ); mkpath( $filepath ) unless -e $filepath; open my $out, '>', $filename or die "Can't open '$filename': $!"; print $out <<END_HERE; #!/usr/bin/perl -w BEGIN { chdir 't' if -d 't'; use lib '../lib', '../blib/lib'; } use strict; use Test::More 'no_plan'; # tests => 1; my \$module = '$modname'; use_ok( \$module ) or exit; END_HERE

    For Some::Module, run newtest Some::Module t/testfile.t.

      Hm, that's kind of what h2xs also generates. But I was talking about the actual unit tests, more than just use_ok. Wouldn't it be great if with one simple command, something would analyze a requirements list and translate it to tests? But if that were possible, we could also make it write the code itself, and we'd be out of a job.

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        I started something to this end here. I might actually pick this script up again and iron it out some more.
        -brad..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316455]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2022-05-20 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (73 votes). Check out past polls.

    Notices?