Skip to content

Commit

Permalink
edit call stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Müller committed Mar 3, 2016
1 parent 4289a53 commit 724d192
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 42 deletions.
7 changes: 5 additions & 2 deletions R/reporter-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ CacheReporter <- R6::R6Class(
"CacheReporter", inherit = Reporter,

public = list(
initialize = function(reporter = get_reporter()) {
initialize = function(reporter = get_reporter(), select_from_call = -1:-7) {
private$.args <- Stack$new()
private$.reporter <- reporter
private$.select_from_call <- select_from_call
},

add_result = function(context, test, result) {
result$call <- result$call[private$.select_from_call]
private$.args$push(list(context = context, test = test, result = result))
},

Expand All @@ -30,6 +32,7 @@ CacheReporter <- R6::R6Class(

private = list(
.args = NULL,
.reporter = NULL
.reporter = NULL,
.select_from_call = NULL
)
)
17 changes: 4 additions & 13 deletions tests/testthat/reporters/check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,10 @@ stop

6. Error: Error:3 (@tests.R#36) ------------------------------------------------
!
1: expect_message(f(), NA) at reporters/tests.R:36
2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145
3: with_reporter("cache", result <- with_sink(temp, withCallingHandlers(withVisible(code),
warning = handle_warning, message = handle_message))) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56
4: force(code) at /home/muelleki/git/R/testthat/R/reporter-zzz.R:53
5: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning,
message = handle_message))
6: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:90
7: withVisible(code)
8: f()
9: g() at reporters/tests.R:32
10: h() at reporters/tests.R:33
11: stop("!") at reporters/tests.R:34
1: f()
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34

testthat results ================================================================
OK: 5 SKIPPED: 2 FAILED: 6
Expand Down
17 changes: 4 additions & 13 deletions tests/testthat/reporters/summary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,9 @@ stop

6. Error: Error:3 (@tests.R#36) ------------------------------------------------
!
1: expect_message(f(), NA) at reporters/tests.R:36
2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145
3: with_reporter("cache", result <- with_sink(temp, withCallingHandlers(withVisible(code),
warning = handle_warning, message = handle_message))) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56
4: force(code) at /home/muelleki/git/R/testthat/R/reporter-zzz.R:53
5: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning,
message = handle_message))
6: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:90
7: withVisible(code)
8: f()
9: g() at reporters/tests.R:32
10: h() at reporters/tests.R:33
11: stop("!") at reporters/tests.R:34
1: f()
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34

DONE =======================================================================
17 changes: 4 additions & 13 deletions tests/testthat/reporters/tap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,10 @@ not ok 7 Error:1
1: stop("stop") at reporters/tests.R:28
not ok 8 Error:3
!
1: expect_message(f(), NA) at reporters/tests.R:36
2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145
3: with_reporter("cache", result <- with_sink(temp, withCallingHandlers(withVisible(code),
warning = handle_warning, message = handle_message))) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56
4: force(code) at /home/muelleki/git/R/testthat/R/reporter-zzz.R:53
5: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning,
message = handle_message))
6: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:90
7: withVisible(code)
8: f()
9: g() at reporters/tests.R:32
10: h() at reporters/tests.R:33
11: stop("!") at reporters/tests.R:34
1: f()
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34
# Context Skips
ok 9 # SKIP skip
ok 10 # SKIP skip
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/reporters/teamcity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

##teamcity[testSuiteStarted name='Error:3']
##teamcity[testStarted name='expectation 1']
##teamcity[testFailed name='expectation 1' message='!' details='1: expect_message(f(), NA) at reporters/tests.R:36|n2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145|n3: with_reporter("cache", result <- with_sink(temp, withCallingHandlers(withVisible(code), |n warning = handle_warning, message = handle_message))) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56|n4: force(code) at /home/muelleki/git/R/testthat/R/reporter-zzz.R:53|n5: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning, |n message = handle_message))|n6: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:90|n7: withVisible(code)|n8: f()|n9: g() at reporters/tests.R:32|n10: h() at reporters/tests.R:33|n11: stop("!") at reporters/tests.R:34']
##teamcity[testFailed name='expectation 1' message='!' details='1: f()|n2: g() at reporters/tests.R:32|n3: h() at reporters/tests.R:33|n4: stop("!") at reporters/tests.R:34']
##teamcity[testFinished name='expectation 1']
##teamcity[testSuiteFinished name='Error:3']

Expand Down

0 comments on commit 724d192

Please sign in to comment.