Add subprojects purge wrap-git coverage

pull/8701/head
Tristan Partin 4 years ago committed by Xavier Claessens
parent d4e867809b
commit bb12587e0b
  1. 14
      mesonbuild/msubprojects.py
  2. 9
      run_unittests.py

@ -325,11 +325,14 @@ def purge(r: Resolver, wrap: PackageDefinition, repo_dir: str, options: argparse
if options.include_cache:
packagecache = Path(r.cachedir).resolve()
subproject_cache_file = packagecache / wrap.get("source_filename")
if subproject_cache_file.is_file():
if options.confirm:
subproject_cache_file.unlink()
mlog.log(f'Deleting {subproject_cache_file}')
try:
subproject_cache_file = packagecache / wrap.get("source_filename")
if subproject_cache_file.is_file():
if options.confirm:
subproject_cache_file.unlink()
mlog.log(f'Deleting {subproject_cache_file}')
except WrapException:
pass
try:
subproject_patch_file = packagecache / wrap.get("patch_filename")
@ -353,7 +356,6 @@ def purge(r: Resolver, wrap: PackageDefinition, repo_dir: str, options: argparse
subproject_source_dir.unlink()
mlog.log(f'Deleting {subproject_source_dir}')
return True
if not subproject_source_dir.is_dir():
return True

@ -9881,6 +9881,8 @@ class SubprojectsCommandTests(BasePlatformTests):
def test_purge(self):
self._create_project(self.subprojects_dir / 'sub_file')
self._wrap_create_file('sub_file')
self._git_create_local_repo('sub_git')
self._wrap_create_git('sub_git')
def deleting(s) -> T.List[str]:
ret = []
@ -9891,13 +9893,14 @@ class SubprojectsCommandTests(BasePlatformTests):
return sorted(ret)
out = self._subprojects_cmd(['purge'])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'sub_file')])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'sub_file'), str(self.subprojects_dir / 'sub_git')])
out = self._subprojects_cmd(['purge', '--include-cache'])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'packagecache' / 'dummy.tar.gz'), str(self.subprojects_dir / 'sub_file')])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'packagecache' / 'dummy.tar.gz'), str(self.subprojects_dir / 'sub_file'), str(self.subprojects_dir / 'sub_git')])
out = self._subprojects_cmd(['purge', '--include-cache', '--confirm'])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'packagecache' / 'dummy.tar.gz'), str(self.subprojects_dir / 'sub_file')])
self.assertEqual(deleting(out), [str(self.subprojects_dir / 'packagecache' / 'dummy.tar.gz'), str(self.subprojects_dir / 'sub_file'), str(self.subprojects_dir / 'sub_git')])
self.assertFalse(Path(self.subprojects_dir / 'packagecache' / 'dummy.tar.gz').exists())
self.assertFalse(Path(self.subprojects_dir / 'sub_file').exists())
self.assertFalse(Path(self.subprojects_dir / 'sub_git').exists())
def _clang_at_least(compiler: 'Compiler', minver: str, apple_minver: T.Optional[str]) -> bool:
"""

Loading…
Cancel
Save