From 751d9b8ab3de97986a0c63a4235dbd8f93713499 Mon Sep 17 00:00:00 2001 From: Sawjan Gurung Date: Fri, 27 Oct 2023 17:14:42 +0545 Subject: [PATCH] [gui-tests][full-ci] use `XDG_CONFIG_HOME` with custom location for AUT during squish tests (#11316) * remove use of --confdir * use XDG_CONFIG_HOME env for AUT to set custom config dir * address reviews --- test/gui/envs.txt | 1 + .../shared/scripts/helpers/ConfigHelper.py | 25 ++++++++++++++++++- .../scripts/helpers/SetupClientHelper.py | 2 -- test/gui/suite.conf | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 test/gui/envs.txt diff --git a/test/gui/envs.txt b/test/gui/envs.txt new file mode 100644 index 00000000000..a24aacfdad5 --- /dev/null +++ b/test/gui/envs.txt @@ -0,0 +1 @@ +XDG_CONFIG_HOME=/tmp/owncloudtest/ \ No newline at end of file diff --git a/test/gui/shared/scripts/helpers/ConfigHelper.py b/test/gui/shared/scripts/helpers/ConfigHelper.py index d1db9b93b1b..e2e1301374e 100644 --- a/test/gui/shared/scripts/helpers/ConfigHelper.py +++ b/test/gui/shared/scripts/helpers/ConfigHelper.py @@ -3,6 +3,27 @@ from tempfile import gettempdir from configparser import ConfigParser + +def read_env_file(): + envs = {} + script_path = os.path.dirname(os.path.realpath(__file__)) + env_path = os.path.abspath(os.path.join(script_path, '..', '..', '..', 'envs.txt')) + with open(env_path, "rt", encoding="UTF-8") as f: + for line in f: + if line.startswith('#'): + continue + key, value = line.split('=', 1) + envs[key] = value.strip() + return envs + + +def get_config_from_env_file(env): + envs = read_env_file() + if env in envs: + return envs[env] + raise Exception('Environment "%s" not found in envs.txt' % env) + + # map environment variables to config keys CONFIG_ENV_MAP = { 'localBackendUrl': 'BACKEND_HOST', @@ -30,7 +51,9 @@ 'clientLogFile': '-', 'clientRootSyncPath': '/tmp/client-bdd/', 'tempFolderPath': gettempdir() + '/client-bdd/temp/', - 'clientConfigDir': '/tmp/owncloud-client/', + 'clientConfigDir': os.path.join( + get_config_from_env_file("XDG_CONFIG_HOME"), "ownCloud" + ), 'guiTestReportDir': os.path.abspath('../reports/'), 'ocis': False, 'custom_lib': os.path.abspath('../shared/scripts/custom_lib'), diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py index a83a3e98e74..b7d803571f0 100644 --- a/test/gui/shared/scripts/helpers/SetupClientHelper.py +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -84,8 +84,6 @@ def startClient(): + get_config('clientLogFile') + " --logdebug" + " --logflush" - + " --confdir " - + get_config('clientConfigDir') ) diff --git a/test/gui/suite.conf b/test/gui/suite.conf index 911c163142c..e1a13cdb266 100644 --- a/test/gui/suite.conf +++ b/test/gui/suite.conf @@ -1,5 +1,5 @@ AUT=owncloud --showsettings -ENVVARS=envvars +ENVVARS=envs.txt HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=false LANGUAGE=Python