-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
TealAppDriver skips tests when shinytest2 or rvest are not installed #1432
Open
averissimo
wants to merge
7
commits into
main
Choose a base branch
from
518-pkgs_imports@main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+9
−6
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8541273
feat: TealAppDriver skips tests when shinytest2 or rvest are not inst…
averissimo 8bcaa47
Merge branch 'main' into 518-pkgs_imports@main
averissimo 669420e
Merge branch 'main' into 518-pkgs_imports@main
averissimo 21bc010
feat: also check that testthat is installed
averissimo 0b6af0d
Merge branch 'main' into 518-pkgs_imports@main
averissimo d02aab8
Merge branch 'main' into 518-pkgs_imports@main
averissimo 72cc3d8
Merge branch 'main' into 518-pkgs_imports@main
averissimo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about inverting the order of the if else clause, so if there is no testthat and it is not in use the TealAppDriver class won't check for the suggested package used for testing (this uses && shortcut) .
Here is my suggestion (indentation would need to change accordingly):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I misunderstanding or would we still need an
else if
after for the currentelse
clause with your suggestion?I dislike the repetition of the suggestion, maybe a tiny bit more than the nested if clause
Given it's a personal style, if you feel the suggestion is better I'll make the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we could remove the
else
from the current code to make it a bit leanerSecond note: for a moment I considered the following, but the
tryCatch
would be too broad and from all the options I dislike this the mostThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking this code will be executed mostly by developers checking & testing the package, so that should be checked first as it can lead to speed improvements and code readability. I think t
I would expect developers to know they need to install a package if it cannot be loaded and a message reported this.
What do you think about this simplification?
The
identical(Sys.getenv("RTESTS"), "true")
is to ensure that when one does devtools::check it is triggered (but can be omitted).I tested several snippets but I'm not happy with any regarding readability, perhaps it would be easier if we had a little helper/uril function to solve this that we can reuse across packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some needed context that I forgot to add to the original post. This chunk of code serves dual-purposes:
{teal}
if the developer uses the class manually, but didn't install the *OPTIONAL* dependencies{tmc}
,{tmg}
, and other (possibly), asTealAppDriver
depends on{teal}
Suggested packages to work, but cannot be added toDESCRIPTION
to{tmc}
,{tmg}
,{...}
That's why we need
skip
andstop
conditions. To be complete, I've also addedtestthat
to that small list.This suggestion will allow the creation of the class if we don't have
{testthat}
installed. Almost an impossibility, but it could happen.