Unverified Commit e2b3517f authored by Maximilian Bosch's avatar Maximilian Bosch
Browse files

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.
parent d587d569
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ python3Packages.buildPythonApplication {
      colorama
      junit-xml
      ptpython
      ipython
    ]
    ++ extraPythonPackages python3Packages;

+4 −5
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import os
import time
from pathlib import Path

import ptpython.repl
import ptpython.ipython

from test_driver.driver import Driver
from test_driver.logger import (
@@ -136,11 +136,10 @@ def main() -> None:
        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()