Files
DroidDeck/tools/tests/test_session_step_time.py
3331edf265 perf: session log step times carry milliseconds (#993)
The == STEP lines in session.log now read HH:MM:SS.mmm, so the setup
steps before Steam starts can be timed; with whole seconds most of them
showed the same time.

Co-authored-by: ovurrsl <ovurrsl@users.noreply.github.com>
Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
2026-10-22 10:40:48 -04:00

28 lines
1.1 KiB
Python

import re
import subprocess
import unittest
from pathlib import Path
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
def step_function():
match = re.search(r"^step\(\) \{.*\}$", SESSION.read_text(), re.M)
return match.group(0)
class SessionStepTimeTest(unittest.TestCase):
def test_a_step_line_carries_milliseconds_before_its_text(self):
out = subprocess.run(["bash", "-c", step_function() + "\nstep starting the Steam client"],
capture_output=True, text=True, timeout=30).stdout.strip()
self.assertRegex(out, r"^== STEP \d{2}:\d{2}:\d{2}\.\d{3} starting the Steam client$")
def test_the_text_after_the_first_space_is_the_step_name(self):
out = subprocess.run(["bash", "-c", step_function() + "\nstep checking the Steam client"],
capture_output=True, text=True, timeout=30).stdout.strip()
self.assertEqual("checking the Steam client", out.removeprefix("== STEP ").split(" ", 1)[1])
if __name__ == "__main__":
unittest.main()