Closed MarcinKosinski closed 5 years ago
@pdrhlik also add dplyr
to Suggests in DESCRIPTION
It works when using devtools::test()
but not using devtools::check()
. That's because I'm relying on the raw swear word lists that are stored in data-raw/swear-word-lists right now. Probably because it's a non-standard directory, it's not copied to the assumed placed.
So the real problem with this test failing is the difference between testing the source/installation. We have the folder data-raw/swear-word-lists that contains all the currently completed language files.
If we use devtools::check()
, this folder isn't installed. So when the tests are run, there are actually no files to be tested. It works just fine when doing devtools::test()
because the folder can be accessed.
There are to possible solutions to this.
First: Don't run these tests on an installed package at all. We probably don't need to have the raw files present there. That means that these tests are only for local testing when creating/editing language files. We already have all the data in an exported data frame.
Second: Move the folder to inst/
so that it can be accessed in an installed package. I tried that, it works. The only thing is that we have to check the folder in which the word lists are. It will be either swear-word-lists/
or inst/swear-word-lists/
.
I would personally prefer the first solution. It will make our package even smaller and probably makes more sense. What do you think, @MarcinKosinski?
I had similar problem with my package and the solution was to add sample file to the test folder (not very elegant, but worked)
@mczyzj @pdrhlik if we only test that locally let's have those tests in a directory that is then listed in the .Rbuildignore
. So the 3rd option is to move test for the data-raw
to data-raw
and then to extend .Rbuildignore
with data-raw
.
I'll try Marcin's suggestion. That's probably the best option.
The local tests should be run using testthat::test_dir("data-raw/tests-local/")
. I'll close this for now. We'll see in the future if this approach is sustainable.
@pdrhlik I think this is related to that line in tests https://github.com/pdrhlik/sweary/blob/master/tests/testthat/helper_file_names.R#L2