commit:     90b89296bd671e9c0fc5023d9ae11847dfe9c645
Author:     Amadeusz Żołnowski <aidecoe <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  2 17:12:58 2017 +0000
Commit:     Amadeusz Piotr Żołnowski <aidecoe <AT> gentoo <DOT> org>
CommitDate: Mon Jan  2 17:30:24 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=90b89296

dev-erlang/fast_xml: Fix unit tests

Package-Manager: Portage-2.3.3, Repoman-2.3.1

 dev-erlang/fast_xml/fast_xml-1.1.18.ebuild         |  4 +-
 .../fast_xml/files/1.1.18-0001-Fix-unittests.patch | 92 ++++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild 
b/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
index 7133bba..fda4c02 100644
--- a/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
+++ b/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -23,3 +23,5 @@ DEPEND="${RDEPEND}
        test? ( >=dev-lang/elixir-1.1 )"
 
 DOCS=( CHANGELOG.md  README.md )
+
+PATCHES=( "${FILESDIR}"/${PV}-0001-Fix-unittests.patch )

diff --git a/dev-erlang/fast_xml/files/1.1.18-0001-Fix-unittests.patch 
b/dev-erlang/fast_xml/files/1.1.18-0001-Fix-unittests.patch
new file mode 100644
index 00000000..c5113bd
--- /dev/null
+++ b/dev-erlang/fast_xml/files/1.1.18-0001-Fix-unittests.patch
@@ -0,0 +1,92 @@
+From 4b65d1603c9b16cf440e0b434673de9d7bdca6b5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= <pchmielow...@process-one.net>
+Date: Mon, 2 Jan 2017 10:58:33 +0100
+Subject: [PATCH] Load locally build .so file when performing tests
+
+This should help with issue #19 and #20
+---
+ src/fxml.erl        |  5 ++++-
+ src/fxml_stream.erl | 11 +++++++----
+ test/fxml_test.erl  |  6 ++----
+ 3 files changed, 13 insertions(+), 9 deletions(-)
+
+diff --git a/src/fxml.erl b/src/fxml.erl
+index 935bf28..ed6e535 100644
+--- a/src/fxml.erl
++++ b/src/fxml.erl
+@@ -36,7 +36,7 @@
+        append_subtags/2, get_path_s/2,
+        replace_tag_attr/3, replace_subtag/2, to_xmlel/1]).
+ 
+--export([load_nif/0]).
++-export([load_nif/0, load_nif/1]).
+ 
+ -include("fxml.hrl").
+ -export_type([xmlel/0]).
+@@ -44,6 +44,9 @@
+ %% Replace element_to_binary/1 with NIF
+ load_nif() ->
+     SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml"),
++    load_nif(SOPath).
++
++load_nif(SOPath) ->
+     case catch erlang:load_nif(SOPath, 0) of
+         ok -> ok;
+         Err -> error_logger:warning_msg("unable to load fxml NIF: ~p~n", 
[Err]),
+diff --git a/src/fxml_stream.erl b/src/fxml_stream.erl
+index a2fcb01..ee1a949 100644
+--- a/src/fxml_stream.erl
++++ b/src/fxml_stream.erl
+@@ -30,7 +30,7 @@
+ -export([new/1, new/2, new/3, parse/2, close/1, reset/1,
+        change_callback_pid/2, parse_element/1]).
+ 
+--export([load_nif/0]).
++-export([load_nif/0, load_nif/1]).
+ 
+ -include("fxml.hrl").
+ 
+@@ -54,13 +54,16 @@
+ -export_type([xml_stream_state/0, xml_stream_el/0]).
+ 
+ load_nif() ->
+-    NifFile = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml_stream"),
+-    case erlang:load_nif(NifFile, 0) of
++    SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml_stream"),
++    load_nif(SOPath).
++
++load_nif(SOPath) ->
++    case erlang:load_nif(SOPath, 0) of
+       ok ->
+           ok;
+         {error, {Reason, Txt}} ->
+             error_logger:error_msg("failed to load NIF ~s: ~s",
+-                                   [NifFile, Txt]),
++                                   [SOPath, Txt]),
+             {error, Reason}
+     end.
+ 
+diff --git a/test/fxml_test.erl b/test/fxml_test.erl
+index e41a3dc..0bd2f91 100644
+--- a/test/fxml_test.erl
++++ b/test/fxml_test.erl
+@@ -39,7 +39,8 @@ close(State) ->
+     ?assertEqual(true, fxml_stream:close(State)).
+ 
+ start_test() ->
+-    ?assertEqual(ok, application:start(fast_xml)).
++    ?assertEqual(ok, fxml:load_nif(p1_nif_utils:get_so_path(fxml, [], 
"fxml"))),
++    ?assertEqual(ok, 
fxml_stream:load_nif(p1_nif_utils:get_so_path(fxml_stream, [], "fxml_stream"))).
+ 
+ tag_test() ->
+     ?assertEqual(#xmlel{name = <<"root">>},
+@@ -877,6 +878,3 @@ rpc_empty_response_test() ->
+     Result = {response, []},
+     ?assertEqual({ok, Result}, fxmlrpc:decode(Response)),
+     ?assertEqual(Response, fxmlrpc:encode(Result)).
+-
+-application_stop_test() ->
+-    ?assertEqual(ok, application:stop(fast_xml)).
+-- 
+2.11.0
+

Reply via email to