Skip to content

Commit

Permalink
Merge pull request #343 from krlmlr/234-skip-summary
Browse files Browse the repository at this point in the history
Summary of skipped tests
  • Loading branch information
hadley committed Feb 18, 2016
2 parents 57c40c7 + 2934284 commit 57dc3ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion R/reporter-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ CheckReporter <- setRefClass("CheckReporter", contains = "Reporter",
)
)

skip_summary <- function(x, label) {
header <- paste0(label, ". ", x$test)

paste0(
colourise(header, "skipped"), " - ", x$failure_msg
)
}

failure_summary <- function(x, label, width = getOption("width")) {
header <- paste0(label, ". ", failure_header(x))
linewidth <- ifelse(nchar(header) > width, 0, width - nchar(header))
Expand All @@ -90,7 +98,10 @@ failure_summary <- function(x, label, width = getOption("width")) {
}

failure_header <- function(x) {
type <- if (x$error) "Error" else "Failure"
if (x$error)
type <- "Error"
else
type <- "Failure"

ref <- x$srcref
if (is.null(ref)) {
Expand Down
10 changes: 10 additions & 0 deletions R/reporter-summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ NULL
SummaryReporter <- setRefClass("SummaryReporter", contains = "Reporter",
fields = list(
"failures" = "list",
"skips" = "list",
"n" = "integer",
"has_tests" = "logical",
"max_reports" = "numeric",
Expand All @@ -45,6 +46,7 @@ SummaryReporter <- setRefClass("SummaryReporter", contains = "Reporter",

start_reporter = function() {
failures <<- list()
skips <<- list()
has_tests <<- FALSE
n <<- 0L
},
Expand All @@ -53,6 +55,8 @@ SummaryReporter <- setRefClass("SummaryReporter", contains = "Reporter",
callSuper(result)
has_tests <<- TRUE
if (result$skipped) {
result$test <- if (is.null(test)) "(unknown)" else test
skips <<- c(skips, list(result))
cat(colourise("S", "skipped"))
return()
}
Expand All @@ -75,6 +79,12 @@ SummaryReporter <- setRefClass("SummaryReporter", contains = "Reporter",
if (n == 0) {
if (!has_tests)
return()

if (length(skips) > 0L) {
cat(colourise("\nSkip:", "skipped"), "\n\n")
cat_reports(skips, skip_summary, "\n")
}

cat("\n")
if (show_praise && runif(1) < 0.1) {
cat(colourise(praise(), "passed"), "\n")
Expand Down

0 comments on commit 57dc3ce

Please sign in to comment.