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

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

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

                                         Interactively run some Rt test files in a package
                                         一些RT测试文件包中的交互方式运行

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

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

Run some Rt test files in a package from within an interactive R session. There are two major modes in which runtests() can be used:
运行一些RT测试文件包内互动的R会话。有两个主要的模式,其中runtests()可以使用:

full=FALSE: Running tests within the current R session, which can change existing R variables, and create new ones.
full=FALSE:在目前的R会话,它可以改变现有的R参数,并建立新的运行测试。

full=TRUE: Running tests by creating a new R session for each test file.  This is safer, but slower, and also requires an installed version of the package in a local directory, such as one created by running R CMD check at the command line.
full=TRUE:运行测试,每个测试文件中创建一个新的R会话。这是更安全,但速度慢,还需要安装的软件包版本的本地目录中,如通过运行R CMD check在命令行中。


用法----------Usage----------


runtests(pkg.dir = getOption("scriptests.pkg.dir", "pkg"),
         pattern = ".*",
         file = NULL,
         full = FALSE,
         dir = TRUE,
         clobber = FALSE,
         output.suffix = NULL,
         console = FALSE,
         ...,
         verbose = TRUE,
         envir = globalenv(),
         subst = NULL,
         path = getOption("scriptests.pkg.path", default=getwd()))

dumprout(res = .Last.value,
         output.suffix = ".Rout.tmp",
         verbose = TRUE,
         console = FALSE,
         files = !console,
         clobber = identical(output.suffix, ".Rout.tmp"),
         level=c("error", "all", "info", "warning"))



参数----------Arguments----------

参数:pkg.dir
The directory in which the package code and tests reside.
包的代码和测试所在的目录中。


参数:path
The path to the package in which the tests reside.  If path contains $PKG, the value of pkg.dir will be substituted for $PKG, otherwise the value of pkg.dir will be appended to pkg.dir to give the location of the pacakge.  
路径包的测试。如果path包含$PKG,pkg.dir将被替换为$PKG,否则pkg.dir将追加到pkg.dir得到的位置的线路咨询。


参数:pattern
A regular expression pattern of test files to be run. Only one of pattern and file should be supplied.
正则表达式模式的测试文件来运行。只有一个pattern和file应提供。


参数:file
The name of the file(s) containing tests to be run.
该文件的名称(),其中包含要执行的测试。


参数:full
If TRUE run in full testing environment: create directory for tests; copy tests to that directory; chdir to directory; run each test file in a newly created R session.  
如果TRUE完整的测试环境中运行:创建目录的测试;拷贝测试中,该目录chdir到目录,运行每一个测试文件在一个新创建的R会话。


参数:dir
Directory where tests will be run.  The default is usually satisfactory.  This can be important if the files access and/or create any files or directories.  The default value depends on full: if full=FALSE the default value is paste(pkg.dir, ".tests", sep=""; if full=TRUE the default value is paste(pkg.dir, ".Rcheck/tests", sep="". Supply dir=FALSE to run tests in the current directory.
目录测试将被运行。默认的通常是令人满意的。这可能是重要的,如果文件的访问和/或创建的任何文件或目录。默认值取决于full:如果full=FALSE的默认值是paste(pkg.dir, ".tests", sep=""如果full=TRUE的默认值是paste(pkg.dir, ".Rcheck/tests", sep=""。供应dir=FALSE在当前目录运行测试。


参数:console
If TRUE, output from the test will be written as output from this function.  The default is FALSE for runtests() and TRUE for dumprout().
如果TRUE,从测试输出将被写入从这个函数的输出。默认的是FALSEruntests()TRUE和dumprout()。


参数:files
Opposite of console (specify just console=TRUE or file=TRUE)
对面只有console或console=TRUEfile=TRUE(指定)


参数:clobber
Should existing output files or directories be clobbered?  For safety, the default is FALSE.  For runtests(), if the dir already exists, clobber=TRUE will result in replacing that directory, clobber=FALSE will result in stopping with an error if the directory already exists.  
如果现有的输出文件或目录被篡改?为了安全起见,默认的是FALSE。对于runtests(),如果已经存在的dir,clobber=TRUE会导致在更换该目录,clobber=FALSE会导致一个错误,如果停止该目录已经存在。


参数:output.suffix
File suffix for actual output transcript files (default NULL for runtests, meaning no files written), if output.suffix==TRUE, uses suffix .Rout.tmp  
文件后缀为实际输出成绩单文件为runtests,这意味着没有书面的文件(默认为空),如果output.suffix==TRUE,使用后缀.Rout.tmp


参数:level
Skip files unless they have notifications at the specified level or above.
跳过文件,除非他们有通知在指定级别或以上。


参数:...
Arguments to pass on to runScripTests().  Only relevant when full=TRUE. (Ignored with a warning message otherwise.)
参数传递到runScripTests()。只有相关的,当full=TRUE。 (一个警告消息,否则忽略)。


参数:verbose
Should progress indications be printed?  
进度指示印刷?


参数:envir
The environment in which to run the tests.  
所处的环境来运行测试。


参数:subst
Provides control over whether the string "package:::" is removed from test code.  Supply subst=FALSE to prevent any substitution.  The default value will remove "package:::" when appropriate.  
提供的字符串是否"package:::"被删除测试代码的控制权。供应subst=FALSE的,防止任何替代。默认值将删除"package:::"在适当的时候。


参数:res
A value returned from runtests().  
返回的值runtests()。


Details

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

runtests() runs some or all of the tests (in .Rt files) found in the tests directory of a package.  The arguments pkg.dir and path are used to specify the location of the package (see the section Running tests below for further details).  runtests() is designed to be used in conjunction with source.pkg(), which reads all the R code in a package into a special environment on the search path.  With the default argument full=FALSE, runtests() will run the tests in the same R session, though it will create a special directory which will be used as the working directory while running the tests.  In this mode of operation, output from tests is not is not written to files (unless output.suffix is supplied with a value), though tests may create or modify files themselves.
runtests()运行.Rt目录的包中发现的部分或全部的测试(tests文件)。的参数pkg.dir和path是用来指定包的位置(请参见运行测试,下面为进一步细节)。 runtests()设计使用结合source.pkg(),它读取所有的R代码包到一个特殊的环境上的搜索路径。使用默认参数full=FALSE,runtests()将运行在相同的R会话的测试,但它会创建一个特殊的目录将被用来作为工作目录,而运行测试。在这种操作模式下,输出测试是不是就是不写入文件(除非output.suffix提供的值),但测试可以创建或修改文件本身。

Supplying runtests(..., full=TRUE) will run each test file in a new R session - the way tests are run under R CMD check.  When run like this, the package must be installed in the location <pkg.dir>.Rcheck or or <pkg.name>.Rcheck, relative to the working directory of the current R session.  This can be accomplished by running the shell command
供应runtests(..., full=TRUE)将运行在一个新的R会话的每个测试文件 - 测试运行的方式下R CMD check。像这样运行时,必须将软件包安装的位置<pkg.dir>.Rcheck或<pkg.name>.Rcheck,相对于目前的R会话的工作目录。这可以通过运行shell命令


值----------Value----------

runtests() returns an invisible list of RtTestSetResults objects (each element of the list is the result of running and checking the test in one file.) This result can be given to dumprout() to write actual R output to temporary files for test debugging and development purposes. dumprout() returns its first argument (whose default value is .Last.value), allowing it to be run several times in a row without having to supply any arguments
runtests()返回一个无形的名单,这个结果可以给RtTestSetResults写实际的dumprout()对象(列表中的每个元素是在一个文件中的运行和检查测试结果。) R输出到临时文件测试调试和开发的目的。 dumprout()返回第一个参数(其默认值是.Last.value),允许它运行在一排几次,而无需提供任何参数


运行测试----------Running tests----------

runtests() is intended to be used in an R session while developing and/or maintaining code and/or tests.  It is designed to work together with source.pkg(), which rapidly reads the R code in a package..  The arguments given to runtests() will depend on how package directories are organized, and the working directory for the R session used for code and test development.
runtests()的目的是在开发和/或维护代码和/或测试中使用的R会话。它被设计成一起工作source.pkg(),迅速读取的R代码包中的..给出的参数runtests()将取决于如何组织包目录中,用于代码和测试开发的R会话的工作目录。

Scenario 1: working directory of R session contains the package source code
方案1:R会话的工作目录包含包源代码

The package source code mynewpkg is in
包源代码mynewpkg是在


(作者)----------Author(s)----------


Tony Plate <a href="mailto:tplate@acm.org">tplate@acm.org</a>



参见----------See Also----------

source.pkg() shares the options scriptests.pkg.dir and scriptests.pkg.path that provide defaults for the pkg.dir and path arguments.
source.pkg()股份的选项scriptests.pkg.dir和scriptests.pkg.pathpkg.dir和path参数提供默认值。

For running tests in under R CMD check, use the function runScripTests() in the file tests/runtests.R in the package.
对于在R CMD check运行测试,使用功能runScripTests()文件中的tests/runtests.R包中。

For an overview and for more details of how tests are run, inlcuding how to make test output matching more flexible, see scriptests.
有关概述和如何测试运行的详细信息,计有测试输出匹配更灵活的中,看到scriptests。


实例----------Examples----------


## Not run: [#不运行:]
&gt; # To run like this example, set the current working directory[要运行这个例子一样,设置当前工作目录]
&gt; # to where the package code lives.[封装代码的生活。]
&gt; # source.pkg() reads in the functions -- could just as well[source.pkg()读取的功能 - 可以一样好]
&gt; # load the library, but source.pkg() can be more convenient[加载库中,但source.pkg()可以更方便]
&gt; # when developing a package.[在开发包。]
> source.pkg("scriptests")
Reading 5 .R files into env at pos 2: 'pkgcode:scriptests'
Sourcing scriptests/R/createRfromRt.R
Sourcing scriptests/R/interactive.R
Sourcing scriptests/R/oldcode.R
Sourcing scriptests/R/plus.R
Sourcing scriptests/R/rttests.R
list()
> runtests("simple1")
Running tests in scriptests/tests/simple1.Rt (read 4 chunks)
....
Ran 4 tests with 0 errors and 0 warnings from scriptests/tests/simple1.Rt
> runtests("simple2")
Running tests in scriptests/tests/simple2.Rt (read 5 chunks)
.....
Ran 5 tests with 0 errors and 0 warnings from scriptests/tests/simple2.Rt
> runtests("simple")
Running tests in scriptests/tests/simple1.Rt (read 4 chunks)
....
Ran 4 tests with 0 errors and 0 warnings from scriptests/tests/simple1.Rt
Running tests in scriptests/tests/simple2.Rt (read 5 chunks)
.....
Ran 5 tests with 0 errors and 0 warnings from scriptests/tests/simple2.Rt
>

## End(Not run)[#(不执行)]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-30 00:32 , Processed in 0.029338 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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