"""Native Qt tests on a private Windows desktop without switching desktops.""" import argparse import ctypes as ct from ctypes import wintypes as w from dataclasses import replace import hashlib import json import os from pathlib import Path import shutil import struct import subprocess import sys import tempfile from time import monotonic, sleep from uuid import uuid4 from zipfile import ZipFile ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) USER = ct.WinDLL("user32", use_last_error=True) KERNEL = ct.WinDLL("kernel32", use_last_error=True) def bind(dll, name, result, *args): fn = getattr(dll, name) fn.restype, fn.argtypes = result, args return fn class Startup(ct.Structure): _fields_ = [("cb", w.DWORD), ("reserved", w.LPWSTR), ("desktop", w.LPWSTR), ("title", w.LPWSTR)] + [(key, w.DWORD) for key in ( "x", "y", "width", "height", "cols", "rows", "fill", "flags")] + [ ("show", w.WORD), ("reserved2_size", w.WORD), ("reserved2", ct.c_void_p), ("stdin", w.HANDLE), ("stdout", w.HANDLE), ("stderr", w.HANDLE), ] class ProcessInfo(ct.Structure): _fields_ = [("process", w.HANDLE), ("thread", w.HANDLE), ("pid", w.DWORD), ("tid", w.DWORD)] def start_isolated(argv, desktop_name, timeout=210): create_desktop = bind(USER, "CreateDesktopW", w.HANDLE, w.LPCWSTR, w.LPCWSTR, ct.c_void_p, w.DWORD, w.DWORD, ct.c_void_p) close_desktop = bind(USER, "CloseDesktop", w.BOOL, w.HANDLE) desktop = create_desktop(desktop_name, None, None, 0, 0x01ff, None) if not desktop: raise ct.WinError(ct.get_last_error()) close = bind(KERNEL, "CloseHandle", w.BOOL, w.HANDLE) create = bind(KERNEL, "CreateProcessW", w.BOOL, w.LPCWSTR, w.LPWSTR, ct.c_void_p, ct.c_void_p, w.BOOL, w.DWORD, ct.c_void_p, w.LPCWSTR, ct.POINTER(Startup), ct.POINTER(ProcessInfo)) wait = bind(KERNEL, "WaitForSingleObject", w.DWORD, w.HANDLE, w.DWORD) status = bind(KERNEL, "GetExitCodeProcess", w.BOOL, w.HANDLE, ct.POINTER(w.DWORD)) terminate = bind(KERNEL, "TerminateProcess", w.BOOL, w.HANDLE, w.UINT) launch = Startup() launch.cb, launch.desktop = ct.sizeof(Startup), f"WinSta0\\{desktop_name}" process = ProcessInfo() try: command = ct.create_unicode_buffer(subprocess.list2cmdline(argv)) if not create(str(argv[0]), command, None, None, False, 0x08000000, None, str(ROOT), ct.byref(launch), ct.byref(process)): raise ct.WinError(ct.get_last_error()) try: if wait(process.process, timeout * 1000): terminate(process.process, 30) wait(process.process, 10_000) raise TimeoutError("Isolated Windows GUI test exceeded its time allowance") exit_code = w.DWORD() if not status(process.process, ct.byref(exit_code)): raise ct.WinError(ct.get_last_error()) return exit_code.value finally: close(process.thread) close(process.process) finally: close_desktop(desktop) def verify_desktop(expected): current_tid = bind(KERNEL, "GetCurrentThreadId", w.DWORD)() desk = bind(USER, "GetThreadDesktop", w.HANDLE, w.DWORD)(current_tid) get = bind(USER, "GetUserObjectInformationW", w.BOOL, w.HANDLE, ct.c_int, ct.c_void_p, w.DWORD, ct.POINTER(w.DWORD)) buf, required = ct.create_unicode_buffer(256), w.DWORD() if not get(desk, 2, buf, ct.sizeof(buf), ct.byref(required)) or buf.value != expected: raise RuntimeError("Application test is not on the requested private desktop") return buf.value def window_process(hwnd): pid = w.DWORD() thread = bind(USER, "GetWindowThreadProcessId", w.DWORD, w.HWND, ct.POINTER(w.DWORD))(hwnd, ct.byref(pid)) return thread, pid.value def run_frozen(exe, profile_root, output): from arm.config import ConfigStore, Settings, Target from arm.version import NAME, VERSION # Separate settings and logs for each run. Existing profiles stay untouched. appdir = profile_root / NAME env = dict(os.environ, LOCALAPPDATA=str(profile_root)) for key in ("PYTHONPATH", "QT_QPA_PLATFORM", "QT_SCALE_FACTOR"): env.pop(key, None) config = ConfigStore(appdir / "settings.json") if not config.path.is_file(): config.save(Settings(minimized=False, mode="Composite", targets=[ Target(name="Saved test profile", host="127.0.0.1", enabled=False, credential="test-reference") ])) original = config.path.read_bytes() find = bind(USER, "FindWindowW", w.HWND, w.LPCWSTR, w.LPCWSTR) visible = bind(USER, "IsWindowVisible", w.BOOL, w.HWND) post = bind(USER, "PostMessageW", w.BOOL, w.HWND, w.UINT, w.WPARAM, w.LPARAM) post_thread = bind(USER, "PostThreadMessageW", w.BOOL, w.DWORD, w.UINT, w.WPARAM, w.LPARAM) send = bind(USER, "SendMessageTimeoutW", ct.c_size_t, w.HWND, w.UINT, w.WPARAM, w.LPARAM, w.UINT, w.UINT, ct.POINTER(ct.c_size_t)) for iteration in range(2): with subprocess.Popen([str(exe)], env=env, cwd=exe.parent) as proc: try: deadline, hwnd = monotonic() + 25, None while monotonic() < deadline and proc.poll() is None: found = find(None, NAME) if found: thread, pid = window_process(found) if pid == proc.pid and visible(found): hwnd = found break sleep(.15) assert hwnd, f"Frozen application did not open its native window, exit {proc.poll()}" sleep(2.5) replacement = find(None, NAME) if replacement and window_process(replacement)[1] == proc.pid: hwnd = replacement assert proc.poll() is None, f"Frozen application exited before close, code {proc.returncode}" icon = ct.c_size_t() assert send(hwnd, 0x7f, 1, 0, 2, 2000, ct.byref(icon)) and icon.value, "Missing window icon" if not post(hwnd, 0x10, 0, 0): raise ct.WinError(ct.get_last_error()) sleep(.45) assert proc.poll() is None and not visible(hwnd), "Window close should leave tray running" assert post_thread(thread, 0x12, 0, 0), "Posting WM_QUIT failed" assert proc.wait(10) == 0 finally: if proc.poll() is None: proc.terminate() proc.wait(8) assert config.path.read_bytes() == original data = (appdir / "arm.log").read_text(encoding="utf-8") assert data.count(f"{NAME} {VERSION} starting") == iteration + 1 assert data.count(f"{NAME} stopped") == iteration + 1 assert all(word in data for word in ("Initializing provider CPU", "Initializing provider GPU")) assert " ERROR " not in data, data output["frozen_launches"] = 2 output["frozen_version"] = VERSION def verify_executable(path, version): import pefile from arm.branding import COPYRIGHT, ICON_SIZES, PUBLISHER pe = pefile.PE(str(path)) try: assert pe.FILE_HEADER.Machine == 0x8664 fields = next(node.StringTable[0].entries for block in pe.FileInfo for node in block if hasattr(node, "StringTable")) assert fields[b"CompanyName"].decode().strip() == PUBLISHER assert fields[b"LegalCopyright"].decode().strip() == COPYRIGHT assert fields[b"ProductVersion"].decode().strip() == version group = next(entry for entry in pe.DIRECTORY_ENTRY_RESOURCE.entries if entry.id == 14) sizes = set() for ident in group.directory.entries: ref = ident.directory.entries[0].data.struct data = pe.get_data(ref.OffsetToData, ref.Size) count = struct.unpack_from(" initial_size.height() assert hover.update_banner.label.text() == available capture(hover, "update-hover.png") session.select_machine(ALL, LOCAL) session.hover.pin(True, LOCAL) assert hover.update_banner.isVisible() and hover.selected_machine == ALL session.hover.pin(False) session.select_machine(LOCAL, LOCAL) hover.hide() session.open_expanded() assert expanded.update_banner.isVisible() and expanded.monitor_visible capture(expanded, "update-expanded.png") menu.popup(QPoint(20, 20)) capture(menu, "update-tray-menu.png") menu.hide() menu.update.trigger() assert expanded.tabs.currentWidget() == session.about_page and expanded.update_banner.isVisible() capture(expanded, "update-about.png") with patch.object(update.client, "open", return_value=Response(PACKAGE)): update.client.source["public_key"], original_key = fixture.public, update.client.source["public_key"] try: update.download_now() wait_for(lambda: update.job is None) assert update.phase is Phase.READY and update.downloaded.is_file() update.defer_install() assert menu.update.text() == f"Update Ready to Install: {NEW}" assert update.restore()[1][1] == update.downloaded finally: update.client.source["public_key"] = original_key update.downloaded.unlink() update.downloaded = None with patch.object(update.client, "check", return_value=rejected): update.check_now() wait_for(lambda: update.job is None) assert not menu.update.isVisible() and expanded.update_banner.isHidden() assert hover.popup_size() == initial_size expanded.close() finally: fixture.doCleanups() results["verified_shared_update_notices"] = "Verified, ready, rejected, deferred and duplicate notification states" def verify_hover_version(session, remote, results, captures): from arm.model import ALL, LOCAL from arm.version import VERSION original = session.settings hover = session.popup scale = round(hover.devicePixelRatioF() * 100) modes = ( ("individual-unpinned", LOCAL, LOCAL, False), ("individual-pinned", remote, remote, True), ("all-systems-unpinned", ALL, LOCAL, False), ("all-systems-pinned", ALL, remote, True), ) try: for theme in ("Light", "Dark"): session.apply(replace(original, theme=theme)) for name, selection, anchor, pinned in modes: session.hover.pin(False) session.select_machine(selection, anchor) session.hover.pin(pinned, anchor) session.qt.processEvents() label = hover.version_label rect = label.geometry() assert hover.isVisible() and hover.pinned == pinned assert hover.selected_machine == selection and session.hover.anchor == anchor assert label.isVisible() and label.text() == VERSION assert rect.bottom() < hover.machine.geometry().top() assert rect.right() == hover.width() - hover.layout().contentsMargins().right() - 1 assert label.fontMetrics().horizontalAdvance(VERSION) <= rect.width() assert hover.rect().contains(rect) if captures and theme == ("Light" if scale > 100 else "Dark"): capture_native_window(int(hover.winId()), captures / f"hover-{name}-{scale}.png") finally: session.hover.pin(False) hover.hide() session.apply(original) results["hover_version"] = {"version": VERSION, "scale_percent": scale, "themes": ["Light", "Dark"], "views": [row[0] for row in modes]} def evaluate_app(work, results, short=False, captures=None): import psutil from PySide6.QtCore import QEventLoop, QTimer from PySide6.QtGui import QGuiApplication from PySide6.QtWidgets import QApplication, QSystemTrayIcon from arm.application import Application from arm.branding import set_windows_identity from arm.config import STATIC_TRAY_MODE, ConfigStore, Settings, Target from arm.dialogs import ConnectionsDialog, SettingsDialog from arm.model import ALL, LOCAL, NETWORK, TOTAL, Connection, RESOURCES from arm.providers.ssh import update_host_key from ssh_fixture import Fixture, SECRET from contextlib import ExitStack from threading import Event from unittest.mock import patch assert set_windows_identity() == 0 app = QApplication([]) assert QGuiApplication.platformName() == "windows" app.setQuitOnLastWindowClosed(False) root = work / "app" session = Application(app, root) process = psutil.Process() results["platform"] = app.platformName() results["qt_reports_system_tray"] = QSystemTrayIcon.isSystemTrayAvailable() results["scale"] = [screen.devicePixelRatio() for screen in app.screens()] def wait_for(condition, seconds=8): loop = QEventLoop() timer = QTimer() timer.setInterval(100) def check(): if condition(): loop.quit() if condition(): return timer.timeout.connect(check) timer.start() QTimer.singleShot(seconds * 1000, loop.quit) loop.exec() timer.stop() assert condition(), "Expected condition did not arrive" def measure(label, seconds=12): usage = process.cpu_times() started = monotonic() loop = QEventLoop() QTimer.singleShot(round(seconds * 1000), loop.quit) loop.exec() ended = process.cpu_times() cpu = 100 * (ended.user + ended.system - usage.user - usage.system) / (monotonic() - started) results.setdefault("performance", {})[label] = { "cpu_percent_one_logical": round(cpu, 3), "cpu_percent_machine": round(cpu / (psutil.cpu_count() or 1), 3), "rss_mib": round(process.memory_info().rss / 2**20, 2), "seconds": seconds, } try: assert session.icons[LOCAL].icon().cacheKey() == session.brand_icon.cacheKey() resources = ("cpu.util", "gpu.util", "ram.util", "gpu.vram_pct", "disk.total", "net.total") wait_for(lambda: all((r := session.collectors.history.latest(LOCAL, TOTAL, key)) and r.valid for key in resources), 12) results["local_resources"] = {key: round(session.collectors.history.latest(LOCAL, TOTAL, key).value, 2) for key in resources} results["gpu_devices"] = [d.name for d in session.collectors.devices[LOCAL].values() if d.kind == "gpu"] results["per_gpu"] = { device.name: { metric: round(item.value, 2) for metric in ("gpu.util", "gpu.vram_total", "gpu.vram_used", "gpu.temperature", "gpu.power") if (item := session.collectors.history.latest(LOCAL, device.identifier, metric)) and item.valid } for device in session.collectors.devices[LOCAL].values() if device.kind == "gpu" } results["physical_disks"] = [d.name for d in session.collectors.devices[LOCAL].values() if d.kind == "disk"] if not short: measure("tray") results["registered_icon_rect"] = bool(session.icons[LOCAL].geometry().isValid()) session.render() assert session.icons[LOCAL].icon().cacheKey() != session.brand_icon.cacheKey() verify_branding(session, results, captures) menu = session.menus[LOCAL] from arm.update_client import Check update = session.about_page.updates lookup = next(action for action in menu.actions() if action.text() == "Check for Updates") entered, release_check = Event(), Event() def slow_check(version, kind): entered.set() assert release_check.wait(10) return Check(None, None, ()) wait_for(lambda: update.job is None) with patch.object(update.client, "check", side_effect=slow_check): try: sample = session.collectors.last[LOCAL] lookup.trigger() assert session.expanded.tabs.currentWidget() is session.about_page wait_for(entered.is_set) assert not update.buttons["Check for Updates"].isEnabled() wait_for(lambda: session.collectors.last[LOCAL] > sample) finally: release_check.set() wait_for(lambda: update.job is None) assert update.fields["Latest published"].text() == "No public releases" assert "UTC" in update.fields["Last successful check"].text() session.expanded.close() verify_update_notices(session, wait_for, results, captures) results["asynchronous_update_check_with_live_telemetry"] = True modes = {} for mode in ("Stacked", STATIC_TRAY_MODE, "Overlay", "Composite"): menu.modes[mode].trigger() assert menu.modes[mode].isChecked() and session.settings.mode == mode qr = session.icons[LOCAL].icon().pixmap(32, 32).toImage() modes[mode] = hashlib.sha256(bytes(qr.bits())).hexdigest()[:12] assert (session.icons[LOCAL].icon().cacheKey() == session.brand_icon.cacheKey()) == (mode == STATIC_TRAY_MODE) assert len(set(modes.values())) == 4, modes results["rendered_modes"] = modes assert ConfigStore(root / "settings.json").load().mode == "Composite" menu.pin.trigger() assert session.popup.isVisible() and session.popup.pinned assert sum(card.isVisible() for card in session.popup.cards.values()) == len(RESOURCES) wait_for(lambda: session.popup.frameGeometry().isValid()) if not short: measure("pinned_popup") session.popup.pin.click() assert not session.popup.pinned session.popup.hide() session.open_expanded(LOCAL) assert session.expanded.isVisible() and session.expanded.table.rowCount() > 20 assert session.expanded.device.count() > 10 assert app.primaryScreen().availableGeometry().contains(session.popup.frameGeometry()) if not short: measure("expanded") session.expanded.close() assert not session.expanded.isVisible() and session.icons[LOCAL].isVisible() if not short: prefs, connections = SettingsDialog(session), ConnectionsDialog(session) prefs.show() connections.show() assert prefs.isVisible() and connections.isVisible() assert prefs.tabs.count() == 7 and connections.table.rowCount() == 0 prefs.close() connections.close() prefs.deleteLater() connections.deleteLater() with ExitStack() as stack: servers = [stack.enter_context(Fixture()) for _ in range(2)] targets = [] for i, server in enumerate(servers, 1): target = Target(name=f"Loopback {i}", host="127.0.0.1", port=server.port, username="tester", interval=2, timeout=6, tray=True) update_host_key(session.hosts, f"[127.0.0.1]:{server.port}", server.key) session.save_target(target, SECRET, False) targets.append(target) try: wait_for(lambda: session.dashboard.state(target.identifier) == Connection.ONLINE, 15) except AssertionError as exc: raise AssertionError(f"SSH fixture {i}: {server.connections} TCP sessions, " f"{len(server.commands)} commands, {server.samples} frames, " f"{session.dashboard.state(target.identifier)}") from exc assert "Connected" in menu.remote_entries[target.identifier].text() menu.remote_entries[target.identifier].trigger() assert session.popup.selected_machine == target.identifier assert session.scopes() == [LOCAL] menu.local.trigger() session.popup.hide() if i == 1 and not short: measure("one_loopback_ssh") if not short: measure("two_loopback_ssh") from arm.graphs import tray_icon primary, other = (target.identifier for target in targets) prefs = SettingsDialog(session) tray_machine = prefs.controls["tray_machine"].__self__ assert [tray_machine.itemData(i) for i in range(tray_machine.count())] == [LOCAL, primary, other] tray_machine.setCurrentIndex(tray_machine.findData(primary)) prefs.save() prefs.deleteLater() assert session.scopes() == [primary] and session.popup.selected_machine == LOCAL menu = session.menus[primary] for select, expected in ((menu.all, ALL), (menu.remote_entries[other], other), (menu.local, LOCAL)): select.trigger() with patch("arm.application.tray_icon", wraps=tray_icon) as draw: session.render() assert [call.args[1] for call in draw.call_args_list] == [primary] assert session.popup.selected_machine == session.expanded.selected_machine == expected assert select.isChecked() if expected == ALL: for view in (session.popup, session.expanded): assert set(view.sections) == {LOCAL, primary, other} assert all(set(section.cards) == set(RESOURCES) for section in view.sections.values()) menu.all.trigger() history = session.collectors.history wait_for(lambda: all( (reading := history.latest(machine, TOTAL, direction)) and reading.valid and reading.value > 0 for machine in (primary, other) for direction in NETWORK )) session.popup.refresh() for machine in (primary, other): card = session.popup.sections[machine].cards["net"] for direction, (points, _) in zip(NETWORK, card.plot.data[0]): latest = history.latest(machine, TOTAL, direction) assert any(stamp == latest.timestamp and value > 0 for stamp, value in points if value is not None) assert card.direction_labels[direction].text().startswith(NETWORK[direction][0] + ":") results["independent_network_directions"] = True session.popup.interval.setCurrentIndex(session.popup.interval.findData(300)) session.popup.hide() menu.defaultAction().trigger() assert session.expanded.selected_machine == ALL session.expanded.close() session.hover.show(primary) assert session.popup.selected_machine == ALL and session.popup.span == 300 saved = ConfigStore(root / "settings.json").load() assert (saved.hover_machine, saved.hover_range, saved.tray_machine) == (ALL, 300, primary) session.popup.hide() session.apply(replace(session.settings, separate_tray_icons=True, persistent=True)) assert set(session.icons) == {LOCAL, *(target.identifier for target in targets)} verify_hover_version(session, primary, results, captures) with patch("arm.application.tray_icon", wraps=tray_icon) as draw: session.render() assert {call.args[1] for call in draw.call_args_list} == {LOCAL, primary, other} assert draw.call_count == 3 results["independent_tray_and_monitor"] = "Local plus two SSH targets, six graphs each, three independent icon sources" results["loopback_frame_counts"] = [server.samples for server in servers] for target in targets: session.collectors.disconnect(target.identifier) assert all(session.dashboard.state(t.identifier) == Connection.OFFLINE for t in targets) assert session.popup.selected_machine == ALL session.apply(replace(session.settings, separate_tray_icons=False, persistent=False)) if not short: measure("disconnected_remotes") assert set(session.icons) == {primary} for target in list(session.settings.targets): session.remove_target(target) assert set(session.icons) == {LOCAL} and session.popup.selected_machine == ALL exit_action = next(action for action in next(iter(session.menus.values())).actions() if action.text().startswith("Exit Adaptive Resource Monitor")) QTimer.singleShot(0, exit_action.trigger) assert app.exec() == 0 finally: for target in list(session.settings.targets): session.remove_target(target) session.close() assert not session.collectors.workers data = (root / "arm.log").read_text(encoding="utf-8") assert "Adaptive Resource Monitor stopped" in data and " ERROR " not in data, data restart_root = work / "restart" store = ConfigStore(restart_root / "settings.json") stored_targets = [replace(target, enabled=False, credential="test-reference") for target in saved.targets] store.save(replace(saved, targets=stored_targets)) for legacy in (False, True): if legacy: source = json.loads(store.path.read_text(encoding="utf-8")) source.update(hover_machine="@peak", default_machine="@peak") store.path.write_text(json.dumps(source), encoding="utf-8") startup = replace(store.load(), update_startup=True, update_interval=4) if legacy: source["update_startup"] = True source["update_interval"] = 4 store.path.write_text(json.dumps(source), encoding="utf-8") else: store.save(startup) from arm.update_client import ReleaseClient with patch.object(ReleaseClient, "check", return_value=Check(None, None, ())) as check: reopened = Application(app, restart_root) try: assert reopened.scopes() == [primary] assert reopened.popup.selected_machine == reopened.expanded.selected_machine == ALL assert reopened.popup.span == 300 and not reopened.popup.pinned assert reopened.settings.targets == stored_targets panel = reopened.about_page.updates assert panel.periodic.isActive() and panel.periodic.interval() == 4 * 3_600_000 wait_for(lambda: check.called and panel.job is None) assert panel.fields["Latest published"].text() == "No public releases" finally: reopened.close() app.processEvents() results["restored_monitor_and_tray"] = "New and legacy settings restored All Systems at five minutes with a separate tray source" results["startup_update_and_periodic_timer"] = True def child(args): result = {"desktop": verify_desktop(args.desktop)} try: if args.package: validate_packages(args.package, args.work, result, args.upgrade_from, args.captures, args.portable_only) else: evaluate_app(args.work, result, args.short, args.captures) except Exception: import traceback result["traceback"] = traceback.format_exc() log = args.work / "app" / "arm.log" if log.is_file(): result["application_log"] = log.read_text(encoding="utf-8").splitlines()[-35:] for name in ("portable-profile", "installed-profile"): log = args.work / name / "Adaptive Resource Monitor" / "arm.log" if log.is_file(): result[name] = log.read_text(encoding="utf-8").splitlines()[-35:] return 1 finally: (args.work / "result.json").write_text(json.dumps(result, indent=2), encoding="utf-8") return 0 def parent(args): desktop = f"ARM_Validation_{uuid4().hex[:10]}" with tempfile.TemporaryDirectory(prefix="arm-desktop-test-") as directory: work = Path(directory) command = [sys.executable, str(Path(__file__).resolve()), "--desktop", desktop, "--work", str(work)] if args.package: command.extend(("--package", str(args.package.resolve()))) if args.portable_only: command.append("--portable-only") if args.upgrade_from: command.extend(("--upgrade-from", str(args.upgrade_from.resolve()))) if args.captures: command.extend(("--captures", str(args.captures.resolve(strict=True)))) if args.short: command.append("--short") exit_code = start_isolated(command, desktop) data = work / "result.json" if data.is_file(): print(data.read_text(encoding="utf-8")) elif exit_code == 0: raise RuntimeError("Isolated Windows process did not publish test evidence") staged = sum(path.stat().st_size for path in work.rglob("*") if path.is_file()) print(f"Isolated Windows test exit {exit_code}. Removed {staged:,} bytes of temporary QA data.") return exit_code if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--desktop") parser.add_argument("--work", type=Path) parser.add_argument("--package", type=Path) parser.add_argument("--portable-only", action="store_true") parser.add_argument("--upgrade-from", type=Path) parser.add_argument("--captures", type=Path) parser.add_argument("--short", action="store_true") args = parser.parse_args() if args.desktop: raise SystemExit(child(args)) raise SystemExit(parent(args))