Closed yutannihilation closed 3 years ago
Thanks to the the power of Twitterverse, a better trick is suggested.
https://twitter.com/hadleywickham/status/1355519666660192259
thanks, having a look
Do we know if Japanese locale is available on the GH Actions Windows builder? https://github.com/ropensci/parzer/pull/32/checks?check_run_id=1797664773
Maybe you can try adding to the gh actions config file to show testthat output
- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
Yes, it's available. Do you mean I should make GHA fail when the locale is unavailable?
Confirmed no test is skipped.
https://github.com/ropensci/parzer/pull/32/checks?check_run_id=1826691377#step:12:394
Okay, great. And I assume this works for you on your machine?
Yes, it works on my Windows, and I also confirmed this fixes the problem of the original reporter of this issue (for reference, here's the conversation (in Japanese): https://twitter.com/niszet0/status/1357863004847497221).
thanks!
Thanks for merging!
Fix #31
This pull request fixes #31 by wrapping functions that call
std::regex
withwithr::with_locale()
.Implementation
First, I investigate which R functions generated by Rcpp use
std::regex
, and found all of them do. So, it's probably better to fix at the very near location of these functions. But, since they are automatically generated, we cannot modifyRcppExports.R
. So, there probably are two choices:pz_parzer_lat_safe()
forpz_parzer_lat()
)While 1. is easy, I'm afraid this is human-error prone (e.g. use the original function without(edit: I got the suggestion to override_safe
mistakenly, forget to add the wrapper when adding a new Rcpp function, etc). So, I chose option 2 in this pull request..Call()
. It seems far better than my tricky implementations, so I switched to it)Testing
The hardest part is how to test this. The problem is, as the nature of this bug, the test case doesn't fail, but hangs forever. So, I think it's safe to call it on an external process, so that we can set timeout.
However, this turned out a bit tricky. To test the function, we need to use
pkgload::load_all()
(ordevtools::load_all()
) to load them on the external process. The problem is, on Windows, this invokes recompilation (I don't know why), which makes the tests fail as it doesn't finish within the specifiedtimeout
. I tweaked to compile it beforehand withpkgbuild::compile_dll()
, but anyway it means we need to compile twice on Windows, so the Windows check is a bit slow (I think this is acceptable).