RE: run C++ TAP output? (even easier)

2007-03-11 Thread leif . eriksen
 Another option is to use IPC::System::Simple.

The driver script is a neat idea, I used this variation for testing my
harness wrapped around my Utils C library

Say I had C code in a Utils library, one source file which might have
this code


/**
  * internal function
  */
static int hexChar2Int (unsigned char ch) {
if (ch >= '0' && ch <= '9') return ch - '0';
if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10;
return -1;
}

The test harness might look like this


#include "tap.h"
#include "Utils.c"
isInt(hexChar2Int('0'), 0);
isInt(hexChar2Int('Z'), -1);

And the perl driver could look like this


use IPC::System::Simple;
...
run('test_Utils');

or

run('test_Utils', @args);

Note how the function we're testing is declared static, but we include
the C file in the harness - this is a neat way to get at the internal
functions and state variables in C code, if your testing down at that
level.

IPC::System::Simple give me finer grained control over testing return
codes from calls to run various harnesses

As with Ovid's code I options as to how I want to run this.

perl -MTest::Harness -e 'runtests(qw(test_Utils.t))'
prove test_Utils.t
make test

L

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Friday, 9 March 2007 11:19 PM
To: [EMAIL PROTECTED]; perl-qa@perl.org
Subject: Re: run C++ TAP output? (even easier)

If you want things to be *really* easy to run test suites in multiple
languages, do this.

First, make sure that all test programs are executable.  Then use this
driver program:

   $ cat bin/run.pl 
   #!/usr/bin/perl
 
   use strict;
   use warnings;
 
   my $prog = shift;
   unless ( -e $prog && -x _ ) {
   die "Cannot find or execute ($prog)";
   }
   exec $prog;

Then 'find' all executable files and use the '--exec' option with
runtests to execute all of them with the 'bin/run.pl' program:

  $ find t/ -perm /u+x -type f | xargs runtests --exec bin/run.pl
  t/tap Failed 1/3 subtests 
  t/perl...ok   
  
  Test Summary Report
  ---
  t/tap.exe (Wstat: 0 Tests: 3 Failed: 1)
Failed tests:  2
  Files=2, Tests=5,  0 wallclock secs ( 0.04 cusr +  0.00 csys =  0.04
CPU)

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
**
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed.  If
you received this e-mail in error, please notify the HPA Postmaster, [EMAIL 
PROTECTED],
then delete  the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at
www.hpa.com.au
**


Re: run C++ TAP output? (even easier)

2007-03-09 Thread Michael G Schwern
Julien Beasley wrote:
> Well at my last job, we had hundreds of test files.. and most of them were
> really fast because we wanted to keep the total time to a minimum. Even
> then, it took over five minutes to run all of our tests, and that was
> getting to be Too Long. So I could definitely see in a case like that that
> the overhead of starting a new interpreter for each file would add up

$ time perl -wle 'for (1..$ARGV[0]) { system "perl -e 1" }' 1000

real0m5.358s
user0m1.328s
sys 0m3.474s

And that's on my dinky little Macbook.

Firing up a new perl interpreter for each test will not be your bottleneck
if your tests actually do anything.



Re: run C++ TAP output? (even easier)

2007-03-09 Thread Andy Armstrong

On 9 Mar 2007, at 23:57, Julien Beasley wrote:
Well at my last job, we had hundreds of test files.. and most of  
them were
really fast because we wanted to keep the total time to a minimum.  
Even

then, it took over five minutes to run all of our tests, and that was
getting to be Too Long. So I could definitely see in a case like  
that that

the overhead of starting a new interpreter for each file would add up


Doing something about it before you know it's a problem would be  
premature optimisation. Give it a try, see how it works.


--
Andy Armstrong, hexten.net



Re: run C++ TAP output? (even easier)

2007-03-09 Thread Julien Beasley

Well at my last job, we had hundreds of test files.. and most of them were
really fast because we wanted to keep the total time to a minimum. Even
then, it took over five minutes to run all of our tests, and that was
getting to be Too Long. So I could definitely see in a case like that that
the overhead of starting a new interpreter for each file would add up

Julien

On 3/9/07, chromatic <[EMAIL PROTECTED]> wrote:


On Friday 09 March 2007 15:39, Julien Beasley wrote:

> However, and I apologize if I'm wrong about
> this, doesn't your proposed solution have to start a new perl
interpreter
> for every single test file? If so, that might up being too slow for
> practical use.

That would surprise me; I would expect that process creation time on your
OS
is reasonably fast and that the work done in the test files themselves
would
overcome startup time.

-- c



Re: run C++ TAP output? (even easier)

2007-03-09 Thread Andy Armstrong

On 9 Mar 2007, at 23:39, Julien Beasley wrote:
Thanks Ovid! This may be exactly what I'm looking for (since I'm  
going to
have tests in libtap and perl). However, and I apologize if I'm  
wrong about
this, doesn't your proposed solution have to start a new perl  
interpreter

for every single test file? If so, that might up being too slow for
practical use.


That's what Perl does when it runs tests written in Perl. It could be  
faster but it's far from unusable.


--
Andy Armstrong, hexten.net



Re: run C++ TAP output? (even easier)

2007-03-09 Thread chromatic
On Friday 09 March 2007 15:39, Julien Beasley wrote:

> However, and I apologize if I'm wrong about
> this, doesn't your proposed solution have to start a new perl interpreter
> for every single test file? If so, that might up being too slow for
> practical use.

That would surprise me; I would expect that process creation time on your OS 
is reasonably fast and that the work done in the test files themselves would 
overcome startup time.

-- c


Re: run C++ TAP output? (even easier)

2007-03-09 Thread Julien Beasley

Thanks Ovid! This may be exactly what I'm looking for (since I'm going to
have tests in libtap and perl). However, and I apologize if I'm wrong about
this, doesn't your proposed solution have to start a new perl interpreter
for every single test file? If so, that might up being too slow for
practical use.


Julien

On 3/9/07, Ovid <[EMAIL PROTECTED]> wrote:


If you want things to be *really* easy to run test suites in multiple
languages, do this.

First, make sure that all test programs are executable.  Then use this
driver program:

  $ cat bin/run.pl
  #!/usr/bin/perl

  use strict;
  use warnings;

  my $prog = shift;
  unless ( -e $prog && -x _ ) {
  die "Cannot find or execute ($prog)";
  }
  exec $prog;

Then 'find' all executable files and use the '--exec' option with
runtests to execute all of them with the 'bin/run.pl' program:

$ find t/ -perm /u+x -type f | xargs runtests --exec bin/run.pl
t/tap Failed 1/3 subtests
t/perl...ok

Test Summary Report
---
t/tap.exe (Wstat: 0 Tests: 3 Failed: 1)
   Failed tests:  2
Files=2, Tests=5,  0 wallclock secs ( 0.04 cusr +  0.00 csys =  0.04
CPU)

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/



Re: run C++ TAP output? (even easier)

2007-03-09 Thread Geoffrey Young
Ovid wrote:
> If you want things to be *really* easy to run test suites in multiple
> languages, do this.

another option is this:

  http://people.apache.org/~geoff/test-more-separately.tar.gz

which illustrates how to separate planning, etc in perl but use a
foreign tap producing faile - something we do all the time over in httpd
land...

anyway, in that tarball t/plan.t calls

  print qx!perl t/response.pl!;

so alter that call to execute whatever shell command you like, say

  print qx!./response.exe!;


 and alter response.exe to emit tap using $language and you're all set.

HTH

--Geoff


Re: run C++ TAP output? (even easier)

2007-03-09 Thread Ovid
If you want things to be *really* easy to run test suites in multiple
languages, do this.

First, make sure that all test programs are executable.  Then use this
driver program:

   $ cat bin/run.pl 
   #!/usr/bin/perl
 
   use strict;
   use warnings;
 
   my $prog = shift;
   unless ( -e $prog && -x _ ) {
   die "Cannot find or execute ($prog)";
   }
   exec $prog;

Then 'find' all executable files and use the '--exec' option with
runtests to execute all of them with the 'bin/run.pl' program:

  $ find t/ -perm /u+x -type f | xargs runtests --exec bin/run.pl 
  t/tap Failed 1/3 subtests 
  t/perl...ok   
  
  Test Summary Report
  ---
  t/tap.exe (Wstat: 0 Tests: 3 Failed: 1)
Failed tests:  2
  Files=2, Tests=5,  0 wallclock secs ( 0.04 cusr +  0.00 csys =  0.04
CPU)

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/