diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 39ee3c8a6..236ff8598 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -3,7 +3,7 @@ set -u export HOME=${HOME:-/root} mode=${1:-desktop} shift || true -step() { echo "== STEP $(date -u +%H:%M:%S) $*"; } +step() { echo "== STEP $(date -u +%H:%M:%S.%3N) $*"; } steam_setup_failed() { echo "== steam: the Steam client could not be set up (status $1)" [ -z "${BL_STEAM_EXIT_FILE:-}" ] || printf '%s\n' "$1" > "$BL_STEAM_EXIT_FILE" diff --git a/tools/tests/test_session_step_time.py b/tools/tests/test_session_step_time.py new file mode 100644 index 000000000..2622e34cc --- /dev/null +++ b/tools/tests/test_session_step_time.py @@ -0,0 +1,27 @@ +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()