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

fix test-list.R for Windows systems #199

Merged
merged 39 commits into from
Apr 25, 2018

Conversation

Hugovdberg
Copy link
Collaborator

A fix for issue #197, the custom filename generator didn't handle the different file path separator on Windows correctly.

Hugovdberg and others added 30 commits December 30, 2016 15:09
… with clear(), testing for cache ignored

Added data_ignore to project.config
@Hugovdberg
Copy link
Collaborator Author

hmm, how do I prevent all those old commits from showing up? Apparently github doesn't notice all those old commits were squashed into the latest merge.. I literally is just one line changed.

@connectedblue
Copy link
Contributor

connectedblue commented May 14, 2017

@Hugovdberg the way I do it is to keep my master an exact copy of this one. Then you create a new branch from master for each feature/bug you want to fix. You then raise a PR from that branch.

@connectedblue
Copy link
Contributor

Hi @Hugovdberg

This fix didn't work unfortunately. I installed off your branch:

devtools::install_github("Hugovdberg/ProjectTemplate@197_fix_test-list")

and I got the same test failures as reported in #197

@Hugovdberg
Copy link
Collaborator Author

I cannot reproduce the errors with the following code:

devtools::install_github("Hugovdberg/ProjectTemplate@197_fix_test-list")
testthat::test_package("ProjectTemplate")

How do you reproduce the errors? I tested it both on windows 7 and windows 10, I only get an error related to missing Perl for the xls.reader. Also, we should fix the test for migration to suppress the warning related to changes in the csv2.reader.

@connectedblue
Copy link
Contributor

connectedblue commented May 15, 2017

Hi @Hugovdberg

I tried your command and got the same 15 failures.

I was running the tests using

source('C:/Users/cs/git/ProjectTemplate2/tests/run-all.R')

and got the same errors.

Here's a snippet:

x[3]: "test/file2ef8665d74d4.csv"
y[3]: "test\\file2ef8665d74d4.csv"

I think there's possibly a difference in how we define the file separator in the environment perhaps? Mine always comes up as \\ for reasons I dont fully understand `

@Hugovdberg
Copy link
Collaborator Author

That's the reason I replace \\ with /. All comparisons are done with the output of list.data first, so the reported y-value is what's created by temp_csv_file inside test-list.R. Apparently not all occurrences of \\ are replaced from the output of tempfile (which confusingly reports a different file separator than list.files). Could you please source the temp_csv_file function and run it to see if any \\ remain?

@connectedblue
Copy link
Contributor

connectedblue commented May 18, 2017

I ran the following:

> temp_csv_file <- function(dir = '') {
+   gsub('^/', '', tempfile(pattern = "file", tmpdir = dir, fileext = ".csv"))
+ }
> temp_csv_file()
[1] "\\file2ef820131766.csv"
> temp_csv_file(dir = 'test')
[1] "test\\file2ef839073b0e.csv"
> 

what's the result supposed to be? should it just be file2ef820131766.csv and test/file2ef839073b0e.csv?

I don't really understand why a tempfile name is being created if the data file is being created inside a project. Can't the test dataframe just be written to files data/test1.csv and data/test2.csv?

@Hugovdberg
Copy link
Collaborator Author

Given the definition of temp_csv_file you show there you did not check out my the branch. See test-list.R in the referenced branch. Could you please make sure you checked out the correct branch or copy the definition from github manually for the test first?

@connectedblue
Copy link
Contributor

connectedblue commented May 18, 2017

ok, I did install your branch directly off github but didn't check it out, so sourcing the files wouldn't have worked.

The tests run fine now.

Is there a particular reason why you selected this strategy for naming a test file? It might be worth placing a comment inside the temp_csv_file function to explain what the nested gsub's and backslashes are doing. Could help future ProjectTemplate maintainers.

@Hugovdberg
Copy link
Collaborator Author

I'm actually not quite sure why I made that decision, because the most feasible argument I can come up with (not hardcoding the correctness of the test) isn't too strong. I did add the explanatory comments as requested.

@KentonWhite
Copy link
Owner

Cleaning up PRs now that new version is on CRAN.

@KentonWhite KentonWhite reopened this Apr 25, 2018
@KentonWhite KentonWhite merged commit 1ea617a into KentonWhite:master Apr 25, 2018
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