Adding upstream version 1.24.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
94e3fc38e7
commit
d7573acbf5
26 changed files with 565 additions and 169 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from tempfile import mkstemp
|
||||
|
||||
|
@ -11,6 +12,24 @@ from steps.wrappers import run_cli, wait_prompt
|
|||
test_log_file = os.path.join(os.environ['HOME'], '.mycli.test.log')
|
||||
|
||||
|
||||
SELF_CONNECTING_FEATURES = (
|
||||
'test/features/connection.feature',
|
||||
)
|
||||
|
||||
|
||||
MY_CNF_PATH = os.path.expanduser('~/.my.cnf')
|
||||
MY_CNF_BACKUP_PATH = f'{MY_CNF_PATH}.backup'
|
||||
MYLOGIN_CNF_PATH = os.path.expanduser('~/.mylogin.cnf')
|
||||
MYLOGIN_CNF_BACKUP_PATH = f'{MYLOGIN_CNF_PATH}.backup'
|
||||
|
||||
|
||||
def get_db_name_from_context(context):
|
||||
return context.config.userdata.get(
|
||||
'my_test_db', None
|
||||
) or "mycli_behave_tests"
|
||||
|
||||
|
||||
|
||||
def before_all(context):
|
||||
"""Set env parameters."""
|
||||
os.environ['LINES'] = "100"
|
||||
|
@ -22,7 +41,7 @@ def before_all(context):
|
|||
|
||||
test_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
login_path_file = os.path.join(test_dir, 'mylogin.cnf')
|
||||
os.environ['MYSQL_TEST_LOGIN_FILE'] = login_path_file
|
||||
# os.environ['MYSQL_TEST_LOGIN_FILE'] = login_path_file
|
||||
|
||||
context.package_root = os.path.abspath(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
|
@ -33,8 +52,7 @@ def before_all(context):
|
|||
context.exit_sent = False
|
||||
|
||||
vi = '_'.join([str(x) for x in sys.version_info[:3]])
|
||||
db_name = context.config.userdata.get(
|
||||
'my_test_db', None) or "mycli_behave_tests"
|
||||
db_name = get_db_name_from_context(context)
|
||||
db_name_full = '{0}_{1}'.format(db_name, vi)
|
||||
|
||||
# Store get params from config/environment variables
|
||||
|
@ -104,11 +122,18 @@ def before_step(context, _):
|
|||
context.atprompt = False
|
||||
|
||||
|
||||
def before_scenario(context, _):
|
||||
def before_scenario(context, arg):
|
||||
with open(test_log_file, 'w') as f:
|
||||
f.write('')
|
||||
run_cli(context)
|
||||
wait_prompt(context)
|
||||
if arg.location.filename not in SELF_CONNECTING_FEATURES:
|
||||
run_cli(context)
|
||||
wait_prompt(context)
|
||||
|
||||
if os.path.exists(MY_CNF_PATH):
|
||||
shutil.move(MY_CNF_PATH, MY_CNF_BACKUP_PATH)
|
||||
|
||||
if os.path.exists(MYLOGIN_CNF_PATH):
|
||||
shutil.move(MYLOGIN_CNF_PATH, MYLOGIN_CNF_BACKUP_PATH)
|
||||
|
||||
|
||||
def after_scenario(context, _):
|
||||
|
@ -134,6 +159,17 @@ def after_scenario(context, _):
|
|||
context.cli.sendcontrol('d')
|
||||
context.cli.expect_exact(pexpect.EOF, timeout=5)
|
||||
|
||||
if os.path.exists(MY_CNF_BACKUP_PATH):
|
||||
shutil.move(MY_CNF_BACKUP_PATH, MY_CNF_PATH)
|
||||
|
||||
if os.path.exists(MYLOGIN_CNF_BACKUP_PATH):
|
||||
shutil.move(MYLOGIN_CNF_BACKUP_PATH, MYLOGIN_CNF_PATH)
|
||||
elif os.path.exists(MYLOGIN_CNF_PATH):
|
||||
# This file was moved in `before_scenario`.
|
||||
# If it exists now, it has been created during a test
|
||||
os.remove(MYLOGIN_CNF_PATH)
|
||||
|
||||
|
||||
# TODO: uncomment to debug a failure
|
||||
# def after_step(context, step):
|
||||
# if step.status == "failed":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue