如何从命令行 运行 devtools::test?
How to run devtools::test from the command line?
我的一个测试失败了,我想使用 git bisect 来追踪它。
为此,我需要从命令行 运行 devtools::test
以进程退出代码指示是否所有测试都已通过的方式。
我该怎么做?
在命令行中,标准包构建工作流程是使用 R CMD build
创建包 tarball,然后使用 R CMD check
检查它。 devtools 只是 运行 为您使用 system()
调用的工作流。这对你来说会是什么样子:
R CMD build dirname
R CMD check pkgname_version.tar.gz
这将根据所有检查是否成功给出适当的状态代码。如果您只想检查测试(而不是其他包功能),那么您将不得不探索 R CMD check
选项。这些将使您能够关闭(某些)其他特定检查,例如文档示例、插图、构建文档的 PDF 等。
这些选项的当前列表(针对 R2.3.3)是:
> R CMD check --help
Check R packages from package sources, which can be directories or
package 'tar' archives with extension '.tar.gz', '.tar.bz2',
'.tar.xz' or '.tgz'.
A variety of diagnostic checks on directory structure, index and
control files are performed. The package is installed into the log
directory and production of the package PDF manual is tested.
All examples and tests provided by the package are tested to see if
they run successfully. By default code in the vignettes is tested,
as is re-building the vignette PDFs.
Options:
-h, --help print short help message and exit
-v, --version print version info and exit
-l, --library=LIB library directory used for test installation
of packages (default is outdir)
-o, --output=DIR directory for output, default is current directory.
Logfiles, R output, etc. will be placed in 'pkg.Rcheck'
in this directory, where 'pkg' is the name of the
checked package
--no-clean do not clean 'outdir' before using it
--no-codoc do not check for code/documentation mismatches
--no-examples do not run the examples in the Rd files
--no-install skip installation and associated tests
--no-tests do not run code in 'tests' subdirectory
--no-manual do not produce the PDF manual
--no-vignettes do not run R code in vignettes nor build outputs
--no-build-vignettes do not build vignette outputs
--run-dontrun do run \dontrun sections in the Rd files
--run-donttest do run \donttest sections in the Rd files
--use-gct use 'gctorture(TRUE)' when running examples/tests
--use-valgrind use 'valgrind' when running examples/tests/vignettes
--timings record timings for examples
--install-args= command-line args to be passed to INSTALL
--test-dir= look in this subdirectory for test scripts (default tests)
--check-subdirs=default|yes|no
run checks on the package subdirectories
(default is yes for a tarball, no otherwise)
--as-cran select customizations similar to those used
for CRAN incoming checking
The following options apply where sub-architectures are in use:
--extra-arch do only runtime tests needed for an additional
sub-architecture.
--multiarch do runtime tests on all installed sub-archs
--no-multiarch do runtime tests only on the main sub-architecture
--force-multiarch run tests on all sub-archs even for packages
with no compiled code
By default, all test sections are turned on.
Report bugs at bugs.r-project.org .
注意:对于 R CMD check
,您必须手动指定包版本号(这将基于包 DESCRIPTION
文件中 Version
的值)。如果目录中只构建了一个包 tarball,则可以使用通配符创建可重用的工作流程:
R CMD build dirname
R CMD check pkgname*.tar.gz
还请记住,如果您计划将包裹运送到 CRAN,您还应该 运行 使用 --as-cran
选项进行检查,其中 运行 是一些额外的检查。
我的一个测试失败了,我想使用 git bisect 来追踪它。
为此,我需要从命令行 运行 devtools::test
以进程退出代码指示是否所有测试都已通过的方式。
我该怎么做?
在命令行中,标准包构建工作流程是使用 R CMD build
创建包 tarball,然后使用 R CMD check
检查它。 devtools 只是 运行 为您使用 system()
调用的工作流。这对你来说会是什么样子:
R CMD build dirname
R CMD check pkgname_version.tar.gz
这将根据所有检查是否成功给出适当的状态代码。如果您只想检查测试(而不是其他包功能),那么您将不得不探索 R CMD check
选项。这些将使您能够关闭(某些)其他特定检查,例如文档示例、插图、构建文档的 PDF 等。
这些选项的当前列表(针对 R2.3.3)是:
> R CMD check --help
Check R packages from package sources, which can be directories or
package 'tar' archives with extension '.tar.gz', '.tar.bz2',
'.tar.xz' or '.tgz'.
A variety of diagnostic checks on directory structure, index and
control files are performed. The package is installed into the log
directory and production of the package PDF manual is tested.
All examples and tests provided by the package are tested to see if
they run successfully. By default code in the vignettes is tested,
as is re-building the vignette PDFs.
Options:
-h, --help print short help message and exit
-v, --version print version info and exit
-l, --library=LIB library directory used for test installation
of packages (default is outdir)
-o, --output=DIR directory for output, default is current directory.
Logfiles, R output, etc. will be placed in 'pkg.Rcheck'
in this directory, where 'pkg' is the name of the
checked package
--no-clean do not clean 'outdir' before using it
--no-codoc do not check for code/documentation mismatches
--no-examples do not run the examples in the Rd files
--no-install skip installation and associated tests
--no-tests do not run code in 'tests' subdirectory
--no-manual do not produce the PDF manual
--no-vignettes do not run R code in vignettes nor build outputs
--no-build-vignettes do not build vignette outputs
--run-dontrun do run \dontrun sections in the Rd files
--run-donttest do run \donttest sections in the Rd files
--use-gct use 'gctorture(TRUE)' when running examples/tests
--use-valgrind use 'valgrind' when running examples/tests/vignettes
--timings record timings for examples
--install-args= command-line args to be passed to INSTALL
--test-dir= look in this subdirectory for test scripts (default tests)
--check-subdirs=default|yes|no
run checks on the package subdirectories
(default is yes for a tarball, no otherwise)
--as-cran select customizations similar to those used
for CRAN incoming checking
The following options apply where sub-architectures are in use:
--extra-arch do only runtime tests needed for an additional
sub-architecture.
--multiarch do runtime tests on all installed sub-archs
--no-multiarch do runtime tests only on the main sub-architecture
--force-multiarch run tests on all sub-archs even for packages
with no compiled code
By default, all test sections are turned on.
Report bugs at bugs.r-project.org .
注意:对于 R CMD check
,您必须手动指定包版本号(这将基于包 DESCRIPTION
文件中 Version
的值)。如果目录中只构建了一个包 tarball,则可以使用通配符创建可重用的工作流程:
R CMD build dirname
R CMD check pkgname*.tar.gz
还请记住,如果您计划将包裹运送到 CRAN,您还应该 运行 使用 --as-cran
选项进行检查,其中 运行 是一些额外的检查。