diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-22 12:50:12 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-22 12:50:12 +0300 |
commit | ec541a4a021e5d5468f62d43c24c3252cbd5c5c8 (patch) | |
tree | 7345b5fb086bfaf753e911cdc6938d5447cc3ab6 | |
parent | 626c0a53193415d076936dee0ab4bc4c4c4eb4a4 (diff) | |
download | meson-macfixes.zip meson-macfixes.tar.gz meson-macfixes.tar.bz2 |
Handle macOS filesystem sometimes setting lower digits to zero.macfixes
-rw-r--r-- | test cases/common/14 configure file/check_file.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test cases/common/14 configure file/check_file.py b/test cases/common/14 configure file/check_file.py index 1cdb624..a966147 100644 --- a/test cases/common/14 configure file/check_file.py +++ b/test cases/common/14 configure file/check_file.py @@ -3,6 +3,16 @@ import os import sys +def permit_osx_workaround(m1, m2): + import platform + if platform.system().lower() != 'darwin': + return False + if m2 % 10000 != 0: + return False + if m1//10000 != m2//10000: + return False + return True + if len(sys.argv) == 2: assert(os.path.exists(sys.argv[1])) elif len(sys.argv) == 3: @@ -12,7 +22,11 @@ elif len(sys.argv) == 3: m2 = os.stat(f2).st_mtime_ns # Compare only os.stat() if m1 != m2: - raise RuntimeError(f'mtime of {f1!r} () != mtime of {m1!r} ()') + # Under macOS the lower four digits sometimes get assigned + # zero, even though shutil.copy2 should preserve metadata. + # Just have to accept it, I guess. + if not permit_osx_workaround(m1, m2): + raise RuntimeError(f'mtime of {f1!r} ({m1!r}) != mtime of {f2!r} ({m2!r})') import filecmp if not filecmp.cmp(f1, f2): raise RuntimeError(f'{f1!r} != {f2!r}') |