Skip to content

Encoding of the output file #78

Closed
Closed
@felipebz

Description

@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:

create or replace package test_failure is
  -- %suite
  
  -- %test
  procedure should_fail;
end test_failure;
/
create or replace package body test_failure is
  procedure should_fail is
  begin
    ut.fail('Acentuação');
  end;
end test_failure;
/

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:

<testExecutions version="1">
<file path="test_failure">
<testCase name="should_fail" duration="6" >
<failure message="some expectations have failed">
<![CDATA[
Acentuação
]]>
</failure>
</testCase>
</file>
</testExecutions>

Running a SonarQube analysis with -Dsonar.testExecutionReportPaths=tests.xml causes the exception:

ERROR: Error during SonarQube Scanner execution
Error during parsing of generic test execution report '<path>\tests.xml'. Look at the SonarQube documentation to know the expected XML format.
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 middle byte 0xe3 (at char #172, byte #-1)

Converting the file to UTF-8 ou adding a <?xml version="1.0" encoding="windows-1252"?> fixes the problem.

Some info about the environment:

  • utPLSQL-cli v3.1.0 is running on Windows 10, language pt-BR
  • utPLSQL v3.0.4.1372 on Oracle 11.2.0.4.0 (on Linux, but I think it doesn't matter)
  • NLS_CHARACTERSET is defined as WE8ISO8859P1

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. ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions