diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-05-12 14:42:03 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-06-16 09:31:43 +0200 |
commit | 07206d1e002a249f7e25e9f723fcb810a8e3ce0c (patch) | |
tree | d5edb54c68c19971c45583eb2727ce37e89da479 /uitest | |
parent | 8ba5ca764036923060f39c2e22c4ac45852f8b93 (diff) |
mass-uitesting: simplify logs and results
Change-Id: I5074ebff9344d32b9e9a0d5d1619634613023ec6
Diffstat (limited to 'uitest')
-rwxr-xr-x | uitest/mass-testing/run.py | 71 |
1 files changed, 14 insertions, 57 deletions
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py index 92cf32e9..d6da66a2 100755 --- a/uitest/mass-testing/run.py +++ b/uitest/mass-testing/run.py @@ -12,7 +12,6 @@ import sys import signal import logging from shutil import copyfile -import pickle import time import fcntl import tempfile @@ -35,12 +34,12 @@ class DefaultHelpParser(argparse.ArgumentParser): self.print_help() sys.exit(2) -def start_logger(): +def start_logger(name): rootLogger = logging.getLogger() rootLogger.setLevel(os.environ.get("LOGLEVEL", "INFO")) logFormatter = logging.Formatter("%(asctime)s %(message)s") - fileHandler = logging.FileHandler("./log") + fileHandler = logging.FileHandler(name) fileHandler.setFormatter(logFormatter) rootLogger.addHandler(fileHandler) @@ -63,32 +62,26 @@ def get_file_names(filesPath): def run_tests_and_get_results(sofficePath, listFiles, isDebug, isResume): - results = { - 'pass' : 0, - 'fail' : 0, - 'timeout' : 0, - 'skip' : 0} - process = Popen([sofficePath, "--version"], stdout=PIPE, stderr=PIPE) stdout = process.communicate()[0].decode("utf-8") sourceHash = stdout.split(" ")[2].strip() - #Keep track of the files run - filesRun = {} - - if isResume: - pklFile = './resume.pkl' - if os.path.exists(pklFile): - with open(pklFile, 'rb') as pickle_in: - filesRun = pickle.load(pickle_in) + if not os.path.exists('./logs'): + os.makedirs('./logs') - if sourceHash not in filesRun: - filesRun[sourceHash] = {'files': []} + logName = './logs/' + sourceHash + ".log" + logger = start_logger(logName) - if 'results' in filesRun[sourceHash]: - results = filesRun[sourceHash]['results'] + if isResume: + with open(logName, 'r') as file: + previousLog = file.read() for fileName in listFiles: + if isResume: + if fileName in previousLog: + print("SKIP: " + fileName) + continue + extension = os.path.splitext(fileName)[1][1:] component = "" @@ -99,11 +92,6 @@ def run_tests_and_get_results(sofficePath, listFiles, isDebug, isResume): if not component: continue - if isResume: - if fileName in filesRun[sourceHash]['files']: - print("SKIP: " + fileName) - continue - #Create temp directory for the user profile with tempfile.TemporaryDirectory() as tmpdirname: profilePath = os.path.join(tmpdirname, 'libreoffice/4') @@ -143,10 +131,8 @@ def run_tests_and_get_results(sofficePath, listFiles, isDebug, isResume): if time.time() > timeout: if notLoaded: logger.info("SKIP: " + fileName) - results['skip'] += 1 else: logger.info("TIMEOUT: " + fileName) - results['timeout'] += 1 # kill popen process os.killpg(process.pid, signal.SIGKILL) @@ -172,7 +158,6 @@ def run_tests_and_get_results(sofficePath, listFiles, isDebug, isResume): message = line.split(":")[1] if message == 'skipped': logger.info("SKIP: " + fileName + " : " + importantInfo) - results['skip'] += 1 # kill popen process os.killpg(process.pid, signal.SIGKILL) @@ -193,36 +178,13 @@ def run_tests_and_get_results(sofficePath, listFiles, isDebug, isResume): 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 - if isResume: - filesRun[sourceHash]['files'].append(fileName) - - filesRun[sourceHash]['results'] = results - - with open(pklFile, 'wb') as pickle_out: - pickle.dump(filesRun, pickle_out) - - - totalTests = sum(results.values()) - if totalTests > 0: - logger.info("") - logger.info("Total Tests: " + str(totalTests)) - 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!") - if __name__ == '__main__': currentPath = os.path.dirname(os.path.realpath(__file__)) uitestPath = os.path.join(currentPath, 'uitest/test_main.py') @@ -256,11 +218,6 @@ if __name__ == '__main__': os.environ["URE_BOOTSTRAP"] = "file://" + sofficePath.split('/soffice')[0] + '/fundamentalrc' os.environ["SAL_USE_VCLPLUGIN"] = "gen" - if not os.path.exists('./logs'): - os.makedirs('./logs') - - logger = start_logger() - listFiles = get_file_names(filesPath) listFiles.sort() |