From e450cd60424061ab0b10e94b8e3973d0b5793c6a Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Tue, 5 Mar 2019 15:45:09 +0100 Subject: [PATCH] Set modification time via os.utime Hopefully quicker on Windows --- test/test_makefile_dependencies.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/test_makefile_dependencies.py b/test/test_makefile_dependencies.py index 9045cb3f..86730890 100644 --- a/test/test_makefile_dependencies.py +++ b/test/test_makefile_dependencies.py @@ -24,20 +24,9 @@ def test_makefile_dependencies(): def touch(time, *files): - if not files: - raise Exception("Please specify the files to update") - if os.name == 'nt': - formatstring = "Get-Date -year %Y -month %m -day %d -hour %H -minute %M -second %S" - time = time.strftime(formatstring) - commands = [] - for file in files: - commands.append('(ls {}).LastWriteTime = {}'.format(file, time)) - - helpers.run_subprocess(['powershell', '; '.join(commands)]) - else: - formatstring = "%Y%m%d%H%M.%S" - time = time.strftime(formatstring) - helpers.run_subprocess(['touch', '-t', time, *files]) + for path in files: + times = (time.timestamp(), time.timestamp()) + os.utime(path, times) def make_check(path, expect_error=False):