From 47009df757aea5a203357d5010c37fdfe8396107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= Date: Fri, 18 Oct 2024 12:58:14 +0200 Subject: [PATCH] stdlib: Fix zip_SUITE atime assert --- lib/stdlib/test/zip_SUITE.erl | 43 ++++++++++++++--------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl index ec9a8a282ff7..08ee8651b099 100644 --- a/lib/stdlib/test/zip_SUITE.erl +++ b/lib/stdlib/test/zip_SUITE.erl @@ -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. @@ -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.