diff options
author | Saw-jan <saw.jan.grg3e@gmail.com> | 2022-09-05 14:07:17 +0300 |
---|---|---|
committer | Sawjan Gurung <saw.jan.grg3e@gmail.com> | 2022-09-06 09:28:11 +0300 |
commit | 060e380ef8042f9bd0627742c15a5c2455025145 (patch) | |
tree | 22bc2a2d4183e819dcc21c62c0873378c4722020 /test | |
parent | a80727396a9887b9b46d1c013c656292913838bc (diff) |
make use of default gui test reports dir
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/shared/scripts/bdd_hooks.py | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index 25e272292..c120bf0e6 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -43,6 +43,7 @@ def hook(context): 'clientRootSyncPath': 'CLIENT_ROOT_SYNC_PATH', 'tempFolderPath': 'TEMP_FOLDER_PATH', 'clientConfigDir': 'CLIENT_CONFIG_DIR', + 'guiTestReportDir': 'GUI_TEST_REPORT_DIR', } DEFAULT_CONFIG = { @@ -56,20 +57,9 @@ def hook(context): 'clientRootSyncPath': '/tmp/client-bdd/', 'tempFolderPath': gettempdir(), 'clientConfigDir': '/tmp/owncloud-client/', + 'guiTestReportDir': os.path.abspath('../reports/'), } - # log tests scenario title on serverlog file - if os.getenv('CI'): - guiTestReportDir = os.environ.get("GUI_TEST_REPORT_DIR") - f = open(guiTestReportDir + "/serverlog.log", "a") - f.write( - str((datetime.now()).strftime("%H:%M:%S:%f")) - + "\tBDD Scenario: " - + context._data["title"] - + "\n" - ) - f.close() - # read configs from environment variables context.userData = {} for key, value in CONFIG_ENV_MAP.items(): @@ -91,7 +81,12 @@ def hook(context): context.userData[key] = DEFAULT_CONFIG[key] elif key == 'maxSyncTimeout' or key == 'minSyncTimeout': context.userData[key] = builtins.int(value) - elif key == 'clientRootSyncPath' or 'tempFolderPath' or 'clientConfigDir': + elif ( + key == 'clientRootSyncPath' + or 'tempFolderPath' + or 'clientConfigDir' + or 'guiTestReportDir' + ): # make sure there is always one trailing slash context.userData[key] = value.rstrip('/') + '/' @@ -104,6 +99,22 @@ def hook(context): shutil.rmtree(context.userData['clientConfigDir']) os.makedirs(context.userData['clientConfigDir'], 0o0755) + # create reports dir if not exists + if not os.path.exists(context.userData['guiTestReportDir']): + os.makedirs(context.userData['guiTestReportDir']) + + # log tests scenario title on serverlog file + if os.getenv('CI'): + guiTestReportDir = context.userData['guiTestReportDir'] + f = open(guiTestReportDir + "/serverlog.log", "a") + f.write( + str((datetime.now()).strftime("%H:%M:%S:%f")) + + "\tBDD Scenario: " + + context._data["title"] + + "\n" + ) + f.close() + # initially set user sync path to root # this path will be changed according to the user added to the client # e.g.: /tmp/client-bdd/Alice @@ -155,7 +166,7 @@ def hook(context): context._data["title"].replace(" ", "_").replace("/", "_").strip(".") + ".png" ) - directory = os.environ["GUI_TEST_REPORT_DIR"] + "/screenshots" + directory = context.userData['guiTestReportDir'] + "/screenshots" if not os.path.exists(directory): os.makedirs(directory) |