Skip to content

Conversation

@jennybc
Copy link
Member

@jennybc jennybc commented Mar 31, 2020

Related to the "Can we remove is_testing() too?" comment in #1084 (review)

This removes is_testing() and does a general tidy up around nested projects.

}

# creates a backdoor we can exploit in tests
allow_nested_project <- function() FALSE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new way we give ourselves of method of creating a nested project in tests. More self-explaining than previous reliance on is_testing() plus a magic string in the project name.


## putting `pattern` in the package or project name is part of our strategy for
## suspending the nested project check during testing
pattern <- "aaa"
Copy link
Member Author

@jennybc jennybc Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure why I ever made the magic string part of the default project name.

Probably because I was very frustrated with problems around nested projects and testing? If this ever happens to you @hadley (catastrophic test failure related to nested projects), remember we have some code elsewhere in this helper.R file that can be run to figure out why session temp dir suddenly looks like a project (usually because it somehow holds one or more .Rproj files). Then we can delete the offending file(s). This is something RStudio does in the background every now and then and I've never been able to figure out why.

child <- create_project(path(parent, "fghijk"))
)
expect_true(possibly_in_proj(child))
expect_false(is_package(child))
Copy link
Member Author

@jennybc jennybc Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until now, we had never actually intentionally created a nested package or project in the tests 🤷‍♀️

on.exit({
setwd(oldwd)
dir_delete(newdir)
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated cleanup.

@jennybc jennybc requested a review from hadley March 31, 2020 23:35
@jennybc
Copy link
Member Author

jennybc commented Mar 31, 2020

Not in this PR and already in master, we now give a more actionable error message when a user encounters friction due to a nested project (eb82346).

parent <- scoped_temporary_package()
with_mock(
# since user can't approve interactively, use the backdoor
`usethis:::allow_nested_project` = function() TRUE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be allow_nested_project = ...?

@jennybc jennybc merged commit d1d28c9 into master Apr 1, 2020
@jennybc jennybc deleted the delete-is-testing branch April 1, 2020 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants