[R] tests Rin Rout

2008-03-30 Thread Christophe Genolini
Hi the list,

Some rumour (!) say that is it possible to prepare some tests for 
checking our code using .Rin and .Rout. It seems to be a very good 
practice, but I did not manage to find information on it.
So does someone know how it works ? What are we suppose to write in Rin ?

More precisely :
 - I have a package myPack.r in directories ~/myR/myPack/R/
 - I create the directory ~/myR/myPack/tests

myPack.r is :

`f1` - function(x){cat(\nXXX F1 = ,x,XXX\n)}
`f2` - function(x){cat(\nXXX F2 = ,f1(x^2),XXX\n)}

What am I suppose to do to test it? Create myPack.Rin, but what in it?

Thanks for your help.

Christophe

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tests Rin Rout

2008-03-30 Thread Duncan Murdoch
On 30/03/2008 10:44 AM, Christophe Genolini wrote:
 Hi the list,
 
 Some rumour (!) say that is it possible to prepare some tests for 
 checking our code using .Rin and .Rout. It seems to be a very good 
 practice, but I did not manage to find information on it.
 So does someone know how it works ? What are we suppose to write in Rin ?

See the paragraph in Writing R Extensions which explains this, near the 
end of the section on Package Subdirectories (section 1.1.3 in the 
version I'm looking at).

Rin would be fairly rarely needed:  it is supposed to write a script to 
perform the tests.  Normally you write your script directly, in a .R file.

 
 More precisely :
  - I have a package myPack.r in directories ~/myR/myPack/R/
  - I create the directory ~/myR/myPack/tests
 
 myPack.r is :
 
 `f1` - function(x){cat(\nXXX F1 = ,x,XXX\n)}
 `f2` - function(x){cat(\nXXX F2 = ,f1(x^2),XXX\n)}
 
 What am I suppose to do to test it? Create myPack.Rin, but what in it?

Create tests/myPack.R with those lines in it plus lines to actually run 
the code.  If the code generates errors, your test will fail.  If you 
want to see reports of changes to the output, also include 
tests/myPack.Rout.save with the known correct versions of the output.

Duncan Murdoch

 
 Thanks for your help.
 
 Christophe
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tests Rin Rout

2008-03-30 Thread Christophe Genolini


 See the paragraph in Writing R Extensions which explains this
Well, I saw it again and again (before asking on the r-help) but I do 
not understand. Same for the Kurt Hornik slides on the web.


 Create tests/myPack.R with those lines in it plus lines to actually 
 run the code.
Does it mean that each time I change the code, I will have to change it 
twice, once in R/ and once in tests/
   If the code generates errors, your test will fail.  If you want to 
 see reports of changes to the output, also include 
 tests/myPack.Rout.save with the known correct versions of the output.

What should the Rout.save looks like ? I mean, what is the syntax of 
this file ?

Christophe

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tests Rin Rout

2008-03-30 Thread Duncan Murdoch
For questions like this about package development, you should ask on 
R-devel, but I'll continue the thread here for one more message.

On 30/03/2008 2:54 PM, Christophe Genolini wrote:
 See the paragraph in Writing R Extensions which explains this
 Well, I saw it again and again (before asking on the r-help) but I do 
 not understand. Same for the Kurt Hornik slides on the web.

Generally I find it's good to look at examples that work.  For examples 
of packages using tests, look at source packages on CRAN.  Run the tests 
on them (using R CMD check), and see what gets produced.

 Create tests/myPack.R with those lines in it plus lines to actually 
 run the code.
 Does it mean that each time I change the code, I will have to change it 
 twice, once in R/ and once in tests/

There shouldn't be any duplication.  Just put tests in the tests 
directory.  That code will be run with your package loaded when you run 
R CMD check.  If it fails, your package will fail the check.

   If the code generates errors, your test will fail.  If you want to 
 see reports of changes to the output, also include 
 tests/myPack.Rout.save with the known correct versions of the output.

 What should the Rout.save looks like ? I mean, what is the syntax of 
 this file ?

It should just be a copy of the Rout file produced from a previous 
trusted run.  R CMD check will ignore certain differences (like changes 
to the date or R version at the top of the file), but will report on others.

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.