Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-991

eunit_surefire does not handle invalid XML characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 23
    • Component/s: eunit
    • Labels:
      None

      Description

      eunit_surefire does not handle control characters (code points 0 through 31) when writing XML files.
      The generated XML file will be invalid if, for example, a test case produces output with such characters.
      These characters should probably be stripped or replaced with e.g. $?.

      I have attached mytest.erl and TEST-mytest.xml which show the problem.

      mytest.erl:

      -module(mytest).
      
      -include_lib("eunit/include/eunit.hrl").
      
      main([]) ->
          compile:file("mytest.erl"),
          eunit:test(mytest, [{report,{eunit_surefire,[{dir,"."}]}}]),
          xmerl_scan:file("TEST-mytest.xml").
      
      bad_char_test() ->
          io:format("'~c'~n", [27]).
      

      Running it:

      $ escript mytest.erl 
      mytest.erl:9: Warning: function bad_char_test/0 is unused
      mytest.erl:5: Warning: function main/1 is unused
        Test passed.
      
      =ERROR REPORT==== 1-Jul-2019::14:42:05 ===
      3422- fatal: {error,{wfc_Legal_Character,27}}
      escript: exception exit: {fatal,{{error,{wfc_Legal_Character,27}},
                              {file,"TEST-mytest.xml"},
                              {line,4},
                              {col,19}}}
        in function  xmerl_scan:fatal/2 (xmerl_scan.erl, line 4117)
        in call from xmerl_scan:scan_char_data/5 (xmerl_scan.erl, line 2711)
        in call from xmerl_scan:scan_content/11 (xmerl_scan.erl, line 2623)
        in call from xmerl_scan:scan_element/12 (xmerl_scan.erl, line 2133)
        in call from xmerl_scan:scan_content/11 (xmerl_scan.erl, line 2598)
        in call from xmerl_scan:scan_element/12 (xmerl_scan.erl, line 2133)
        in call from xmerl_scan:scan_content/11 (xmerl_scan.erl, line 2598)
        in call from xmerl_scan:scan_element/12 (xmerl_scan.erl, line 2133)
      

        Attachments

        1. mytest.erl
          0.3 kB
        2. TEST-mytest.xml
          0.3 kB

          Activity

            People

            Assignee:
            hasse Hans Bolinder
            Reporter:
            ampleyfly Simon Johansson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: