File 3327-Test-suite-cuddling.patch of Package erlang

From 8ea44cddb60d58b5970de6d54e10cc6ca4dc24e6 Mon Sep 17 00:00:00 2001
From: Lars Thorsen <lars@erlang.org>
Date: Wed, 10 Jun 2020 13:27:35 +0200
Subject: [PATCH] Test suite cuddling

  Remove compile warnings for test suites
  Fix problem when running tests under windows
---
 lib/xmerl/test/xmerl_SUITE.erl            | 65 ++++++++++++-----------
 lib/xmerl/test/xmerl_sax_std_SUITE.erl    |  4 +-
 lib/xmerl/test/xmerl_sax_stream_SUITE.erl |  2 +-
 3 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/lib/xmerl/test/xmerl_SUITE.erl b/lib/xmerl/test/xmerl_SUITE.erl
index 66f04f6c25..bc133558d6 100644
--- a/lib/xmerl/test/xmerl_SUITE.erl
+++ b/lib/xmerl/test/xmerl_SUITE.erl
@@ -1,7 +1,7 @@
 %%
 %% %CopyrightBegin%
 %%
-%% Copyright Ericsson AB 2008-2017. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2020. All Rights Reserved.
 %%
 %% Licensed under the Apache License, Version 2.0 (the "License");
 %% you may not use this file except in compliance with the License.
@@ -241,7 +241,7 @@ default_attrs_bug(Config) ->
     ok.
 
 
-xml_ns(Config) ->
+xml_ns(_Config) ->
     Doc = "<?xml version='1.0'?>\n"
         "<doc xml:attr1=\"implicit xml ns\"/>",
     {#xmlElement{namespace=#xmlNamespace{default = [], nodes = []},
@@ -326,8 +326,9 @@ sax_parse_export_xml_big(Config) ->
     {ok,IO} = file:open(OutFile,[write,append]),
     ok = file:write(IO,Bin),
     ok = io:format(IO,"~s~n~n",[lists:flatten(Ex)]),
-    Cmd = lists:flatten(io_lib:format("cmp ~s ~s",[OutFile,CMOMxml])),
-    [] = os:cmd(Cmd),
+    ok = file:close(IO),
+    {ok,CmpBin1} = file:read_file(OutFile),
+    {ok,CmpBin1} = file:read_file(CMOMxml),
     ok.
 
 sax_parse_export_xml_small(Config) ->
@@ -342,11 +343,11 @@ sax_parse_export_xml_small(Config) ->
     {ok,IO} = file:open(OutFile,[write,append]),
     ok = file:write(IO,Bin),
     ok = io:format(IO,"~s~n",[lists:flatten(Ex)]),
-    Cmd = lists:flatten(io_lib:format("cmp ~s ~s",[OutFile,Wurfl_xml])),
-    [] = os:cmd(Cmd),
+    ok = file:close(IO),
+    {ok,CmpBin1} = file:read_file(OutFile),
+    {ok,CmpBin1} = file:read_file(Wurfl_xml),
     ok.
 
-
 simple() ->
     [{document, 
       [{title, "Doc Title"}, {author, "Ulf Wiger"}],
@@ -450,24 +451,26 @@ ticket_5998(Config) ->
     DataDir = datadir(Config),
     %% First fix is tested by case syntax_bug2.
     
-    case catch xmerl_scan:file(filename:join([DataDir,misc,"ticket_5998_2.xml"])) of
-        {'EXIT',{fatal,Reason1}} ->
-            case Reason1 of
-                {{endtag_does_not_match,
-                  {was,obj,should_have_been,int}},
-                 _,_,_} -> ok;
-                _ -> {comment,"parsing changed behaviour"}
-            end
-    end,
-
-    case catch xmerl_scan:file(filename:join([DataDir,misc,"ticket_5998_3.xml"])) of
-        {'EXIT',{fatal,Reason2}} ->
-            case Reason2 of
-                {"expected one of: ?>, standalone, encoding",
-                 _,_,_} -> ok;
-                _ -> {comment,"parsing changed behaviour"}
-            end
-    end.
+    ok =
+        case catch xmerl_scan:file(filename:join([DataDir,misc,"ticket_5998_2.xml"])) of
+            {'EXIT',{fatal,Reason1}} ->
+                case Reason1 of
+                    {{endtag_does_not_match,
+                      {was,obj,should_have_been,int}},
+                     _,_,_} -> ok;
+                    _ -> {comment,"parsing changed behaviour"}
+                end
+        end,
+
+    ok =
+        case catch xmerl_scan:file(filename:join([DataDir,misc,"ticket_5998_3.xml"])) of
+            {'EXIT',{fatal,Reason2}} ->
+                case Reason2 of
+                    {"expected one of: ?>, standalone, encoding",
+                     _,_,_} -> ok;
+                    _ -> {comment,"parsing changed behaviour"}
+                end
+        end.
 
 
 %%
@@ -528,8 +531,8 @@ ticket_7214(Config) ->
 %% Problem with contents of numeric character references followed by 
 %% UTF-8 characters..
 %%
-ticket_7430(Config) ->
-    DataDir = datadir(Config),
+ticket_7430(_Config) ->
+    %%DataDir = datadir(Config),
 
     {E,[]} = xmerl_scan:string("<a>\303\251&#xD;\303\251</a>",[{encoding,'utf-8'}]),
 
@@ -553,7 +556,7 @@ ticket_7496(Config) ->
     file:set_cwd(filename:join(datadir(Config),xpath)),
     ok = xpath_abbrev:ticket_7496().
 
-ticket_8156(Config) ->
+ticket_8156(_Config) ->
     {ftp,{[],[]},"testmachine1",21,"/w.erl"} = xmerl_uri:parse("ftp://testmachine1/w.erl"),
     {ftp,{"user",[]},"testmachine1",21,"/w.erl"} = xmerl_uri:parse("ftp://user@testmachine1/w.erl"),
     {ftp,{"user","hello"},"testmachine1",21,"/w.erl"} = xmerl_uri:parse("ftp://user:hello@testmachine1/w.erl"),
@@ -562,7 +565,7 @@ ticket_8156(Config) ->
     ok.
 
 %% Test that xmerl_scan can decode unicode entities properly
-ticket_8697(Config) ->
+ticket_8697(_Config) ->
     {UTF8Output, []} = xmerl_scan:string("<?xml version=\"1\" ?>\n<text>" ++ [229, 145, 156] ++ "</text>"),
     #xmlElement{content = [#xmlText{value = UTF8Text}]} = UTF8Output,
     [16#545C] = UTF8Text,
@@ -585,9 +588,9 @@ ticket_9411(Config) ->
     {E, _} = xmerl_xsd:validate(E, Schema).
 
 %% Test that xmerl_scan handles continuation correct when current input runs out at the end of an attribute value
-ticket_9457(Config) ->
+ticket_9457(_Config) ->
     Opts = [{continuation_fun, fun ticket_9457_cont/3, start}, {space, normalize}],
-    {E, _} = xmerl_scan:string([], Opts).
+    {_E, _} = xmerl_scan:string([], Opts).
 
 ticket_9457_cont(Continue, Exception, GlobalState) ->
     case xmerl_scan:cont_state(GlobalState) of
diff --git a/lib/xmerl/test/xmerl_sax_std_SUITE.erl b/lib/xmerl/test/xmerl_sax_std_SUITE.erl
index 94c02b2218..fd392c1321 100644
--- a/lib/xmerl/test/xmerl_sax_std_SUITE.erl
+++ b/lib/xmerl/test/xmerl_sax_std_SUITE.erl
@@ -2817,7 +2817,7 @@ end_per_testcase(_Func,_Config) ->
 %% Description:
 %%   Tests the VC by referring to an undefined parameter entity within an
 %%   external entity.
-'not-wf-not-sa-005'(Config) -> {skip, "unknown parameter reference in external (VC test not WFC)"}.
+'not-wf-not-sa-005'(_Config) -> {skip, "unknown parameter reference in external (VC test not WFC)"}.
 %%    file:set_cwd(datadir(Config)),
 %%    Path = filename:join([datadir(Config),"xmltest","not-wf/not-sa/005.xml"]),
 %%    R = xmerl_sax_parser:file(Path, [{event_fun, fun sax_canon/3}]),
@@ -2895,7 +2895,7 @@ end_per_testcase(_Func,_Config) ->
 %% Entities: both
 %% Description:
 %%   Tests the WFC by having an external general entity be self-recursive.
-'not-wf-ext-sa-001'(Config) -> {skip, "recursive external reference"}.
+'not-wf-ext-sa-001'(_Config) -> {skip, "recursive external reference"}.
 %%    file:set_cwd(datadir(Config)),
 %%    Path = filename:join([datadir(Config),"xmltest","not-wf/ext-sa/001.xml"]),
 %%    R = xmerl_sax_parser:file(Path, [{event_fun, fun sax_canon/3}]),
diff --git a/lib/xmerl/test/xmerl_sax_stream_SUITE.erl b/lib/xmerl/test/xmerl_sax_stream_SUITE.erl
index 7315f67374..9114a74e4a 100644
--- a/lib/xmerl/test/xmerl_sax_stream_SUITE.erl
+++ b/lib/xmerl/test/xmerl_sax_stream_SUITE.erl
@@ -207,7 +207,7 @@ one_document_and_junk(Config) ->
 
 %%----------------------------------------------------------------------
 %% Test of continuation when end of stream
-end_of_stream(Config) ->
+end_of_stream(_Config) ->
     Stream = <<"<?xml version=\"1.0\" encoding=\"utf-8\"?><a>hej</a>">>,
     {ok, undefined, <<>>} = xmerl_sax_parser:stream(Stream, []),
     ok.
-- 
2.26.2

openSUSE Build Service is sponsored by