Closed mrmstn closed 5 years ago
Hey @mrmstn thanks a lot for your report and PR!
What is strange is that I think this happened before and I thought we had a test for that... Look at these commits:
Sorry that this happened once again. Can you add a test on your PR just to be 200% certain this will not happen again (it probably will cause it is very subtle and any refactoring might bring this back)?
Once again, thanks for your report!
@victorolinasc Thank you very much for your response, I should have thought about the tests.
I tried to add some failing tests for the codebase without my fix, but strangly - file writing process died instantly with the following error message ( as soon as there were any unicode chars in the failure message):
** (exit) exited in: GenServer.stop(#PID<0.205.0>, :normal, 30000)
** (EXIT) exited in: :sys.terminate(#PID<0.205.0>, :normal, :infinity)
** (EXIT) an exception was raised:
** (File.Error) could not write to file "<path to project>/junit-formatter/_build/test/lib/junit_formatter/report_file_test.xml": bad argument
(elixir) lib/file.ex:953: File.write!/3
(junit_formatter) lib/formatter.ex:77: JUnitFormatter.handle_cast/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
So I guess as long as we can convert the charlist back to the same string, there shouldn't be a issue with unicodes in the body
The error seems like the file has a wrong name <path to project>/junit-formatter/_build/test/lib/junit_formatter/report_file_test.xml
...
I'll take a look after I merge this.
Thanks once again!
I had a issue with special chars like öäü. As soon as they appeard in a test content, for example as error message, those characters corrupted the junit xml, since were invalid utf8 characters (�)
Here's a example of the xmllint output:
After a little bit of debugging, I've found the issue. String.to_charlist will convert the String to a list of Unicode representivs but the xmerl_lib expects utf8 characters