Skip to content

Commit ac1406c

Browse files
committed
Deal w/ failing test on rhub and winbuilder
1 parent 2d5000b commit ac1406c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/testthat/helper.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ skip_if_not_ci <- function() {
5151
skip("Not on Travis or Appveyor")
5252
}
5353

54+
skip_if_no_git_config <- function() {
55+
cfg <- git2r::config()
56+
user_name <- cfg$local$`user.name` %||% cfg$global$`user.name`
57+
user_email <- cfg$local$`user.email` %||% cfg$global$`user.email`
58+
user_name_exists <- !is.null(user_name)
59+
user_email_exists <- !is.null(user_email)
60+
if (user_name_exists && user_email_exists) {
61+
return(invisible(TRUE))
62+
}
63+
skip("No Git user configured")
64+
}
65+
5466
expect_error_free <- function(...) {
5567
expect_error(..., regexp = NA)
5668
}

tests/testthat/test-use-readme.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ test_that("error if try to overwrite existing file", {
1111
test_that("sets up git pre-commit hook iff pkg uses git", {
1212
# git2r::git2r::discover_repository() not working on R 3.1 (Travis)
1313
skip_if(getRversion() < 3.2)
14+
skip_if_no_git_config()
15+
1416
scoped_temporary_package()
1517
capture_output(use_readme_rmd(open = FALSE))
1618
expect_false(file.exists(proj_path(".git", "hooks", "pre-commit")))

0 commit comments

Comments
 (0)