()
| 182 | |
| 183 | |
| 184 | def main(): |
| 185 | if os.name != "nt": |
| 186 | print("PRECONDITION: native Windows is required") |
| 187 | return 2 |
| 188 | if len(sys.argv) != 2: |
| 189 | print("usage: python test_windows_update_handoff.py <codebase-memory-mcp.exe>") |
| 190 | return 2 |
| 191 | |
| 192 | source = pathlib.Path(sys.argv[1]).resolve() |
| 193 | if not source.is_file(): |
| 194 | print("PRECONDITION: binary not found: %s" % source) |
| 195 | return 2 |
| 196 | |
| 197 | work = pathlib.Path(tempfile.mkdtemp(prefix="cbm_win_update_")) |
| 198 | try: |
| 199 | env, cache = isolated_environment(work) |
| 200 | assert_update_hands_off_to_install_script(source, env, work) |
| 201 | assert_update_does_not_drain_active_session(source, env, cache, work) |
| 202 | print("\nGREEN: Windows update handoff contract honored.") |
| 203 | return 0 |
| 204 | except (GuardFailure, McpError, OSError, subprocess.SubprocessError) as exc: |
| 205 | print("\nRED: %s" % exc) |
| 206 | return 1 |
| 207 | finally: |
| 208 | shutil.rmtree(work, ignore_errors=True) |
| 209 | |
| 210 | |
| 211 | if __name__ == "__main__": |
no test coverage detected