Closed jayhendren closed 4 years ago
Sounds to me like serverspec is interfering with encodings? Can you reproduce in plain rspec?
I wouldn't be surprised if ServerSpec is doing something funky. However, considering that the bug appeared when changing nothing except upgrading rspec_junit_formatter from 0.3.0 to 0.4.0 and that rspec_junit_formatter is the only thing besides rspec in the stack trace, this smells like an issue with rspec_junit_formatter to me.
I'm working on reproducing without ServerSpec. I'm having a bit of trouble but I feel like I'm getting close.
Ok, so I'm starting to get this one figured out. There's a few different puzzle pieces here. It's still not clear to me exactly where the issue lies, though I'm starting to suspect Serverspec is doing something wrong.
First, starting in version 0.4.0, rspec_junit_formatter starting processing :stdout
and :stderr
in example metadata. This is why I'm only seeing the issue with versions >= 0.4.0.
Second, Serverspec always saves stdout to example metadata (this does not appear to be configurable behavior in Serverspec, otherwise I would simply disable it and close this issue and move on).
Finally, Serverspec uses a very low-level way to read command output involving reading from pipes 4096 bytes at a time using IO.select
and looping over IO#read_nonblock(4096)
. As far as I can tell, this often results in an output string (incorrectly?) labeled with ASCII-8BIT
encoding. If I override this method to use something a bit more abstract, like IO.read()
, then the output usually is UTF-8
encoding and I don't have any encoding issues.
I'm not really sure where the ASCII-8BIT
encoding is ultimately coming from. That's what I'm looking into right now.
There are a couple things I wish existed that would allow for workarounds:
@Poohblah did you find anything? I seem to have the same issue.
I just pinned to version 0.3.x of this gem and moved on.
IIRC, I considered opening a PR against Serverspec, but that was a lot more work than just pinning one gem version. I barely use the junit output at all, so it simply wasn't worth my time investment.
Thank you for the update. That is what I ended up doing as well. So I guess this issue can be closed.
Sorry folks, encodings are hard!
Looks like #57 was fixed in 0.3.0, but regressed in 0.4.0.
The following code generates the following error in versions >= 0.4.0, but not 0.3.0. So far I have only been able to reproduce the error when using Serverspec; I haven't yet figured out how to reproduce in plain RSpec.
There are no errors if I remove the
ø
character: