Re: [Rd] unit testing for R packages?

2009-10-06 Thread Shane Conway
If you haven't done so already, you might want to read the RUnit Vignette:
http://cran.r-project.org/web/packages/RUnit/vignettes/RUnit.pdf.
On a somewhat related note: is anyone doing continuous integration with
their R packages?  I'm thinking about trying to use something like
CruiseControl (which I used before for Java development), and was wondering
if anyone had experience with how much work will be involved...


On Mon, Oct 5, 2009 at 3:01 PM, Blair Christian
blair.christ...@gmail.comwrote:

 Hi All,

 I'm interested in putting some unit tests into an R package I'm
 building.  I have seen assorted things such as Runit library, svUnit
 library, packages
 with 'tests' directories, etc

 I grep'd unit test through the writing R extensions manual but didn't
 find
 anything.  Are there any suggestions out there?  Currently I have
 several (a lot?) classes/methods that I keep tinkering with, and I'd
 like to run a script frequently to check that I don't cause any
 unforeseen problems.

 Right now I'm writing the classes/methods, but will be packaging it up
 soon.

 Thx,
 Blair

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-06 Thread hadley wickham
 If you haven't done so already, you might want to read the RUnit Vignette:
 http://cran.r-project.org/web/packages/RUnit/vignettes/RUnit.pdf.
 On a somewhat related note: is anyone doing continuous integration with
 their R packages?  I'm thinking about trying to use something like
 CruiseControl (which I used before for Java development), and was wondering
 if anyone had experience with how much work will be involved...

It's not quite continuous integration, but I've been working on some
code for autotesting - i.e. any time your code or tests change, rerun
the appropriate part of the test suite (as much as I can guess at
that)

Hadley


-- 
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-06 Thread Shane Conway
On a related note: I recently started to set up CruiseControl (
http://cruisecontrol.sourceforge.net/) to do continuous integration with my
R packages (along with my RUnit test cases).  Has anyone had any luck with
this before?
I use it for other software and it provides a very nice interface...

On Tue, Oct 6, 2009 at 10:33 AM, hadley wickham h.wick...@gmail.com wrote:

  If you haven't done so already, you might want to read the RUnit
 Vignette:
  http://cran.r-project.org/web/packages/RUnit/vignettes/RUnit.pdf.
  On a somewhat related note: is anyone doing continuous integration with
  their R packages?  I'm thinking about trying to use something like
  CruiseControl (which I used before for Java development), and was
 wondering
  if anyone had experience with how much work will be involved...

 It's not quite continuous integration, but I've been working on some
 code for autotesting - i.e. any time your code or tests change, rerun
 the appropriate part of the test suite (as much as I can guess at
 that)

 Hadley


 --
 http://had.co.nz/


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 10/5/2009 3:01 PM, Blair Christian wrote:

Hi All,

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  



Nothing very specific, but what there is is described in that manual in 
the discussion of the tests subdirectory.


Duncan Murdoch

Currently I have

several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.

Right now I'm writing the classes/methods, but will be packaging it up soon.

Thx,
Blair

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Seth Falcon
Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
 I'm interested in putting some unit tests into an R package I'm
 building.  I have seen assorted things such as Runit library, svUnit
 library, packages
 with 'tests' directories, etc

 I grep'd unit test through the writing R extensions manual but didn't find
 anything.  Are there any suggestions out there?  Currently I have
 several (a lot?) classes/methods that I keep tinkering with, and I'd
 like to run a script frequently to check that I don't cause any
 unforeseen problems.

I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/user

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Paul Gilbert
Seth

I should look at RUnit more carefully sometime, but having had my own system in 
place from much earlier, I've never made the move. Basically I just use files 
in the tests/ directory which are run by a makefile in the package directory 
above. Roughly, this just means that I can run the tests quickly before 
building and checking the package. Is there a (very short) explanation of the 
main things that RUnit gives beyond this?

Thanks,
Paul

 -Original Message-
 From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-
 project.org] On Behalf Of Seth Falcon
 Sent: October 5, 2009 3:48 PM
 To: Blair Christian
 Cc: r-devel@r-project.org
 Subject: Re: [Rd] unit testing for R packages?
 
 Hi,
 
 On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
 blair.christ...@gmail.com wrote:
  I'm interested in putting some unit tests into an R package I'm
  building.  I have seen assorted things such as Runit library, svUnit
  library, packages
  with 'tests' directories, etc
 
  I grep'd unit test through the writing R extensions manual but
 didn't find
  anything.  Are there any suggestions out there?  Currently I have
  several (a lot?) classes/methods that I keep tinkering with, and I'd
  like to run a script frequently to check that I don't cause any
  unforeseen problems.
 
 I've had good experiences using RUnit.  To date, I've mostly used
 RUnit by putting tests in inst/unitTests and creating a Makefile there
 to run the tests.  You should also be able to use RUnit in a more
 interactive fashion inside an interactive R session in which you are
 doing development.
 
 The vignette in svUnit has an interesting approach for integrating
 unit testing into R CMD check via examples in an Rd file within the
 package.
 
 + seth
 
 --
 Seth Falcon | @sfalcon | http://userprimary.net/user
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


La version française suit le texte anglais.



This email may contain privileged and/or confidential information, and the Bank 
of
Canada does not waive any related rights. Any distribution, use, or copying of 
this
email or the information it contains by other than the intended recipient is
unauthorized. If you received this email in error please delete it immediately 
from
your system and notify the sender promptly by email that you have done so. 



Le présent courriel peut contenir de l'information privilégiée ou 
confidentielle.
La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute 
diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il contient par une
personne autre que le ou les destinataires désignés est interdite. Si vous 
recevez
ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans 
délai à
l'expéditeur un message électronique pour l'aviser que vous avez éliminé de 
votre
ordinateur toute copie du courriel reçu.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 05/10/2009 4:39 PM, spencerg wrote:
I put unit test in the examples, using \dontshow to hide stopifnot.  
Many help pages I've written contain code like the following: 



A - functionDocumentedHere()
B - manuallyComputedAnswer

\dontshow{stopifnot(}
all.equal(A, B)
\dontshow{)}


This will fail in a future release of R, because those aren't valid 
expressions within \dontshow{}, which expects R code.  You can achieve 
the same effect using the clearer


all.equal(A,B)
\dontshow{ stopifnot(isTrue(.Last.value)) }

Duncan Murdoch




  I think it helps the documentation to include an example comparing 
a special case computed using a function with a manual computation.  
However, stopifnot contributes nothing to user understanding, so I 
hide it.  One could also use \dontshow to hide entire examples that 
check trivial details you think would not interest users. 



  Spencer


Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
  

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

  





__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 05/10/2009 6:06 PM, spencerg wrote:
Hi, Duncan: 



  Thanks for the warning.  Can you give me a hint of which release 
might require this?  In particular, will it be R 2.10.0, coming quite 
soon? 


The alpha version of 2.10.0 lets this pass, and I can't see changing 
that now.  But 2.11.0 (due next spring) may well enforce the rules that 
have been documented but unenforced since before the release of 2.9.0.


Duncan Murdoch



  Thanks,
  Spencer


Duncan Murdoch wrote:

On 05/10/2009 4:39 PM, spencerg wrote:
I put unit test in the examples, using \dontshow to hide 
stopifnot.  Many help pages I've written contain code like the 
following:


A - functionDocumentedHere()
B - manuallyComputedAnswer

\dontshow{stopifnot(}
all.equal(A, B)
\dontshow{)}
This will fail in a future release of R, because those aren't valid 
expressions within \dontshow{}, which expects R code.  You can achieve 
the same effect using the clearer


all.equal(A,B)
\dontshow{ stopifnot(isTrue(.Last.value)) }

Duncan Murdoch



  I think it helps the documentation to include an example 
comparing a special case computed using a function with a manual 
computation.  However, stopifnot contributes nothing to user 
understanding, so I hide it.  One could also use \dontshow to hide 
entire examples that check trivial details you think would not 
interest users.


  Spencer


Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
 

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but 
didn't find

anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

  









__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Philippe Grosjean

Hi,

I am the writer of svUnit. My initial goal was to build functions on top
of RUnit which is older, and certainly deserves all the credit for core
test unit functions. Unfortunately, the way RUnit is working internally
did not allowed me to build the extensions I needed.

Now, as Seth already told, there are several functions in svUnit that
ease interactive use of the tests in an R session. What he did not told
is that RUnit has some nice code coverage functions that svUnit does not
have.

Thus, not easy to decide... The good news is that both RUnit and svUnit
are almost completely compatible with test unit code, that is, the same
code put in inst/unitTests should run with both packages. So, you could
write your test units, try both approaches in practice, and finally
decide after a little bit of experiment which one you prefer (at least,
read the vignette of each packages).

In case you use Komodo Edit as R code editor, there is a nice GUI
interactive panel to svUnit available (see
http://www.sciviews.org/SciViews-K).

Best,

Philippe Grosjean

Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Peter Cowan
On Mon, Oct 5, 2009 at 5:44 PM, hadley wickham h.wick...@gmail.com wrote:
 Now, as Seth already told, there are several functions in svUnit that
 ease interactive use of the tests in an R session. What he did not told
 is that RUnit has some nice code coverage functions that svUnit does not
 have.

 What are those? I've skimmed through the documentation and couldn't
 see anything?

The R wiki has information about both RUnit and svUnit.  I'm not sure
that it details all of the differences.  I have successfully used the
methodology of the gdata package described there.

http://wiki.r-project.org/rwiki/doku.php?id=developers:runit

Peter



 Hadley

 --
 http://had.co.nz/

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] unit testing for R packages?

2009-10-05 Thread hadley wickham
On Mon, Oct 5, 2009 at 8:48 PM, Peter Cowan cowan...@gmail.com wrote:
 On Mon, Oct 5, 2009 at 5:44 PM, hadley wickham h.wick...@gmail.com wrote:
 Now, as Seth already told, there are several functions in svUnit that
 ease interactive use of the tests in an R session. What he did not told
 is that RUnit has some nice code coverage functions that svUnit does not
 have.

 What are those? I've skimmed through the documentation and couldn't
 see anything?

 The R wiki has information about both RUnit and svUnit.  I'm not sure
 that it details all of the differences.  I have successfully used the
 methodology of the gdata package described there.

Sorry, I should have been more explicit.  I was interested
particularly in the code coverage functions.

Hadley


-- 
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel