dovetail tool: show progress during executing test cases 79/33179/1
authorxudan <xudan16@huawei.com>
Mon, 10 Apr 2017 08:15:03 +0000 (08:15 +0000)
committerxudan <xudan16@huawei.com>
Mon, 10 Apr 2017 08:15:03 +0000 (08:15 +0000)
JIRA: DOVETAIL-159

1. It takes long time to execute test cases that most of users think it hangs there,
   so a progress is needed to show the test is running.
2. add dynamic progress during execution
3. it' s a fake progress only showing the test is alive,
   not to show the percentage of completion.

Change-Id: I0294659f79e8e09d1bcdd36d8f391d933e35b635
Signed-off-by: xudan <xudan16@huawei.com>
dovetail/utils/dovetail_utils.py

index e72a37c..766bb64 100644 (file)
@@ -48,9 +48,14 @@ def exec_cmd(cmd, logger=None, exit_on_error=False, info=False,
     p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT)
     stdout = ''
+    count = 1
+    DEBUG = os.getenv('DEBUG')
     for line in iter(p.stdout.readline, b''):
         exec_log(verbose, logger, line.strip(), level, True)
         stdout += line
+        if DEBUG is None or DEBUG.lower() != "true":
+            show_progress_bar(count)
+            count += 1
     stdout = stdout.strip()
     returncode = p.wait()
     p.stdout.close()
@@ -144,5 +149,5 @@ def show_progress_bar(length):
     length %= max_len
     sys.stdout.write('Running ' + ' ' * max_len + '\r')
     sys.stdout.flush()
-    sys.stdout.write('Running ' + '=' * length + '>' + '\r')
+    sys.stdout.write('Running ' + '.' * length + '\r')
     sys.stdout.flush()