| 196 | |
| 197 | |
| 198 | def reset_fixture(root, backend, manifest, case): |
| 199 | repo = root / backend |
| 200 | shutil.copyfile(root / (backend + '-baseline.redb'), repo / '.atomic/atomic.redb') |
| 201 | for index, file in enumerate(manifest['files']): |
| 202 | path = repo / file['path'] |
| 203 | if path.exists() or path.is_symlink(): |
| 204 | if path.is_dir() and not path.is_symlink(): |
| 205 | raise ValueError('refusing to remove directory: ' + str(path)) |
| 206 | path.unlink() |
| 207 | if case == 'render': |
| 208 | path.parent.mkdir(parents=True, exist_ok=True) |
| 209 | content = (root / 'golden' / str(index)).read_bytes() |
| 210 | if file['mode'] == '120000': |
| 211 | path.symlink_to(os.fsdecode(content)) |
| 212 | else: |
| 213 | path.write_bytes(content) |
| 214 | path.chmod(0o755 if file['mode'] == '100755' else 0o644) |
| 215 | |
| 216 | |
| 217 | def meminfo(): |