Skip to content

Commit

Permalink
Add covr and testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
statnmap committed Jun 21, 2018
1 parent 20bdeeb commit 3c0772d
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 11 deletions.
16 changes: 9 additions & 7 deletions .Rbuildignore
@@ -1,7 +1,9 @@
^.*\.Rproj$
^\.Rproj\.user$
^devstuff_history\.R$
^\.travis\.yml$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
^README\.Rmd$
^.*\.Rproj$
^\.Rproj\.user$
^devstuff_history\.R$
^\.travis\.yml$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
^README\.Rmd$
^codecov\.yml$
^appveyor\.yml$
4 changes: 3 additions & 1 deletion DESCRIPTION
Expand Up @@ -15,8 +15,10 @@ Imports:
usethis,
utils
Suggests:
covr,
knitr,
rmarkdown
rmarkdown,
testthat
VignetteBuilder: knitr
Encoding: UTF-8
LazyData: true
Expand Down
14 changes: 13 additions & 1 deletion R/att_to_description.R
Expand Up @@ -16,13 +16,25 @@ att_to_description <- function(path = "NAMESPACE", path.d = "DESCRIPTION",
pkg_name <- desc$get("Package")
suggests <- vg[!vg %in% c(depends, pkg_name)]

suggest_orig <- desc$get("Suggests")
if (dir.exists("tests") | grepl("testthat", suggest_orig)) {
suggests_keep <- "testthat"
} else {
suggests_keep <- NULL
}
if (file.exists("codecov.yml") | grepl("covr", suggest_orig)) {
suggests_keep <- c(suggests_keep, "covr")
} else {
suggests_keep <- NULL
}

desc$del("Imports")
desc$del("Suggests")
desc$write(file = "DESCRIPTION")

# print(paste("Add:", paste(depends, collapse = ", "), "in Depends"))
tmp <- lapply(depends, use_package)
# print(paste("Add:", paste(suggests, collapse = ", "), "in Suggests (from vignettes)"))
tmp <- lapply(suggests, function(x) use_package(x, type = "Suggests"))
tmp <- lapply(c(suggests, suggests_keep), function(x) use_package(x, type = "Suggests"))
use_tidy_description()
}
45 changes: 45 additions & 0 deletions appveyor.yml
@@ -0,0 +1,45 @@
# DO NOT CHANGE the "init" and "install" sections below

# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:
ps: Bootstrap

cache:
- C:\RLibrary

# Adapt as necessary starting from here

build_script:
- travis-tool.sh install_deps

test_script:
- travis-tool.sh run_tests

on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip

artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs

- path: '*.Rcheck\**\*.out'
name: Logs

- path: '*.Rcheck\**\*.fail'
name: Logs

- path: '*.Rcheck\**\*.Rout'
name: Logs

- path: '\*_*.tar.gz'
name: Bits

- path: '\*_*.zip'
name: Bits
12 changes: 12 additions & 0 deletions codecov.yml
@@ -0,0 +1,12 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 1%
10 changes: 8 additions & 2 deletions devstuff_history.R
Expand Up @@ -35,12 +35,18 @@ fill_desc_generic(name = "attachment",
Title = "Deal with dependencies")

usethis::use_pipe()
usethis::use_package("stringr")
usethis::use_package("magrittr")
# usethis::use_package("stringr")
# usethis::use_package("magrittr")
options(usethis.full_name = "Vincent Guyader")
usethis::use_gpl3_license()
usethis::use_tidy_description()
usethis::use_test("attachment")
usethis::use_coverage()
usethis::use_appveyor()

attachment::att_to_description()

usethis::use_vignette("fill-pkg-description")

devtools::build_vignettes()
# devtools::load_all(".")
4 changes: 4 additions & 0 deletions tests/testthat.R
@@ -0,0 +1,4 @@
library(testthat)
library(attachment)

test_check("attachment")
5 changes: 5 additions & 0 deletions tests/testthat/test-attachment.R
@@ -0,0 +1,5 @@
context("test-attachment.R")

test_that("multiplication works", {
expect_equal(2 * 2, 4)
})

0 comments on commit 3c0772d

Please sign in to comment.