Skip to content

Commit

Permalink
gh03 - Update for Erlang/OTP 18
Browse files Browse the repository at this point in the history
- Update require_otp_version in rebar.config.
- Now the eunit module uses erlang:timestamp/0 in OTP 18 or newer,
  and falls back to erlang:now/0 for older OTP releases.
  • Loading branch information
tatsuya6502 committed Jul 31, 2015
1 parent 0c1af44 commit 95358d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%%% -*- mode: erlang -*-

{require_otp_vsn, "R16|17"}.
{require_otp_vsn, "R16|17|18"}.

{pre_hooks, [{clean, "c_src/build_deps.sh clean"},
{'get-deps', "c_src/build_deps.sh get_deps"},
Expand Down
22 changes: 20 additions & 2 deletions test/eunit/h2leveldb_test.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%%% The MIT License
%%%
%%% Copyright (C) 2014 by Tatsuya Kawano <tatsuya@hibaridb.org>
%%% Copyright (C) 2014-2015 by Tatsuya Kawano <tatsuya@hibaridb.org>
%%%
%%% Permission is hereby granted, free of charge, to any person obtaining a copy
%%% of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,6 +24,16 @@

-include_lib("eunit/include/eunit.hrl").

%% We don't want warnings about the use of erlang:now/0 in
%% this module.
-compile(nowarn_deprecated_function).
%%
%% We don't use
%% -compile({nowarn_deprecated_function, [{erlang, now, 0}]}).
%% since this will produce warnings when compiled on systems
%% where it has not yet been deprecated.
%%

-define(H2LEVELDB, h2leveldb).

db_crud_test() ->
Expand Down Expand Up @@ -269,7 +279,15 @@ read_and_prev(_, Key, _, _, _) ->
error({key, Key, must_not_exist}).

make_temp_db_path() ->
{MegaSecs, Secs, MicroSecs} = erlang:now(),
{MegaSecs, Secs, MicroSecs} = timestamp(),
FileName = io_lib:format("h2leveldb-test-~w-~w-~w.leveldb",
[MegaSecs, Secs, MicroSecs]),
filename:join("/tmp", FileName).

timestamp() ->
try
erlang:timestamp()
catch
error:undef ->
erlang:now()
end.

0 comments on commit 95358d9

Please sign in to comment.