1- # This runner only supports recording tests
2- # For subsetting, use 'ng' test runner instead
3- # It's possible to use 'karma' runner for recording, and 'ng' runner for subsetting, for the same test session
41import json
52from typing import Annotated , Dict , Generator , List
63
129from . import smart_tests
1310
1411
15- @smart_tests .subset
16- def subset (client , _with : Annotated [str | None , typer .Option (
17- '--with' , help = "Specify 'ng' to use the Angular test runner for subsetting" )] = None , ):
18- # TODO: implement the --with ng option
19-
20- # read lines as test file names
21- for t in client .stdin ():
22- client .test_path (t .rstrip ("\n " ))
23-
24- client .run ()
25-
26-
2712@smart_tests .record .tests
2813def record_tests (client ,
2914 reports : Annotated [List [str ], typer .Argument (multiple = True , help = "Test report files to process" )],
@@ -32,6 +17,28 @@ def record_tests(client,
3217
3318 for r in reports :
3419 client .report (r )
20+ client .run ()
21+
22+
23+ @smart_tests .subset
24+ def subset (client , _with : Annotated [str | None , typer .Option (
25+ '--with' , help = 'Format output for specific test runner (e.g., "ng" for Angular CLI)' )] = None , ):
26+ """
27+ Usage:
28+ find src -name "*.spec.ts" -o -name "*.spec.js" > test-list.txt
29+ cat test-list.txt | launchable subset --target 10% karma
30+
31+ # Output in ng test format
32+ find src -name "*.spec.ts" | launchable subset --target 10% karma --with ng
33+ """
34+ for t in client .stdin ():
35+ path = t .strip ()
36+ if path :
37+ client .test_path (path )
38+
39+ if _with == 'ng' :
40+ client .formatter = lambda x : "--include={}" .format (x [0 ]['name' ])
41+ client .separator = " "
3542
3643 client .run ()
3744
0 commit comments