Gentoo Archives: gentoo-commits

From: "Amadeusz Piotr Żołnowski" <aidecoe@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-erlang/fast_xml/files/, dev-erlang/fast_xml/
Date: Mon, 02 Jan 2017 17:30:37
Message-Id: 1483378224.90b89296bd671e9c0fc5023d9ae11847dfe9c645.aidecoe@gentoo
1 commit: 90b89296bd671e9c0fc5023d9ae11847dfe9c645
2 Author: Amadeusz Żołnowski <aidecoe <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 2 17:12:58 2017 +0000
4 Commit: Amadeusz Piotr Żołnowski <aidecoe <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 2 17:30:24 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=90b89296
7
8 dev-erlang/fast_xml: Fix unit tests
9
10 Package-Manager: Portage-2.3.3, Repoman-2.3.1
11
12 dev-erlang/fast_xml/fast_xml-1.1.18.ebuild | 4 +-
13 .../fast_xml/files/1.1.18-0001-Fix-unittests.patch | 92 ++++++++++++++++++++++
14 2 files changed, 95 insertions(+), 1 deletion(-)
15
16 diff --git a/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild b/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
17 index 7133bba..fda4c02 100644
18 --- a/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
19 +++ b/dev-erlang/fast_xml/fast_xml-1.1.18.ebuild
20 @@ -1,4 +1,4 @@
21 -# Copyright 1999-2016 Gentoo Foundation
22 +# Copyright 1999-2017 Gentoo Foundation
23 # Distributed under the terms of the GNU General Public License v2
24 # $Id$
25
26 @@ -23,3 +23,5 @@ DEPEND="${RDEPEND}
27 test? ( >=dev-lang/elixir-1.1 )"
28
29 DOCS=( CHANGELOG.md README.md )
30 +
31 +PATCHES=( "${FILESDIR}"/${PV}-0001-Fix-unittests.patch )
32
33 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
34 new file mode 100644
35 index 00000000..c5113bd
36 --- /dev/null
37 +++ b/dev-erlang/fast_xml/files/1.1.18-0001-Fix-unittests.patch
38 @@ -0,0 +1,92 @@
39 +From 4b65d1603c9b16cf440e0b434673de9d7bdca6b5 Mon Sep 17 00:00:00 2001
40 +From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= <pchmielowski@×××××××××××.net>
41 +Date: Mon, 2 Jan 2017 10:58:33 +0100
42 +Subject: [PATCH] Load locally build .so file when performing tests
43 +
44 +This should help with issue #19 and #20
45 +---
46 + src/fxml.erl | 5 ++++-
47 + src/fxml_stream.erl | 11 +++++++----
48 + test/fxml_test.erl | 6 ++----
49 + 3 files changed, 13 insertions(+), 9 deletions(-)
50 +
51 +diff --git a/src/fxml.erl b/src/fxml.erl
52 +index 935bf28..ed6e535 100644
53 +--- a/src/fxml.erl
54 ++++ b/src/fxml.erl
55 +@@ -36,7 +36,7 @@
56 + append_subtags/2, get_path_s/2,
57 + replace_tag_attr/3, replace_subtag/2, to_xmlel/1]).
58 +
59 +--export([load_nif/0]).
60 ++-export([load_nif/0, load_nif/1]).
61 +
62 + -include("fxml.hrl").
63 + -export_type([xmlel/0]).
64 +@@ -44,6 +44,9 @@
65 + %% Replace element_to_binary/1 with NIF
66 + load_nif() ->
67 + SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml"),
68 ++ load_nif(SOPath).
69 ++
70 ++load_nif(SOPath) ->
71 + case catch erlang:load_nif(SOPath, 0) of
72 + ok -> ok;
73 + Err -> error_logger:warning_msg("unable to load fxml NIF: ~p~n", [Err]),
74 +diff --git a/src/fxml_stream.erl b/src/fxml_stream.erl
75 +index a2fcb01..ee1a949 100644
76 +--- a/src/fxml_stream.erl
77 ++++ b/src/fxml_stream.erl
78 +@@ -30,7 +30,7 @@
79 + -export([new/1, new/2, new/3, parse/2, close/1, reset/1,
80 + change_callback_pid/2, parse_element/1]).
81 +
82 +--export([load_nif/0]).
83 ++-export([load_nif/0, load_nif/1]).
84 +
85 + -include("fxml.hrl").
86 +
87 +@@ -54,13 +54,16 @@
88 + -export_type([xml_stream_state/0, xml_stream_el/0]).
89 +
90 + load_nif() ->
91 +- NifFile = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml_stream"),
92 +- case erlang:load_nif(NifFile, 0) of
93 ++ SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_xml], "fxml_stream"),
94 ++ load_nif(SOPath).
95 ++
96 ++load_nif(SOPath) ->
97 ++ case erlang:load_nif(SOPath, 0) of
98 + ok ->
99 + ok;
100 + {error, {Reason, Txt}} ->
101 + error_logger:error_msg("failed to load NIF ~s: ~s",
102 +- [NifFile, Txt]),
103 ++ [SOPath, Txt]),
104 + {error, Reason}
105 + end.
106 +
107 +diff --git a/test/fxml_test.erl b/test/fxml_test.erl
108 +index e41a3dc..0bd2f91 100644
109 +--- a/test/fxml_test.erl
110 ++++ b/test/fxml_test.erl
111 +@@ -39,7 +39,8 @@ close(State) ->
112 + ?assertEqual(true, fxml_stream:close(State)).
113 +
114 + start_test() ->
115 +- ?assertEqual(ok, application:start(fast_xml)).
116 ++ ?assertEqual(ok, fxml:load_nif(p1_nif_utils:get_so_path(fxml, [], "fxml"))),
117 ++ ?assertEqual(ok, fxml_stream:load_nif(p1_nif_utils:get_so_path(fxml_stream, [], "fxml_stream"))).
118 +
119 + tag_test() ->
120 + ?assertEqual(#xmlel{name = <<"root">>},
121 +@@ -877,6 +878,3 @@ rpc_empty_response_test() ->
122 + Result = {response, []},
123 + ?assertEqual({ok, Result}, fxmlrpc:decode(Response)),
124 + ?assertEqual(Response, fxmlrpc:encode(Result)).
125 +-
126 +-application_stop_test() ->
127 +- ?assertEqual(ok, application:stop(fast_xml)).
128 +--
129 +2.11.0
130 +