Skip to content

Commit 96489ce

Browse files
committed
Enabling srcref argument in reporter$start_test
1 parent c45ce93 commit 96489ce

14 files changed

+25
-18
lines changed

R/parallel.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ SubprocessReporter <- R6::R6Class(
377377
private$filename <- filename
378378
private$event("start_file", filename)
379379
},
380-
start_test = function(context, test) {
380+
start_test = function(context, test, srcref=NULL) {
381381
private$context <- context
382382
private$test <- test
383-
private$event("start_test", context, test)
383+
private$event("start_test", context, test, srcref)
384384
},
385385
start_context = function(context) {
386386
private$context <- context

R/reporter-junit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ JunitReporter <- R6::R6Class(
6969
self$file_name <- file
7070
},
7171

72-
start_test = function(context, test) {
72+
start_test = function(context, test, srcref=NULL) {
7373
if (is.null(context)) {
7474
context_start_file(self$file_name)
7575
}

R/reporter-list.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ListReporter <- R6::R6Class(
2424
self$results <- Stack$new()
2525
},
2626

27-
start_test = function(context, test) {
27+
start_test = function(context, test, srcref=NULL) {
2828
if (
2929
!identical(self$current_context, context) ||
3030
!identical(self$current_test, test)

R/reporter-location.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ LocationReporter <- R6::R6Class(
1010
"LocationReporter",
1111
inherit = Reporter,
1212
public = list(
13-
start_test = function(context, test) {
14-
self$cat_line("Start test: ", test)
13+
start_test = function(context, test, srcref=NULL) {
14+
if (!is.null(srcref)) {
15+
filename <- attr(srcref, "srcfile")$filename
16+
line_number <- as.integer(srcref[[1]])
17+
self$cat_line("Start test: '", test, "' at ", filename, ":", line_number)
18+
} else {
19+
self$cat_line("Start test: ", test)
20+
}
1521
},
1622

1723
add_result = function(context, test, result) {

R/reporter-multi.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ MultiReporter <- R6::R6Class(
2626
start_context = function(context) {
2727
o_apply(self$reporters, "start_context", context)
2828
},
29-
start_test = function(context, test) {
30-
o_apply(self$reporters, "start_test", context, test)
29+
start_test = function(context, test, srcref=NULL) {
30+
o_apply(self$reporters, "start_test", context, test, srcref)
3131
},
3232
add_result = function(context, test, result) {
3333
o_apply(

R/reporter-slow.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ SlowReporter <- R6::R6Class(
3838
self$current_file <- file
3939
},
4040

41-
start_test = function(context, test) {
41+
start_test = function(context, test, srcref=NULL) {
4242
self$current_test_start <- proc.time()[[3]]
4343
},
4444

R/reporter-stop.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ StopReporter <- R6::R6Class(
3131
self$stop_reporter <- stop_reporter
3232
},
3333

34-
start_test = function(context, test) {
34+
start_test = function(context, test, srcref=NULL) {
3535
self$issues <- Stack$new()
3636
},
3737

R/reporter-teamcity.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TeamcityReporter <- R6::R6Class(
2727
self$cat_line()
2828
},
2929

30-
start_test = function(context, test) {
30+
start_test = function(context, test, srcref=NULL) {
3131
private$report_event("testSuiteStarted", test)
3232
self$i <- 1L
3333
},

R/reporter-timing.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SlowReporter <- R6::R6Class(
3131
self$current_file <- file
3232
},
3333

34-
start_test = function(context, test) {
34+
start_test = function(context, test, srcref=NULL) {
3535
self$current_test_start <- proc.time()[[3]]
3636
},
3737

R/reporter.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Reporter <- R6::R6Class(
2929
capabilities = list(parallel_support = FALSE, parallel_updates = FALSE),
3030
start_reporter = function() {},
3131
start_context = function(context) {},
32-
start_test = function(context, test) {},
32+
start_test = function(context, test, srcref=NULL) {},
3333
start_file = function(filename) {},
3434
add_result = function(context, test, result) {},
3535
end_test = function(context, test) {},

0 commit comments

Comments
 (0)