diff options
author | Tristan Partin <tristan@partin.io> | 2021-04-26 10:14:39 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-04-26 12:06:12 -0400 |
commit | bb12587e0ba83ed6cde0f395c0a31cee9a3ace26 (patch) | |
tree | d465e4c9624905505e90d81613232cab7e0de3b3 | |
parent | d4e867809b5b16a4eda0751c7d0148b13b0e35d9 (diff) | |
download | meson-bb12587e0ba83ed6cde0f395c0a31cee9a3ace26.zip meson-bb12587e0ba83ed6cde0f395c0a31cee9a3ace26.tar.gz meson-bb12587e0ba83ed6cde0f395c0a31cee9a3ace26.tar.bz2 |
Add subprojects purge wrap-git coverage
-rwxr-xr-x | mesonbuild/msubprojects.py | 14 | ||||
-rwxr-xr-x | run_unittests.py | 9 |
2 files changed, 14 insertions, 9 deletions
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index bdd8c1f..b50c986 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.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 diff --git a/run_unittests.py b/run_unittests.py index b75eb16..8674426 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -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: """ |