nixos/test-driver: use ipython via ptpython

Closes #180089

I realized that the previous commits relying on `sys.exit` for dealing
with `MachineError`/`RequestedAssertionFailed` exit the interactive
session which is kinda bad.

This patch uses the ipython driver: it seems to have equivalent features
such as auto-completion and doesn't stop on SystemExit being raised.

This also fixes other places where this happened such as things calling
`log.error` on the CompositeLogger.

Changed files
+5 -5
nixos
lib
test-driver
src
test_driver
+1
nixos/lib/test-driver/default.nix
···
colorama
junit-xml
ptpython
+
ipython
]
++ extraPythonPackages python3Packages;
+4 -5
nixos/lib/test-driver/src/test_driver/__init__.py
···
import time
from pathlib import Path
-
import ptpython.repl
+
import ptpython.ipython
from test_driver.driver import Driver
from test_driver.logger import (
···
if args.interactive:
history_dir = os.getcwd()
history_path = os.path.join(history_dir, ".nixos-test-history")
-
ptpython.repl.embed(
-
driver.test_symbols(),
-
{},
+
ptpython.ipython.embed(
+
user_ns=driver.test_symbols(),
history_filename=history_path,
-
)
+
) # type:ignore
else:
tic = time.time()
driver.run_tests()