This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/couchdb-jiffy.git
commit a529615e4cd40e3ec857ce2e7c2f334ef777a0eb Author: Nick Vatamaniuc <[email protected]> AuthorDate: Fri Apr 10 14:31:11 2026 -0400 Add some NIF lifecyle coverage Not 100% if these ever worked right. Resources do have `ERL_NIF_RT_TAKEOVER` specified and we end up re-creating the private context on upgrade so at least let's try to test them with a few purge and reload checks. Another alternative is to make these `NULL`s and just say that upgrade is not supported. --- test/jiffy_20_lifecycle_tests.erl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/jiffy_20_lifecycle_tests.erl b/test/jiffy_20_lifecycle_tests.erl new file mode 100644 index 0000000..f29af85 --- /dev/null +++ b/test/jiffy_20_lifecycle_tests.erl @@ -0,0 +1,29 @@ +% This file is part of Jiffy released under the MIT license. +% See the LICENSE file for more information. + +-module(jiffy_20_lifecycle_tests). + +-include_lib("eunit/include/eunit.hrl"). + +%% This is more of covarage hacking but we're trying exercise some of the +%% lifecycle callback in jiffy.c + +upgrade_test() -> + % baseline + ?assertEqual(1, jiffy:decode(<<"1">>)), + ?assertEqual(<<"1">>, iolist_to_binary(jiffy:encode(1))), + + % soft purge and reload + code:purge(jiffy), + {module, jiffy} = code:load_file(jiffy), + + % verify + ?assertEqual(1, jiffy:decode(<<"1">>)), + ?assertEqual(<<"1">>, iolist_to_binary(jiffy:encode(1))), + + % another purge should now evict the old module + code:purge(jiffy), + + % verify + ?assertEqual(1, jiffy:decode(<<"1">>)), + ?assertEqual(<<"1">>, iolist_to_binary(jiffy:encode(1))).
