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

Add encoding support #518

Closed
wants to merge 3 commits into from

Conversation

hansharhoff
Copy link

This pull request adds support for an encoding argument to test_dir (and the functions called by this). This is related to an issue reported in devtools. A separate pull request is incoming for devtools.

@gaborcsardi
Copy link
Member

Until this is merged, devtools or testthat (choose as like) is broken: it does not handle the filter argument in devtools::test, because it is passed down to grepl, which errors on it.

Can you please consider reviewing it?

@krlmlr
Copy link
Member

krlmlr commented Nov 23, 2016

@gaborcsardi: Did you mean the encoding argument? What exactly is broken until this is merged?

Copy link
Member

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

Thanks. Just a few minor nits, please @-ping Hadley for a second review.

@@ -1,4 +1,5 @@
# testthat 1.0.2.9000
* New argument`encoding` in `test_file()` and `source_file()` (@hansharhoff, devtools#1306)
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to refer to r-lib/devtools#1306?

Copy link
Author

Choose a reason for hiding this comment

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

Yes,
is this better?

(@hansharhoff, hadley/devtools#1306)

}

test_files <- function(paths, reporter = "summary",
test_files <- function(paths, reporter = "summary", encoding = "unknown",
Copy link
Member

Choose a reason for hiding this comment

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

How are the dots ... used in this function?

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure I completely understand. I wanted to keep it as close as possible to the parent.

Copy link
Member

Choose a reason for hiding this comment

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

The dots ... currently are not used by test_files(). They weren't before, but as we're touching the code now, it's better to clean this up.

@@ -98,11 +99,14 @@ find_test_scripts <- function(path, filter = NULL, invert = FALSE, ...) {
#' @param reporter reporter to use
#' @param env environment in which to execute the tests
#' @param load_helpers Source helper files before running the tests?
#' @param encoding the encoding of the files in test directory. Default is
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps shorter: File encoding, default: "unknown"

…ompatability on Windows (see e.g. r-lib/devtools#1306)

Add NEWS.md line about the change.
@hansharhoff
Copy link
Author

I believe I addressed the points of @krlmlr with this commit. If you agree I will ping hadley.

Copy link
Member

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

Thanks. Could you please look at the two open comments?

}

test_files <- function(paths, reporter = "summary",
test_files <- function(paths, reporter = "summary", encoding = "unknown",
Copy link
Member

Choose a reason for hiding this comment

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

The dots ... currently are not used by test_files(). They weren't before, but as we're touching the code now, it's better to clean this up.

Remove ... from call/definition of test_files
@hansharhoff
Copy link
Author

@krlmlr , I have removed the dots and simplified the arguments. I take it those were the open comments.

@@ -98,11 +99,14 @@ find_test_scripts <- function(path, filter = NULL, invert = FALSE, ...) {
#' @param reporter reporter to use
#' @param env environment in which to execute the tests
#' @param load_helpers Source helper files before running the tests?
#' @param encoding File encoding, default is "unknown"
Copy link
Member

Choose a reason for hiding this comment

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

Can you use @inheritParams source_file here?

@krlmlr
Copy link
Member

krlmlr commented Nov 29, 2016

@hadley: PTAL.

stopifnot(file.exists(path))
stopifnot(is.environment(env))

lines <- readLines(path, warn = FALSE)
lines <- readLines(path, warn = FALSE, encoding = encoding)
Copy link
Member

Choose a reason for hiding this comment

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

The encoding argument does not do what you think it does...

@krlmlr krlmlr mentioned this pull request Dec 7, 2016
@hadley hadley closed this in #550 Dec 15, 2016
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.

4 participants