-
Notifications
You must be signed in to change notification settings - Fork 15
Encoding of the output file #78
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
Comments
Thanks for reporting this issue. |
Hi @jgebal. I've made some tests and I think it's reasonably safe to assume that Oracle driver will handle the database encoding correctly in all situations, when orai18n.jar is on CLASSPATH (for compatibility with all charsets). The Java String class documentation states that "A String represents a string in the UTF-16 format (...)". Therefore we could say that, regardless the environment, a Java string is not affected by the database encoding and we could use any encoding to write it to a file stream. Using UTF-8 to write the files seems to be a safe option to me. I've sent the PR #79 with this change. :-) |
Thanks for the PR. I don't like including this as hard change because it might break someone else's current chain. I can imagine introducing a new command-line parameter to control the charset or using environment variables. |
Yes, I understand. A reporter parameter would be better then. Something like |
Yes. Maybe also support the charset part of LC_ALL environment variable. @jgebal what's your opinion on that? |
It would be best if we can make it work for everyone without exposing additional complexity to the users. Sonar expects utf-8 encoding if no encoding is specified in xml
With option 3 I would still prefer it only to be needed in "specific cases". If option 1 would actually work it might make sense to use it. |
Yes, you are right. We should first of all write the used encoding to the output header. |
@felipebz, @pesse I think it would make sense to keep |
I tried a lot of things, but I guess I'll have to set up a database with this specific characterset configuration so I can get a feeling where in the chain the problem occurs. |
@jgebal What do you think about the following approach: |
Oh, I keep forgetting that. If we go with cli/api-only change, how will you know which reporter's outputs need to be modified (without hardcoding it) ? |
One idea: if output-file ends with *.xml output will start with the following line:
We can even go that far to check whether output already starts with an XML-Tag and only add it if necessary.
|
Nice.
|
How do you check content is xml? I wouldn't want to wait until thw whole file is created, that would be a possible memory-problem.
We might get a problem if content starts with a comment, though. HTML is a bit more problematic because charset information is not in the first line as is with XML but in the |
And how much effort it is to add new parameter ro ur_runner.run while keeping api backward compatible? |
I already introduced Compatibility-Layers, so it should be not a big problem. You prefer doing the logic inside the reporters themselves? It would be much clearer, yes. |
Yes, after thinking about it we should work on the reporters to give valid output instead of injecting it in a post-processing step. |
Lovely! So we have a plan :) |
I think utPLSQL/utPLSQL#676 (comment) will solve this issue. |
@felipebz Can you verify it's working with develop-branch of utPLSQL framework and latest develop-binary of cli? (https://bintray.com/utplsql/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-201806130715.zip) |
Hi @pesse. It works. 👍 For the sake of completeness: ut.version = v3.1.2.2016-develop
|
Great! Thanks for confirming, @felipebz! |
Hi!
We're starting to use utPLSQL-cli to export the test execution reports for SonarQube, but we've found a bug when the output is saved to file and the output contains "special" characters.
Since utPLSQL itself doesn't specify an XML declaration in the XML output, SonarQube expects a UTF-8 file but the file written by utPLSQL-cli is using the default encoding (from the environment).
A simple test case:
I'm generating the report using:
utplsql run <db info> -p=test_failure -f=ut_sonar_test_reporter -o=tests.xml
The output, as expected, is a file with this content:
Running a SonarQube analysis with
-Dsonar.testExecutionReportPaths=tests.xml
causes the exception:Converting the file to UTF-8 ou adding a
<?xml version="1.0" encoding="windows-1252"?>
fixes the problem.Some info about the environment:
I'm not sure if this should be reported here (to generate the file using the UTF-8 encoding) or this should be handled in the utPLSQL project (including an XML declaration in the output). I could send a PR for this, but I wanted to make sure that you are aware of it first. ;-)
The text was updated successfully, but these errors were encountered: