overwrite tests: work on macos
This commit is contained in:
parent
56df316cc2
commit
4e9547703c
@ -1220,6 +1220,17 @@ def test_install_implicit(install_mockery, mock_fetch):
|
|||||||
assert not create_build_task(pkg).explicit
|
assert not create_build_task(pkg).explicit
|
||||||
|
|
||||||
|
|
||||||
|
# Install that wipes the prefix directory
|
||||||
|
def wipe_prefix(pkg, install_args):
|
||||||
|
shutil.rmtree(pkg.prefix, ignore_errors=True)
|
||||||
|
fs.mkdirp(pkg.prefix)
|
||||||
|
raise Exception("Some fatal install error")
|
||||||
|
|
||||||
|
|
||||||
|
def fail(*args, **kwargs):
|
||||||
|
assert False
|
||||||
|
|
||||||
|
|
||||||
def test_overwrite_install_backup_success(
|
def test_overwrite_install_backup_success(
|
||||||
monkeypatch, temporary_store, config, mock_packages, tmpdir
|
monkeypatch, temporary_store, config, mock_packages, tmpdir
|
||||||
):
|
):
|
||||||
@ -1238,17 +1249,8 @@ def test_overwrite_install_backup_success(
|
|||||||
installed_file = os.path.join(task.pkg.prefix, "some_file")
|
installed_file = os.path.join(task.pkg.prefix, "some_file")
|
||||||
fs.touchp(installed_file)
|
fs.touchp(installed_file)
|
||||||
|
|
||||||
# Install that wipes the prefix directory
|
|
||||||
def wipe_prefix(pkg, install_args):
|
|
||||||
shutil.rmtree(pkg.prefix, ignore_errors=True)
|
|
||||||
fs.mkdirp(pkg.prefix)
|
|
||||||
raise Exception("Some fatal install error")
|
|
||||||
|
|
||||||
monkeypatch.setattr(inst, "build_process", wipe_prefix)
|
monkeypatch.setattr(inst, "build_process", wipe_prefix)
|
||||||
|
|
||||||
def fail(*args, **kwargs):
|
|
||||||
assert False
|
|
||||||
|
|
||||||
# Make sure the package is not marked uninstalled
|
# Make sure the package is not marked uninstalled
|
||||||
monkeypatch.setattr(spack.store.STORE.db, "remove", fail)
|
monkeypatch.setattr(spack.store.STORE.db, "remove", fail)
|
||||||
# Make sure that the installer does an overwrite install
|
# Make sure that the installer does an overwrite install
|
||||||
@ -1264,6 +1266,15 @@ def fail(*args, **kwargs):
|
|||||||
assert os.path.exists(installed_file)
|
assert os.path.exists(installed_file)
|
||||||
|
|
||||||
|
|
||||||
|
# Install that removes the backup directory, which is at the same level as
|
||||||
|
# the prefix, starting with .backup
|
||||||
|
def remove_backup(pkg, install_args):
|
||||||
|
backup_glob = os.path.join(os.path.dirname(os.path.normpath(pkg.prefix)), ".backup*")
|
||||||
|
for backup in glob.iglob(backup_glob):
|
||||||
|
shutil.rmtree(backup)
|
||||||
|
raise Exception("Some fatal install error")
|
||||||
|
|
||||||
|
|
||||||
def test_overwrite_install_backup_failure(
|
def test_overwrite_install_backup_failure(
|
||||||
monkeypatch, temporary_store, config, mock_packages, tmpdir
|
monkeypatch, temporary_store, config, mock_packages, tmpdir
|
||||||
):
|
):
|
||||||
@ -1282,15 +1293,6 @@ def test_overwrite_install_backup_failure(
|
|||||||
# Make sure the install prefix exists
|
# Make sure the install prefix exists
|
||||||
installed_file = os.path.join(task.pkg.prefix, "some_file")
|
installed_file = os.path.join(task.pkg.prefix, "some_file")
|
||||||
fs.touchp(installed_file)
|
fs.touchp(installed_file)
|
||||||
|
|
||||||
# Install that removes the backup directory, which is at the same level as
|
|
||||||
# the prefix, starting with .backup
|
|
||||||
def remove_backup(*args, **kwargs):
|
|
||||||
backup_glob = os.path.join(os.path.dirname(os.path.normpath(task.pkg.prefix)), ".backup*")
|
|
||||||
for backup in glob.iglob(backup_glob):
|
|
||||||
shutil.rmtree(backup)
|
|
||||||
raise Exception("Some fatal install error")
|
|
||||||
|
|
||||||
monkeypatch.setattr(inst, "build_process", remove_backup)
|
monkeypatch.setattr(inst, "build_process", remove_backup)
|
||||||
|
|
||||||
called = False
|
called = False
|
||||||
|
Loading…
Reference in New Issue
Block a user