Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGZILLA #17695] stopifnot example does not run all the way through #6869

Open
MichaelChirico opened this issue May 19, 2020 · 2 comments
Open

Comments

@MichaelChirico
Copy link
Owner

While trying to implement #17688, I noticed that example(stopifnot) does not run to completion - it stops after the first example of stopping. There are more examples after that which don't get run (and the handler is overridden), so this might be unintentional?


METADATA

  • Bug author - Neal Fultz
  • Creation time - 2020-01-20 18:51:21 UTC
  • Bugzilla link
  • Status - ASSIGNED
  • Alias - None
  • Component - Documentation
  • Version - R 3.6.xx
  • Hardware - Other Linux
  • Importance - P5 minor
  • Assignee - R-core
  • URL -
  • Modification time - 2020-01-30 10:55 UTC
@MichaelChirico
Copy link
Owner Author

Yes, the interactive

example(stopifnot)

stops early.

OTOH, in R's make check-devel it runs completely through as desired.

Also, if the examples are run by line, interactively (most efficiently in ESS),
it works fine too.
It also works if you send the whole examples "region" to R (again, in ESS), or I'm sure if you cut'n'paste the whole example section into a standard R console.
("standard" not being RStudio; I did not try there).

Yes, this is "unadvertent" in the sense that this was not planned;
OTOH, in order for these to work (notably in R's automated checks, see above), it is necessary to disable the handler

   op <- options(error = expression(NULL))
  &num; "disabling stop(.)"  << Use with CARE! >>

and the comment does warn.

If somebody can think of a smart trick to also have this work with example(stopifnot) I'd be grateful and probably gladly use that (or tell the user in a comment on how to use it.

It's tricky: example() call source(*, echo=TRUE) and source() does quite a bit of fiddling in the 'echo=TRUE' case including using tryCatch(...).
So that is "the explanation" mostly.

I'm setting this to 'ASSIGNED' now, but will probably not spend time trying to solve it. In a year or so, either somebody will have provided a trick / patch for this, or I will add a comment at the beginning of the 'examples' section that they only run through in BATCH mode or fully interactively, but not when run via example().

Thank you for the notice!


METADATA

  • Comment author - Martin Maechler
  • Timestamp - 2020-01-24 22:22:45 UTC

@MichaelChirico
Copy link
Owner Author

(In reply to Martin Maechler from comment #1)

One more thought: To "fix" this I think means to improve the example() function,
and do that most probably by making source() more flexible: possibly by adding yet another (optional, probably logical) argument to source() which when set to TRUE would do the error handling slightly differently within source().


METADATA

  • Comment author - Martin Maechler
  • Timestamp - 2020-01-30 10:55:42 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant