[Libreoffice-commits] dev-tools.git: 6 commits - uitest/mass-testing
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Apr 22 20:41:00 UTC 2019
uitest/mass-testing/calc.py | 2
uitest/mass-testing/run.py | 150 ++++++++++++++++++++++++++------------------
2 files changed, 94 insertions(+), 58 deletions(-)
New commits:
commit f631db9e5e83706ed2678fb4db737700dd623a1b
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 22:38:28 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:38:28 2019 +0200
mass-uitesting: Get focus after closing preview
otherwise, it fails at times
diff --git a/uitest/mass-testing/calc.py b/uitest/mass-testing/calc.py
index 7aaa190..7217c3a 100755
--- a/uitest/mass-testing/calc.py
+++ b/uitest/mass-testing/calc.py
@@ -88,6 +88,8 @@ class massTesting(UITestCase):
self.xUITest.executeCommand(".uno:PrintPreview") #open print preview
self.xUITest.executeCommand(".uno:ClosePreview") # close print preview
+ self.xUITest.getTopFocusWindow()
+
self.ui_test.close_doc()
def test_hide_column_and_undo(self):
commit 7eeaee26607180f22b4a374c9ee6747a6ec15401
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 22:33:07 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:33:07 2019 +0200
mass-uitesting: ignore empty lines
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index db5aa0a..20bb101 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -143,24 +143,27 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
importantInfo = ''
isFailure = False
for line in outputLines:
- line = line.decode("utf-8")
+ line = line.decode("utf-8").strip()
+
+ if not line:
+ continue
if isDebug:
print(line)
- if 'skipped' == line.strip().lower():
+ if 'skipped' == line.lower():
logger.info("SKIP: " + fileName + " : " + importantInfo)
results['skip'] += 1
break
- if 'Execution time' in line.strip():
+ if 'Execution time' in line:
- importantInfo = line.strip().split('for ')[1]
+ importantInfo = line.split('for ')[1]
#Extend timeout
timeout = time.time() + timeoutTime
- elif importantInfo and 'error' == line.strip().lower() or 'fail' == line.strip().lower():
+ elif importantInfo and 'error' == line.lower() or 'fail' == line.lower():
isFailure = True
if importantInfo:
commit 38a10c2f739f4630317acbdadf53905fd9d6e0e2
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 22:22:21 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:22:21 2019 +0200
mass-uitesting: use a variable here
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index 98304ed..db5aa0a 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -120,8 +120,9 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
# Do not block on process.stdout
fcntl.fcntl(process.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
- # Kill the process if the test can't be executed in 20 seconds
- timeout = time.time() + 20
+ # Kill the process if the test can't be executed in 'timeoutTime' seconds
+ timeoutTime = 20
+ timeout = time.time() + timeoutTime
while True:
time.sleep(1)
@@ -157,7 +158,7 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
importantInfo = line.strip().split('for ')[1]
#Extend timeout
- timeout = time.time() + 20
+ timeout = time.time() + timeoutTime
elif importantInfo and 'error' == line.strip().lower() or 'fail' == line.strip().lower():
isFailure = True
commit c4571964fd2814490d4539cb9ba305a0611da41a
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 22:15:59 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:15:59 2019 +0200
mass-uitesting: handle failures correctly
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index 5408fcf..98304ed 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -122,11 +122,9 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
# Kill the process if the test can't be executed in 20 seconds
timeout = time.time() + 20
- isFailure = False
while True:
time.sleep(1)
-
if time.time() > timeout:
logger.info("TIMEOUT: " + fileName)
results['timeout'] += 1
@@ -142,6 +140,7 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
pass
importantInfo = ''
+ isFailure = False
for line in outputLines:
line = line.decode("utf-8")
@@ -161,14 +160,16 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
timeout = time.time() + 20
elif importantInfo and 'error' == line.strip().lower() or 'fail' == line.strip().lower():
- logger.info("FAIL: " + fileName + " : " + importantInfo)
- results['fail'] += 1
isFailure = True
- # No error found between the Execution time line and the end of stdout
- if importantInfo and not isFailure:
- logger.info("PASS: " + fileName + " : " + str(importantInfo))
- results['pass'] += 1
+ if importantInfo:
+ if isFailure:
+ logger.info("FAIL: " + fileName + " : " + importantInfo)
+ results['fail'] += 1
+ else:
+ # No error found between the Execution time line and the end of stdout
+ logger.info("PASS: " + fileName + " : " + str(importantInfo))
+ results['pass'] += 1
if process.poll() is not None:
break
commit a31d3edc854f6f5164ee433d79608a5b4801c4fc
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 22:04:50 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:06:33 2019 +0200
mass-uitesting: Add resume parameter
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index c266ff2..5408fcf 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -62,7 +62,7 @@ def get_file_names(component, filesPath):
return auxNames
-def run_tests_and_get_results(liboPath, listFiles, isDebug):
+def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
#Create directory for the user profile
profilePath = '/tmp/libreoffice/4/'
@@ -84,19 +84,21 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
#Keep track of the files run
filesRun = {}
- pklFile = './logs/' + component + '.pkl'
- if os.path.exists(pklFile):
- with open(pklFile, 'rb') as pickle_in:
- filesRun = pickle.load(pickle_in)
+ if isResume:
+ pklFile = './logs/' + component + '.pkl'
+ if os.path.exists(pklFile):
+ with open(pklFile, 'rb') as pickle_in:
+ filesRun = pickle.load(pickle_in)
- if sourceHash not in filesRun:
- filesRun[sourceHash] = []
+ if sourceHash not in filesRun:
+ filesRun[sourceHash] = []
for fileName in listFiles:
- if fileName in filesRun[sourceHash]:
- print("SKIP: " + fileName)
- continue
+ if isResume:
+ if fileName in filesRun[sourceHash]:
+ print("SKIP: " + fileName)
+ continue
# Replace the profile file with
# 1. DisableMacrosExecution = True
@@ -124,6 +126,7 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
while True:
time.sleep(1)
+
if time.time() > timeout:
logger.info("TIMEOUT: " + fileName)
results['timeout'] += 1
@@ -139,7 +142,6 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
pass
importantInfo = ''
-
for line in outputLines:
line = line.decode("utf-8")
@@ -171,11 +173,11 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
if process.poll() is not None:
break
+ if isResume:
+ filesRun[sourceHash].append(fileName)
- filesRun[sourceHash].append(fileName)
-
- with open(pklFile, 'wb') as pickle_out:
- pickle.dump(filesRun, pickle_out)
+ with open(pklFile, 'wb') as pickle_out:
+ pickle.dump(filesRun, pickle_out)
totalTests = sum(results.values())
if totalTests > 0:
@@ -199,6 +201,8 @@ if __name__ == '__main__':
parser.add_argument(
'--debug', action='store_true', help="Flag to print output")
parser.add_argument(
+ '--resume', action='store_true', help="Flag to resume previous runs")
+ parser.add_argument(
'--component', required=True, help="The component to be used. Options: " + \
" ".join("[" + x + "]" for x in extensions.keys()))
@@ -227,6 +231,6 @@ if __name__ == '__main__':
listFiles = get_file_names(component, filesPath)
- run_tests_and_get_results(liboPath, listFiles, argument.debug)
+ run_tests_and_get_results(liboPath, listFiles, argument.debug, argument.resume)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 399377505af0bfa1f711d1a7274e390528634718
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Apr 22 17:43:22 2019 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Apr 22 22:01:58 2019 +0200
mass-uitesting: timeout by test
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index 6e3aeb6..c266ff2 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -13,6 +13,8 @@ import signal
import logging
from shutil import copyfile
import pickle
+import time
+import fcntl
extensions = {
'writer' : [ "odt", "doc", "docx", "rtf" ],
@@ -68,10 +70,11 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
if not os.path.exists(userPath):
os.makedirs(userPath)
- totalPass = 0
- totalFail = 0
- totalTimeout = 0
- totalSkip = 0
+ results = {
+ 'pass' : 0,
+ 'fail' : 0,
+ 'timeout' : 0,
+ 'skip' : 0}
sofficePath = liboPath + "instdir/program/soffice"
process = Popen([sofficePath, "--version"], stdout=PIPE, stderr=PIPE)
@@ -104,62 +107,84 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug):
#TODO: Find a better way to pass fileName parameter
os.environ["TESTFILENAME"] = fileName
- with Popen(["python3.5",
+ process = Popen(["python3.5",
liboPath + "uitest/test_main.py",
"--debug",
"--soffice=path:" + sofficePath,
"--userdir=file://" + profilePath,
"--file=" + component + ".py"], stdin=PIPE, stdout=PIPE, stderr=PIPE,
- preexec_fn=os.setsid) as process:
- try:
- outputLines = process.communicate(timeout=60)[0].decode('utf-8').splitlines()
- importantInfo = ''
- for line in outputLines:
- if isDebug:
- print(line)
-
- if 'skipped' == line.strip().lower():
- logger.info("SKIP: " + fileName + " : " + importantInfo)
- totalSkip += 1
- break
-
- if 'Execution time' in line:
- # No error found between one Execution time line and the other
- if importantInfo:
- logger.info("PASS: " + fileName + " : " + importantInfo)
- totalPass += 1
-
- importantInfo = line.strip().split('for ')[1]
-
- elif importantInfo and 'error' == line.strip().lower() or 'fail' == line.strip().lower():
- logger.info("FAIL: " + fileName + " : " + importantInfo)
- totalFail += 1
- importantInfo = ''
-
- if importantInfo:
- # No error found between the last Execution time line and the end
- logger.info("PASS: " + fileName + " : " + importantInfo)
- totalPass += 1
-
- except TimeoutExpired:
+ preexec_fn=os.setsid)
+
+ # Do not block on process.stdout
+ fcntl.fcntl(process.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
+
+ # Kill the process if the test can't be executed in 20 seconds
+ timeout = time.time() + 20
+ isFailure = False
+ while True:
+ time.sleep(1)
+
+ if time.time() > timeout:
logger.info("TIMEOUT: " + fileName)
- totalTimeout += 1
+ results['timeout'] += 1
+
+ # kill popen process
+ os.killpg(process.pid, signal.SIGKILL)
+ break
+
+ try:
+ outputLines = process.stdout.readlines()
+
+ except IOError:
+ pass
+
+ importantInfo = ''
+
+ for line in outputLines:
+ line = line.decode("utf-8")
+
+ if isDebug:
+ print(line)
+
+ if 'skipped' == line.strip().lower():
+ logger.info("SKIP: " + fileName + " : " + importantInfo)
+ results['skip'] += 1
+ break
+
+ if 'Execution time' in line.strip():
+
+ importantInfo = line.strip().split('for ')[1]
+
+ #Extend timeout
+ timeout = time.time() + 20
+
+ elif importantInfo and 'error' == line.strip().lower() or 'fail' == line.strip().lower():
+ logger.info("FAIL: " + fileName + " : " + importantInfo)
+ results['fail'] += 1
+ isFailure = True
+
+ # No error found between the Execution time line and the end of stdout
+ if importantInfo and not isFailure:
+ logger.info("PASS: " + fileName + " : " + str(importantInfo))
+ results['pass'] += 1
+
+ if process.poll() is not None:
+ break
- os.killpg(process.pid, signal.SIGINT) # send signal to the process group
filesRun[sourceHash].append(fileName)
with open(pklFile, 'wb') as pickle_out:
pickle.dump(filesRun, pickle_out)
- totalTests = totalPass + totalTimeout + totalSkip + totalFail
+ totalTests = sum(results.values())
if totalTests > 0:
logger.info("")
logger.info("Total Tests: " + str(totalTests))
- logger.info("\tPASS: " + str(totalPass))
- logger.info("\tSKIP: " + str(totalSkip))
- logger.info("\tTIMEOUT: " + str(totalTimeout))
- logger.info("\tFAIL: " + str(totalFail))
+ logger.info("\tPASS: " + str(results['pass']))
+ logger.info("\tSKIP: " + str(results['skip']))
+ logger.info("\tTIMEOUT: " + str(results['timeout']))
+ logger.info("\tFAIL: " + str(results['fail']))
logger.info("")
else:
print("No test run!")
More information about the Libreoffice-commits
mailing list