-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more test cases for complete coverage and example of stop_on_erro…
…r = 2L behavior - Using evaluate only - In rmarkdown + knitr context
- Loading branch information
Showing
13 changed files
with
128 additions
and
16 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
tests/testthat/_snaps/conditions/stop-error-auto-entrace.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
processing file: with-stop-error-auto-entrace.Rmd | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
1. global f() | ||
2. global g() | ||
3. global h() | ||
|
||
Quitting from lines 10-14 [unnamed-chunk-2] (with-stop-error-auto-entrace.Rmd) | ||
Execution halted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Error in h() : ! | ||
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> f -> g -> h | ||
Execution halted |
23 changes: 23 additions & 0 deletions
23
tests/testthat/_snaps/conditions/stop-error-trace-calling-handler.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
▆ | ||
1. ├─evaluate::evaluate(...) | ||
2. │ ├─base::withRestarts(...) | ||
3. │ │ └─base (local) withRestartList(expr, restarts) | ||
4. │ │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]]) | ||
5. │ │ │ └─base (local) doWithOneRestart(return(expr), restart) | ||
6. │ │ └─base (local) withRestartList(expr, restarts[-nr]) | ||
7. │ │ └─base (local) withOneRestart(expr, restarts[[1L]]) | ||
8. │ │ └─base (local) doWithOneRestart(return(expr), restart) | ||
9. │ ├─evaluate:::with_handlers(...) | ||
10. │ │ ├─base::eval(call) | ||
11. │ │ │ └─base::eval(call) | ||
12. │ │ └─base::withCallingHandlers(...) | ||
13. │ ├─base::withVisible(eval(expr, envir)) | ||
14. │ └─base::eval(expr, envir) | ||
15. │ └─base::eval(expr, envir) | ||
16. └─global f() | ||
17. └─global g() | ||
18. └─global h() | ||
Execution halted |
8 changes: 8 additions & 0 deletions
8
tests/testthat/_snaps/conditions/stop-error-trace-trimmed.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
▆ | ||
1. └─global f() | ||
2. └─global g() | ||
3. └─global h() | ||
Execution halted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Error in `g()`: | ||
! could not find function "g" | ||
Backtrace: | ||
▆ | ||
1. ├─base::withCallingHandlers(...) | ||
2. ├─evaluate::evaluate(...) | ||
3. │ ├─base::withRestarts(...) | ||
4. │ │ └─base (local) withRestartList(expr, restarts) | ||
5. │ │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]]) | ||
6. │ │ │ └─base (local) doWithOneRestart(return(expr), restart) | ||
7. │ │ └─base (local) withRestartList(expr, restarts[-nr]) | ||
8. │ │ └─base (local) withOneRestart(expr, restarts[[1L]]) | ||
9. │ │ └─base (local) doWithOneRestart(return(expr), restart) | ||
10. │ ├─evaluate:::with_handlers(...) | ||
11. │ │ ├─base::eval(call) | ||
12. │ │ │ └─base::eval(call) | ||
13. │ │ └─base::withCallingHandlers(...) | ||
14. │ ├─base::withVisible(eval(expr, envir)) | ||
15. │ └─base::eval(expr, envir) | ||
16. │ └─base::eval(expr, envir) | ||
17. └─global f() | ||
Execution halted |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() rlang::abort("!") | ||
f() | ||
}, stop_on_error = 2L) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
handlers <- evaluate::new_output_handler( | ||
calling_handlers = list(error = function(cnd) rlang::entrace(cnd)) | ||
) | ||
options(rlang_trace_top_env = parent.frame()) | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L, output_handler = handlers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
handlers <- evaluate::new_output_handler( | ||
calling_handlers = list(error = function(cnd) rlang::entrace(cnd)) | ||
) | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L, output_handler = handlers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
withCallingHandlers( | ||
error = function(cnd) rlang::entrace(cnd), | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters