Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99d9f9e

Browse files
committed
update for smoke testing
1 parent 2e5f269 commit 99d9f9e

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

lib/core/testing.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
import os
2525
import sys
26+
import time
2627

28+
from lib.core.common import dataToStdout
29+
from lib.core.common import getConsoleWidth
2730
from lib.core.data import conf
2831
from lib.core.data import logger
2932
from lib.core.data import paths
@@ -34,6 +37,12 @@ def smokeTest():
3437
"""
3538
import doctest
3639
retVal = True
40+
count, length = 0, 0
41+
42+
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
43+
for file in files:
44+
length += 1
45+
3746
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
3847
for file in files:
3948
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
@@ -45,7 +54,8 @@ def smokeTest():
4554
module = sys.modules[path]
4655
except Exception, msg:
4756
retVal = False
48-
errMsg = "smoke test failed at importing module '%s' (%s):\n%s\n" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
57+
dataToStdout("\r")
58+
errMsg = "smoke test failed at importing module '%s' (%s):\n%s" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
4959
logger.error(errMsg)
5060
else:
5161
# Run doc tests
@@ -54,13 +64,16 @@ def smokeTest():
5464
if failure_count > 0:
5565
retVal = False
5666

57-
infoMsg = "smoke test "
67+
count += 1
68+
status = '%d/%d (%d%s)' % (count, length, round(100.0*count/length), '%')
69+
dataToStdout("\r[%s] [INFO] complete: %s" % (time.strftime("%X"), status))
70+
71+
dataToStdout("\r%s\r" % (" "*(getConsoleWidth()-1)))
5872
if retVal:
59-
infoMsg += "PASSED"
60-
logger.info(infoMsg)
73+
logger.info("smoke test result: passed")
6174
else:
62-
infoMsg += "FAILED"
63-
logger.error(infoMsg)
75+
logger.info("smoke test result: failed")
76+
6477
return retVal
6578

6679
def liveTest():

0 commit comments

Comments
 (0)