找回密码
 注册
查看: 453|回复: 0

R语言 scriptests包 scriptests.design()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-29 23:06:16 | 显示全部楼层 |阅读模式
scriptests.design(scriptests)
scriptests.design()所属R语言包:scriptests

                                        Design considerations for package scriptests
                                         设计包scriptests的考虑

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Design considerations for package scriptests.  This file is a poorly organized collection of notes regarding the design and evolution of the scriptests package.
设计考虑包scriptests。该文件是一个组织得很差的集合的设计和改进的scriptests包的注意事项。


Details

详细信息----------Details----------

"R CMD check" is (as of R-2.9.0) an R script src/scripts/check.in, which invokes R with the command tools:::.runPackageTestsR($extra) to run tests.  If this R session returns non-zero, the check process stops with an error, outputting 13 lines from the first .fail file found (if one exists).
“R CMD检查”的(如R-2.9.0)R脚本src/scripts/check.in,调用R的命令tools:::.runPackageTestsR($extra)运行测试。如果该R会话返回非0,检查过程停止错误,从第13行输出。无法找到的文件(如果存在的话)。

tools:::.runPackageTestsR($extra) invokes R CMD BATCH to run each .R file.  This is where the non-overrideable redirection of stderr to .Rout happens.
tools:::.runPackageTestsR($extra)调用R CMD BATCH运行。R档。这是其中非overrideable的重定向stderr到。溃败的发生。

New design for scriptests to work with R-2.9.0 in which "R CMD check" no longer uses Makefiles in tests directory.
新为scriptests设计与R-2.9.0“R CMD检查”不再使用Makefile中的测试目录。

All transcript files are stored in the tests directory with the file extension .Rt.
所有抄本文件都存储在tests目录的文件扩展名.Rt。

There should be a file called runtests.Rin, which should contain the following two lines:
应该有一个文件称为runtests.Rin,其中应包含以下两行:

When runScripTests() runs, it will create a .R file with the commands extracted from each .Rt file.  It will then run each .R file in a separate R session, save the output in a .Rout file, and compare the output with the .Rt file.  runScripTests will leave a summary in the file test-summary.txt.  If there are errors, the summary will be duplicated in the file test-summary.fail (the presence of a file ending in .fail signals an error to "R CMD     check".)
当runScripTests()运行时,它会创建一个.R从每一个.Rt文件中提取文件的命令。然后,它会在一个单独的.R会话中运行每个R文件,保存在一个.Rout文件的输出,比较输出.Rt文件。 runScripTests将离开的概要文件中的test-summary.txt。如果有错误,总结会的文件复制test-summary.fail(.fail发出错误信号,"R CMD     check"。)存在的文件结束


比较以前scriptests设计的----------Comparisons to previous scriptests designs----------

The functionality that this design gives up over previous designs is immediate checking of test output.  Instead test output is checked after all tests are run.  This is because of the difficulty of controlling the execution order of different test files – it's hard to create pairs of test/check files that will run in the correct order (order of execution depends on the order of files in the value of dir).
放弃以前的设计相比,这样的设计是立即检查测试输出的功能。相反,测试输出后检查所有的测试运行。这是因为不同的测试文件的执行顺序控制的难度 - 这是努力创造对测试/检查文件,将运行在正确的顺序(顺序执行取决于文件的顺序的价值dir)。

The functionality that this design retains from previous designs (and from the native testing framework in R) is that each file of R commands to be checked in run in a new R session.  This means that commands in one test file cannot mess up another test file.  It also means that the testing framework doesn't need to mess around with trying to capture output.
从以前的设计(从本机测试框架,在R)保留的功能,这样的设计是一个新的R会话中运行的每一个文件的R命令进行检查。这意味着,在一个测试文件中的命令不能再搞砸了测试文件。这也意味着,测试框架并不需要周围的混乱,试图捕捉输出。

There are several possible methods that could be used to check output immediately after running each test:
有几种可能的方法,可以用来查询后立即运行每个测试输出:

prepend each .R file with a function that checks output of all previously run tests (skipping ones already done).
每一个.R文件前面加上一个函数,检查所有以前运行测试(跳过已经完成的)的输出。

append to each .R file a call to a function that flushes stdout (flush(stdout())) and checks tests output.
追加到每个.R文件调用一个函数,刷新标准输出(flush(stdout())),并检查测试输出。

define a .Last() function (will be called by q()) that checks test output.
定义.Last()功能(将被称为的q()),检查测试输出。

Hangup with the above approach: it's not possible to have output from the runs go to stdout – because all the output from running a .R file is redirected to the corresponding .Rout file.
挂断与上述方法:这是不可能的,从运行到stdout输出 - ,因为运行。R文件的所有输出被重定向到相应的。溃败文件。

Alternate approach: a setup file calls my own version of .runPackageTests(), which then executes an R session for each .R file.  Still have the problem of not getting any output to the console.  Can solve this by by-passing R CMD BATCH, and just invoking R more directly.
另一种方法:设置文件调用我自己的版本。runPackageTests(),然后执行一个R会话。R档。还是有问题,没有得到任何输出到控制台。可以由通过R CMD BATCH来解决这个问题,只是调用R更多直接。


的原始scriptests设计的基础上的Makefile----------Original scriptests design based on Makefiles----------

An initial design changed the default goal by assigning .DEFAULT\_GOAL in tests/Makefile.  This works with GNU make version 3.81, which is standard in Ubuntu Linux.  However, the Rtools set of programs for Windows includes GNU make version 3.79, which does not appear to recognize the .DEFAULT\_GOAL special variable.  Additionally, version 2.6.2 (2008-02-08) of "R Installation and Administration" specifically says that GNU make version 3.81 does not work to compile under Windows. Furthermore, Mac OS X version 10.4 (Tiger) includes GNU make version 3.80, which also does not appear to recognize the .DEFAULT\_GOAL special variable.
最初的设计改变了默认的目标分配。DEFAULT \ _GOAL在测试/ Makefile文件。这适用于GNU make版本3.81,这是在Ubuntu Linux的标准。然而,Rtools适用于Windows的程序集,包括GNU make版本3.79,这似乎并不认识。DEFAULT \ _GOAL的特殊变量。此外,版本2.6.2(2008-02-08),“R安装和管理”,具体说,GNU版本3.81不工作,在Windows下编译。此外,Mac OS X版本10.4(Tiger)的包括GNU make版本3.80,这也似乎并不认识。DEFAULT \ _GOAL的特殊变量。

Consequently, a different approach to getting R CMD check to run additional tests is needed.
因此,不同的方法来获得R CMD检查,以执行额外的测试是必要的。

The approach implemented as of version 0.1-6 (March 2009) is to use a "%" target in the makefile (which is always called), with an action in the body of the rule that invokes a 'make' recursively with the desired target (here all-Rt).
为0.1-6版(2009年3月)实现的方法是使用“%”的目标在Makefile(总是),行动在体内的规则,调用make的递归所需的目标(在这里all-Rt)。

http://www.gnu.org/software/automake/manual/make/Force-Targets.html describes 'force targets'.
http://www.gnu.org/software/automake/manual/make/Force-Targets.html描述了“力目标”。

Here's the relevant section from scriptests/inst/scripts/Makefile.sub:
从scriptests / INST /脚本/ Makefile.sub的中的相关章节:

This makefile does two things to try to create a goal: (1) it edits Makevars to insert an extra goal; and (2) it uses a specific rule for a allrt.Rin to allrt.R to run a sub-make (the rule is written to Makevars).
这个makefile做了两件事,试图创造了一个目标:(1)编辑Makevars插入一个额外的目标;(2),它使用一个特定的规则的allrt.Rin的allrt.R运行子(规则被写入到Makevars)。

Both of these approaches should work, but the whole thing does not seem to work reliably.  In any case, the sub-make can be called directly from the "force" block instead of using the force block to create a rule that calls the sub-make.  This code is preserved here because it uses a number of techniques that might come in handy somewhere else.
这两种方法都应该工作,但整个事情似乎并不可靠地工作。在任何情况下,子可以直接调用,而不是使用武力块来创建一个规则,调用子从“力”块。此代码是保存在这里,因为它使用了大量的技术可能派上用场了别的地方。

This framework uses three files in the tests directory: Makefile, Makefile.win and  allrt.Rin.
这个框架使用的测试目录中的三个文件:Makefile,Makefile.win和allrt.Rin。

Makefile:
Makefile文件:

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-29 22:32 , Processed in 0.033034 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表