ensure timestamps are different in tests
This commit is contained in:
parent
c20a4d6ad1
commit
f1c831cf6e
@ -8,6 +8,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -3368,7 +3369,9 @@ def test_view_update_unnecessary(update_method, tmpdir, install_mockery, mock_fe
|
|||||||
install("libdwarf")
|
install("libdwarf")
|
||||||
|
|
||||||
# Create a "previous" view
|
# Create a "previous" view
|
||||||
|
# Wait after each view regeneration to ensure timestamps are different
|
||||||
view.regenerate([libelf])
|
view.regenerate([libelf])
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# monkeypatch so that any attempt to actually regenerate the view fails
|
# monkeypatch so that any attempt to actually regenerate the view fails
|
||||||
def raises(*args, **kwargs):
|
def raises(*args, **kwargs):
|
||||||
@ -3380,12 +3383,14 @@ def raises(*args, **kwargs):
|
|||||||
# regenerating the view is a no-op, so doesn't raise
|
# regenerating the view is a no-op, so doesn't raise
|
||||||
# will raise if the view isn't identical
|
# will raise if the view isn't identical
|
||||||
view.regenerate([libelf])
|
view.regenerate([libelf])
|
||||||
|
time.sleep(1)
|
||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
view.regenerate([libelf, libdwarf])
|
view.regenerate([libelf, libdwarf])
|
||||||
|
|
||||||
# Create another view so there are multiple old views around
|
# Create another view so there are multiple old views around
|
||||||
monkeypatch.setattr(view, "view", old_view)
|
monkeypatch.setattr(view, "view", old_view)
|
||||||
view.regenerate([libelf, libdwarf])
|
view.regenerate([libelf, libdwarf])
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# Redo the monkeypatch
|
# Redo the monkeypatch
|
||||||
monkeypatch.setattr(view, "view", raises)
|
monkeypatch.setattr(view, "view", raises)
|
||||||
@ -3393,5 +3398,6 @@ def raises(*args, **kwargs):
|
|||||||
# no raise for no-op regeneration
|
# no raise for no-op regeneration
|
||||||
# raise when it's not a no-op
|
# raise when it's not a no-op
|
||||||
view.regenerate([libelf, libdwarf])
|
view.regenerate([libelf, libdwarf])
|
||||||
|
time.sleep(1)
|
||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
view.regenerate([libelf])
|
view.regenerate([libelf])
|
||||||
|
@ -56,7 +56,7 @@ def atomic_update_renameat2(src, dest):
|
|||||||
raise OSError(f"renameat2 failed to exchange {src} and {dest}")
|
raise OSError(f"renameat2 failed to exchange {src} and {dest}")
|
||||||
except OSError:
|
except OSError:
|
||||||
if not dest_exists:
|
if not dest_exists:
|
||||||
os.unlink(dest)
|
os.rmdir(dest)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user