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

Inline test files directly into tests #133

Merged
merged 5 commits into from
Jun 18, 2024
Merged

Inline test files directly into tests #133

merged 5 commits into from
Jun 18, 2024

Conversation

hadley
Copy link
Member

@hadley hadley commented Jun 15, 2024

This makes it much easier to understand what the tests are actually doing.

@hadley hadley requested a review from cderv June 15, 2024 21:09
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

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

Those files seems be from ancient history before testthat where they lived in inst/tests

It seems way easier to maintain now.

Though, I don't know if you noticed, but they are using in examples in several places like this

evaluate/R/replay.R

Lines 8 to 14 in b2a2689

#' @examples
#' samples <- system.file("tests", "testthat", package = "evaluate")
#' if (file_test("-d", samples)) {
#' replay(evaluate(file(file.path(samples, "order.R"))))
#' replay(evaluate(file(file.path(samples, "plot.R"))))
#' replay(evaluate(file(file.path(samples, "data.R"))))
#' }

through the replay function.

So either they should be kept elsewhere, or those examples should be inlined, or even changed.

I think these are the only one used

@@ -26,6 +32,12 @@ test_that("traceback useful if stop_on_error == 2L", {
})

test_that("capture messages in try() (#88)", {
ev <- evaluate(file("try.R"))
# TODO: figure out why this doesn't work interactively
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is not working for this exactly ? Out of curiosity I tried locally and it seemed to work

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea 😬 I'll have to look again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah seems fine now so I'm not sure what the problem was.

tests/testthat/test-graphics.R Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this test is tested anymore. Historically, as the others, all those tests were before testthat structure, and inside inst/tests.

So probably not testing something we still need - I didn't find what interweave was

Copy link
Member Author

Choose a reason for hiding this comment

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

Me neither! Maybe it's the original name of evaluate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file is used in examples:

#' replay(evaluate(file(file.path(samples, "order.R"))))

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks! I'll inline them into the examples too.

@hadley hadley merged commit 61b0c77 into main Jun 18, 2024
11 checks passed
@hadley hadley deleted the inline-tests branch June 18, 2024 15:14
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.

2 participants