44
44
WRAPPER_DIR = PYTHON_SRC_DIR / "wrapper"
45
45
node_protobuf_dir = ROOT_DIR / "node" / "playwright-wrapper" / "generated"
46
46
node_dir = ROOT_DIR / "node"
47
- npm_deps_timestamp_file = ROOT_DIR / "node_modules" / ".installed"
47
+ NODE_MODULES = ROOT_DIR / "node_modules"
48
+ npm_deps_timestamp_file = NODE_MODULES / ".installed"
49
+
48
50
node_lint_timestamp_file = node_dir / ".linted"
49
51
ATEST_TIMEOUT = 900
50
52
cpu_count = os .cpu_count () or 1
@@ -104,7 +106,7 @@ def deps(c, system=False):
104
106
print ("Install package dependencies." )
105
107
c .run (uv_deps_cmd )
106
108
if os .environ .get ("CI" ):
107
- shutil .rmtree ("node_modules" , ignore_errors = True )
109
+ shutil .rmtree (str ( NODE_MODULES ) , ignore_errors = True )
108
110
109
111
if _sources_changed ([ROOT_DIR / "./package-lock.json" ], npm_deps_timestamp_file ):
110
112
arch = " --target_arch=x64" if platform .processor () == "arm" else ""
@@ -198,14 +200,9 @@ def _python_protobuf_gen(c):
198
200
def _node_protobuf_gen (c ):
199
201
plugin_suffix = ".cmd" if platform .platform ().startswith ("Windows" ) else ""
200
202
protoc_plugin = (
201
- ROOT_DIR
202
- / "node_modules"
203
- / ".bin"
204
- / f"grpc_tools_node_protoc_plugin{ plugin_suffix } "
205
- )
206
- protoc_ts_plugin = (
207
- ROOT_DIR / "node_modules" / ".bin" / f"protoc-gen-ts{ plugin_suffix } "
203
+ NODE_MODULES / ".bin" / f"grpc_tools_node_protoc_plugin{ plugin_suffix } "
208
204
)
205
+ protoc_ts_plugin = NODE_MODULES / ".bin" / f"protoc-gen-ts{ plugin_suffix } "
209
206
cmd = (
210
207
"npm run grpc_tools_node_protoc -- "
211
208
f"--js_out=import_style=commonjs,binary:{ node_protobuf_dir } "
@@ -320,6 +317,14 @@ def clean_atest(c):
320
317
_clean_zip_dir ()
321
318
322
319
320
+ def _batteries (batteries : bool ):
321
+ if batteries :
322
+ print ("Running with BrowserBatteries" )
323
+ sys .path .append (str (BROWSER_BATTERIES_DIR ))
324
+ browser_path = NODE_MODULES / "playwright-core" / ".local-browsers"
325
+ os .environ ["PLAYWRIGHT_BROWSERS_PATH" ] = str (browser_path )
326
+
327
+
323
328
@task (clean_atest , create_test_app )
324
329
def atest (
325
330
c ,
@@ -335,6 +340,7 @@ def atest(
335
340
framed = False ,
336
341
exclude = None ,
337
342
loglevel = None ,
343
+ batteries = False ,
338
344
):
339
345
"""Runs Robot Framework acceptance tests with pabot.
340
346
@@ -348,6 +354,7 @@ def atest(
348
354
smoke: If true, runs only tests that take less than 500ms.
349
355
include_mac: Does not exclude no-mac-support tags. Should be only used in local testing
350
356
loglevel: Set log level for robot framework
357
+ batteries: Run test with BrowserBatteries. Assumes that GRPC server is build.
351
358
"""
352
359
if IS_GITPOD and (not processes or int (processes ) > 6 ):
353
360
processes = "6"
@@ -381,7 +388,7 @@ def atest(
381
388
loglevel = loglevel or "DEBUG"
382
389
args .extend (["--exclude" , "tidy-transformer" ])
383
390
ATEST_OUTPUT .mkdir (parents = True , exist_ok = True )
384
-
391
+ _batteries ( batteries )
385
392
background_process , port = spawn_node_process (ATEST_OUTPUT / "playwright-log.txt" )
386
393
try :
387
394
os .environ ["ROBOT_FRAMEWORK_BROWSER_NODE_PORT" ] = port
@@ -475,12 +482,13 @@ def copy_xunit(c):
475
482
476
483
477
484
@task (clean_atest )
478
- def atest_robot (c , zip = None , smoke = False , suite = None ):
485
+ def atest_robot (c , zip = None , smoke = False , suite = None , batteries = False ):
479
486
"""Run atest with Robot Framework
480
487
481
488
Arguments:
482
489
zip: Create zip file from output files.
483
490
smoke: If true, runs only tests that take less than 500ms.
491
+ batteries: If true, includes BrowserBatteries in the test run.
484
492
"""
485
493
os .environ ["ROBOT_SYSLOG_FILE" ] = str (ATEST_OUTPUT / "syslog.txt" )
486
494
sys_var_ci = int (os .environ .get ("SYS_VAR_CI_INSTALL_TEST" , 0 ))
@@ -511,6 +519,7 @@ def atest_robot(c, zip=None, smoke=False, suite=None):
511
519
command_args .extend (["--suite" , suite ])
512
520
command_args = _add_skips (command_args )
513
521
command_args .append ("atest/test" )
522
+ _batteries (batteries )
514
523
env = os .environ .copy ()
515
524
process = subprocess .Popen (command_args , env = env )
516
525
process .wait (ATEST_TIMEOUT )
@@ -540,11 +549,14 @@ def atest_failed(c):
540
549
541
550
542
551
@task ()
543
- def run_tests (c , tests ):
552
+ def run_tests (c , tests , batteries = False ):
544
553
"""Run robot with dev Browser.
545
554
546
- Parameter [tests] is the path to tests to run.
555
+ Arguments:
556
+ tests: is the path to tests to run.
557
+ batteries: If true, includes BrowserBatteries in the test run.
547
558
"""
559
+ _batteries (batteries )
548
560
env = os .environ .copy ()
549
561
process = subprocess .Popen (
550
562
[
0 commit comments