@davoodmehraban89 / LifeMate / commits / 89a8143
Fork 0

LifeMate — Personal, Family & Learning Companion

test: isolate unsafe sidecar fixtures for independent regression failures

Quinn White committed Oct 23, 2026 at 06:39 UTC 89a81432ebaa95f1d118595f87b90ef287f33693
1 file changed +38 -46
apps/lifemate/tool/test_personal_recovery_android_test.py
+38 -46
@@ -215,53 +215,45 @@ class RecoveryBoundaryTest(unittest.TestCase):
215 h.preflight()
216 h.install(subject.ORIGINAL)
217 previous_shell = self.adb.shell
218 - with tempfile.TemporaryDirectory() as root:
219 - db = Path(root) / subject.DATABASE
220 - db.parent.mkdir()
221 - journal = Path(str(db) + '-journal')
222 - wal = Path(str(db) + '-wal')
223 - shm = Path(str(db) + '-shm')
224 - def shell(*parts, **kwargs):
225 - if parts[0] == 'run-as':
226 - return subprocess.run(['sh', '-c', parts[-1]], cwd=root,
227 - capture_output=True, text=True, check=True, timeout=2).stdout
228 - return previous_shell(*parts, **kwargs)
229 - self.adb.shell = shell
230 - for kind in ('byte', 'directory', 'fifo', 'symlink', 'dangling', 'with_wal', 'with_shm', 'shm_directory', 'shm_fifo', 'wal_dangling', 'shm_dangling'):
231 - with self.subTest(kind=kind):
232 - if kind == 'byte':
233 - journal.write_bytes(b'x')
234 - elif kind == 'directory':
235 - journal.mkdir()
236 - elif kind == 'fifo':
237 - subject.os.mkfifo(journal)
238 - elif kind in ('symlink', 'dangling'):
239 - target = Path(root) / 'empty-target'
240 - if kind == 'symlink':
241 - target.write_bytes(b'')
242 - journal.symlink_to(target if kind == 'symlink' else Path(root) / 'missing')
243 - elif kind in ('shm_directory', 'shm_fifo'):
244 - wal.write_bytes(b'')
245 - if kind == 'shm_directory':
246 - shm.mkdir()
247 - else:
248 - subject.os.mkfifo(shm)
249 - elif kind in ('wal_dangling', 'shm_dangling'):
250 - (wal if kind == 'wal_dangling' else shm).symlink_to(Path(root) / 'missing')
218 + cases = ('byte', 'directory', 'fifo', 'symlink', 'dangling', 'with_wal',
219 + 'with_shm', 'shm_directory', 'shm_fifo', 'wal_dangling', 'shm_dangling')
220 + for kind in cases:
221 + with self.subTest(kind=kind), tempfile.TemporaryDirectory() as root:
222 + db = Path(root) / subject.DATABASE
223 + db.parent.mkdir()
224 + journal = Path(str(db) + '-journal')
225 + wal = Path(str(db) + '-wal')
226 + shm = Path(str(db) + '-shm')
227 + def shell(*parts, **kwargs):
228 + if parts[0] == 'run-as':
229 + return subprocess.run(['sh', '-c', parts[-1]], cwd=root,
230 + capture_output=True, text=True, check=True, timeout=2).stdout
231 + return previous_shell(*parts, **kwargs)
232 + self.adb.shell = shell
233 + if kind == 'byte':
234 + journal.write_bytes(b'x')
235 + elif kind == 'directory':
236 + journal.mkdir()
237 + elif kind == 'fifo':
238 + subject.os.mkfifo(journal)
239 + elif kind in ('symlink', 'dangling'):
240 + target = Path(root) / 'empty-target'
241 + if kind == 'symlink':
242 + target.write_bytes(b'')
243 + journal.symlink_to(target if kind == 'symlink' else Path(root) / 'missing')
244 + elif kind in ('shm_directory', 'shm_fifo'):
245 + wal.write_bytes(b'')
246 + if kind == 'shm_directory':
247 + shm.mkdir()
248 else:
252 - journal.write_bytes(b'')
253 - (wal if kind == 'with_wal' else shm).write_bytes(b'')
254 - with self.assertRaisesRegex(subject.AcceptanceError, 'database_sidecar_present'):
255 - h._cold(subject.ORIGINAL)
256 - if journal.is_dir():
257 - journal.rmdir()
258 - elif journal.exists() or journal.is_symlink():
259 - journal.unlink()
260 - for extra in (wal, shm):
261 - if extra.is_dir():
262 - extra.rmdir()
263 - elif extra.exists() or extra.is_symlink():
264 - extra.unlink()
249 + subject.os.mkfifo(shm)
250 + elif kind in ('wal_dangling', 'shm_dangling'):
251 + (wal if kind == 'wal_dangling' else shm).symlink_to(Path(root) / 'missing')
252 + else:
253 + journal.write_bytes(b'')
254 + (wal if kind == 'with_wal' else shm).write_bytes(b'')
255 + with self.assertRaisesRegex(subject.AcceptanceError, 'database_sidecar_present'):
256 + h._cold(subject.ORIGINAL)
257
258 def test_actual_exited_sqlite_reader_leaves_empty_wal_cache_only(self):
259 source = self.directory / 'real-closed-reader.sqlite'