Skip to content

Commit ef45fd2

Browse files
committed
Refresh WebRunner integration: pass file paths, expand keyword list
- Add start_test_process_file / build_process_from_file that invoke the child interpreter with --execute_file. Multi-file WebRunner flows now pass the JSON path directly instead of reading the file contents into --execute_str, which avoided the Windows ~32K argv cap on large scripts. - Drop the unused stdin=PIPE on the spawned subprocess and extract the shared spawn / pump setup into a helper. - Resync web_runner_keys with the current WebRunner public surface (Playwright wrappers, axe a11y, CDP, HTTP client, env config, data-driven, healing locators, POM generator, notifier, visual regression, recorder, OAuth, testcontainers, storage, event capture, faker, lighthouse, locust, cloud grid, plus the WR_* commands added since the last sync).
1 parent 73256bc commit ef45fd2

4 files changed

Lines changed: 467 additions & 80 deletions

File tree

pybreeze/extend/process_executor/process_executor_utils.py

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,50 @@ def start_process(
4343
send_mail: bool = False,
4444
program_buffer: int = 1024000
4545
):
46-
# Code window init
46+
process = _build_task_process(main_window, send_mail, program_buffer)
47+
process.start_test_process(
48+
package,
49+
exec_str=test_format_code,
50+
)
51+
52+
53+
def build_process_from_file(
54+
main_window: PyBreezeMainWindow,
55+
package: str,
56+
file_path: str,
57+
send_mail: bool = False,
58+
program_buffer: int = 1024000,
59+
):
60+
"""Run ``package`` against an action JSON file path.
61+
62+
Bypasses the ``--execute_str`` cmdline path so large scripts cannot trip
63+
the Windows ~32K argv limit. Useful for batch / multi-file flows where
64+
the file is already on disk.
65+
"""
66+
try:
67+
process = _build_task_process(main_window, send_mail, program_buffer)
68+
process.start_test_process_file(package, file_path)
69+
except ITETestExecutorException as error:
70+
pybreeze_logger.error(repr(error))
71+
72+
73+
def _build_task_process(
74+
main_window: PyBreezeMainWindow,
75+
send_mail: bool,
76+
program_buffer: int,
77+
) -> TaskProcessManager:
4778
code_window = CodeWindow()
4879
main_window.current_run_code_window.append(code_window)
4980
main_window.clear_code_result()
50-
# Process init
5181
if send_mail:
52-
process = TaskProcessManager(
82+
return TaskProcessManager(
5383
main_window=code_window,
5484
task_done_trigger_function=send_after_test,
5585
program_buffer_size=program_buffer,
56-
program_encoding=main_window.encoding
86+
program_encoding=main_window.encoding,
5787
)
58-
else:
59-
process = TaskProcessManager(
60-
code_window,
61-
program_buffer_size=program_buffer,
62-
program_encoding=main_window.encoding
63-
)
64-
process.start_test_process(
65-
package,
66-
exec_str=test_format_code,
88+
return TaskProcessManager(
89+
code_window,
90+
program_buffer_size=program_buffer,
91+
program_encoding=main_window.encoding,
6792
)

pybreeze/extend/process_executor/python_task_process_manager.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,41 @@ def start_test_process(self, package: str, exec_str: str):
8383
"--execute_str",
8484
exec_str
8585
]
86+
self._spawn_and_pump(package, args)
87+
88+
def start_test_process_file(self, package: str, file_path: str):
89+
# Pass the action JSON as a path so we never hit the Windows ~32K
90+
# command-line cap when scripts are large. Caller owns the file.
91+
self.renew_path()
92+
args = [
93+
str(self.compiler_path),
94+
"-m",
95+
package,
96+
"--execute_file",
97+
str(file_path),
98+
]
99+
self._spawn_and_pump(package, args)
100+
101+
def _spawn_and_pump(self, package: str, args: list) -> None:
86102
# Launch user-authored automation script in a child interpreter.
87103
# Argument list is validated upstream; shell=False, no user string ever
88104
# reaches a shell. nosec B603 — intentional local process execution.
89105
self.process = subprocess.Popen( # nosec B603 # nosemgrep # noqa: S603
90106
args,
91-
stdin=subprocess.PIPE,
92107
stdout=subprocess.PIPE,
93108
stderr=subprocess.PIPE,
94109
)
95110
self.still_run_program = True
96-
# program output message queue thread
97111
self.read_program_output_from_thread = Thread(
98112
target=self.read_program_output_from_process,
99113
daemon=True
100114
)
101115
self.read_program_output_from_thread.start()
102-
# program error message queue thread
103116
self.read_program_error_output_from_thread = Thread(
104117
target=self.read_program_error_output_from_process,
105118
daemon=True
106119
)
107120
self.read_program_error_output_from_thread.start()
108-
# start Pyside update
109-
# start timer
110121
self.main_window.setWindowTitle(package)
111122
self.main_window.show()
112123
self.timer = QTimer(self.main_window)

pybreeze/extend/process_executor/web_runner/web_runner_process.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from typing import TYPE_CHECKING
44

5-
from pybreeze.extend.process_executor.process_executor_utils import build_process
5+
from pybreeze.extend.process_executor.process_executor_utils import (
6+
build_process, build_process_from_file,
7+
)
68

79
if TYPE_CHECKING:
810
from pybreeze.pybreeze_ui.editor_main.main_ui import PyBreezeMainWindow
@@ -35,12 +37,10 @@ def call_web_runner_test_multi_file(
3537
need_to_execute_list = ask_and_get_dir_files_as_list(main_window)
3638
if need_to_execute_list is not None and len(need_to_execute_list) > 0:
3739
for execute_file in need_to_execute_list:
38-
with open(execute_file, encoding="utf-8") as test_script_json:
39-
call_web_runner_test(
40-
main_window,
41-
test_script_json.read(),
42-
program_buffer
43-
)
40+
build_process_from_file(
41+
main_window, "je_web_runner", execute_file,
42+
False, program_buffer,
43+
)
4444
except Exception as error:
4545
pybreeze_logger.error(f"web runner multi file error: {error}")
4646

@@ -53,11 +53,9 @@ def call_web_runner_test_multi_file_and_send(
5353
need_to_execute_list = ask_and_get_dir_files_as_list(main_window)
5454
if need_to_execute_list is not None and len(need_to_execute_list) > 0:
5555
for execute_file in need_to_execute_list:
56-
with open(execute_file, encoding="utf-8") as test_script_json:
57-
call_web_runner_test_with_send(
58-
main_window,
59-
test_script_json.read(),
60-
program_buffer
61-
)
56+
build_process_from_file(
57+
main_window, "je_web_runner", execute_file,
58+
True, program_buffer,
59+
)
6260
except Exception as error:
6361
pybreeze_logger.error(f"web runner multi file and send error: {error}")

0 commit comments

Comments
 (0)