2015-12-26 168 views
3

我的一個測試失敗了,我想用git bisect來追蹤它。如何從命令行運行devtools :: test?

爲此,我需要從命令行運行devtools::test,以便進程退出代碼指示是否所有測試都已通過。

我該怎麼做?

+3

爲什麼不使用R CMD CHECK而不是devtools? – Thomas

+0

@Thomas:我會接受一個給出完整命令的答案。簡單的'R CMD CHECK。'不起作用,我想我需要首先生成一個tarball ... devtools只是照顧所有這些。 –

+0

更具體地說,'R CMD check .'的結果是:'必填項缺失或爲空: '作者''維護者' '(並且不運行測試)。 –

回答

4

在命令行中,標準軟件包構建工作流程是使用R CMD build創建軟件包壓縮包,然後使用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值)。如果你只有在建目錄中一個包壓縮包,你可以使用通配符來創建可重用的工作流程:

R CMD build dirname 
R CMD check pkgname*.tar.gz 

還,如果你打算在包裹運送到CRAN,那你也應該記住運行檢查--as-cran選項,該選項運行一些額外的檢查。

+0

謝謝,這工作!唯一的修正是,看起來'build'的參數是一個目錄,而不是包名,所以當我進入包的根目錄時,我需要運行'R CMD build .'。 –

+0

@RomanCheplyaka對不起,這是正確的,我總是使用與包匹配的目錄名稱,所以我忘記了區別。 – Thomas