2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-23 20:41:55 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-4894
|
|
|
|
ISSUE: 4894
|
|
|
|
TITLE: INPUT file not properly closed
|
|
|
|
DESCRIPTION:
|
2023-11-28 19:14:04 +01:00
|
|
|
Test makes TWO attempts to execute script using 'IN <script>' command.
|
|
|
|
After first attempt (which must complete OK) we try to delete file using Windows 'DEL' command.
|
|
|
|
This command must finish successful and second attempt to run the same script must file with
|
|
|
|
message 'Unable to open ...'
|
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
JIRA: CORE-4578
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_4578
|
2022-01-23 20:41:55 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2023-11-28 19:14:04 +01:00
|
|
|
from pathlib import Path
|
|
|
|
import locale
|
2021-04-26 20:07:00 +02:00
|
|
|
import pytest
|
2022-01-23 20:41:55 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2023-11-28 19:14:04 +01:00
|
|
|
init_sql = """
|
|
|
|
recreate table test(id bigint primary key);
|
|
|
|
commit;
|
|
|
|
"""
|
|
|
|
db = db_factory(init = init_sql)
|
2022-01-23 20:41:55 +01:00
|
|
|
act = python_act('db', substitutions=[('Unable to open.*', 'Unable to open')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
2023-11-28 19:14:04 +01:00
|
|
|
tmp_worker = temp_file('tmp.core_4578.worker.sql')
|
|
|
|
tmp_caller = temp_file('tmp.core_4578.caller.sql')
|
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
@pytest.mark.version('>=3')
|
|
|
|
@pytest.mark.platform('Windows')
|
2023-11-28 19:14:04 +01:00
|
|
|
def test_1(act: Action, tmp_worker: Path, tmp_caller: Path):
|
|
|
|
|
|
|
|
|
|
|
|
worker_sql = """
|
|
|
|
set list on;
|
|
|
|
insert into test(id) values(1) returning id;
|
|
|
|
commit;
|
|
|
|
"""
|
|
|
|
|
|
|
|
caller_sql = f"""
|
|
|
|
set list on;
|
|
|
|
commit;
|
|
|
|
in "{str(tmp_worker)}";
|
|
|
|
shell del "{str(tmp_worker)}";
|
|
|
|
in "{str(tmp_worker)}";
|
|
|
|
"""
|
|
|
|
tmp_worker.write_text(worker_sql)
|
|
|
|
tmp_caller.write_text(caller_sql)
|
|
|
|
|
|
|
|
expected_stdout = """
|
|
|
|
ID 1
|
|
|
|
Unable to open
|
|
|
|
"""
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.isql(switches=['-q'], input_file = str(tmp_caller), io_enc = locale.getpreferredencoding(), combine_output = True)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2023-11-28 19:14:04 +01:00
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|