diff --git a/autotest/autotest.py b/autotest/autotest.py index a6cf7e6a..091bff24 100755 --- a/autotest/autotest.py +++ b/autotest/autotest.py @@ -5,6 +5,7 @@ import os import re import subprocess import sys +import time logging.basicConfig(level=logging.DEBUG) @@ -94,7 +95,20 @@ except Exception as e: keymaps = { "^C": "\x03" } +def wait_for_success(): + secs, timeout = 0, 30 + while secs <= timeout: + time.sleep(1) + output = [x for x in subprocess.check_output(["tmux", "capture-pane", "-p"]).split("\n") if x] + if output[-1] == "$": + return True + else: + print(".") + secs += 1 + while True: + # Send a form feed to clear screen (while preserving scrollback) + print("\033[2J") with open("nextstep","w") as f: f.write(str(i)) slide, snippet, method, data = actions[i] @@ -113,6 +127,11 @@ while True: if method == "bash": data += "\n" subprocess.check_call(["tmux", "send-keys", "{}".format(data)]) + while not wait_for_success(): + while raw_input("WARNING /!\ Command timed out. Continue anyway? ('n' to wait) ") == 'n': + if wait_for_success(): + break + break else: print "DO NOT KNOW HOW TO HANDLE {} {!r}".format(method, data) i += 1