Skip to content

Commit

Permalink
stdlib: Fix zip_SUITE atime assert
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Oct 18, 2024
1 parent 2e326d7 commit 47009df
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions lib/stdlib/test/zip_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1467,20 +1467,7 @@ basic_timestamp(Config) ->

UnzipMode = un_z64(get_value(unzip, Config)),

if UnzipMode =/= unemzip ->
?assertEqual(ZMtime, UnZMtime),

%% both atime and ctime behave very differently on different platforms, so it is rather hard to test.
%% atime is sometimes set to ctime for unknown reasons, and sometimes set to 1970...
?assert(UnZAtime =:= UnZMtime orelse UnZAtime =:= UnZCtime orelse UnZAtime =:= {1970,1,1},{1,0,0}),

%% On windows the ctime and mtime are the same so
%% we cannot compare them.
[?assert(UnZMtime < UnZCtime) || os:type() =/= {win32,nt}];
UnzipMode =:= unemzip ->
%% emzip does not support timestamps
ok
end,
assert_timestamp(UnzipMode, UnzipFI, ZMtime),

ok.

Expand Down Expand Up @@ -1534,20 +1521,24 @@ extended_timestamp(Config) ->

UnzipMode = un_z64(get_value(unzip, Config)),

if UnzipMode =/= unemzip ->
?assertEqual(ZMtime, UnZMtime),
assert_time(UnzipMode, UnzipFI, ZMtime ),

%% When using unzip, the atime is sometimes set to ctime for unknown reasons... so we cannot test it
%% ?assertEqual(UnZAtime, UnZMtime),
?assert(UnZAtime =:= UnZMtime orelse UnZAtime =:= UnZCtime),
ok.

%% On windows the ctime and mtime are the same so
%% we cannot compare them.
[?assert(UnZMtime < UnZCtime) || os:type() =/= {win32,nt}];
UnzipMode =:= unemzip ->
%% emzip does not support timestamps
ok
end,
assert_timestamp(unemzip, _FI, _ZMtime) ->
%% emzip does not support timestamps
ok;
assert_timestamp(_, #file_info{ atime = UnZAtime, mtime = UnZMtime, ctime = UnZCtime }, ZMtime) ->

?assertEqual(ZMtime, UnZMtime),

%% both atime and ctime behave very differently on different platforms, so it is rather hard to test.
%% atime is sometimes set to ctime for unknown reasons, and sometimes set to 1970...
?assert(UnZAtime =:= UnZMtime orelse UnZAtime =:= UnZCtime orelse UnZAtime =:= {{1970,1,1},{1,0,0}}),

%% On windows the ctime and mtime are the same so
%% we cannot compare them.
[?assert(UnZMtime < UnZCtime) || os:type() =/= {win32,nt}],

ok.

Expand Down

0 comments on commit 47009df

Please sign in to comment.