@@ -47,12 +47,15 @@ def _make_karma_config_impl(ctx):
4747 if grep :
4848 args = args + ["--grep=" + grep ]
4949
50+ seed = ctx .attr .seed
5051 ctx .actions .expand_template (
5152 template = ctx .file .template ,
5253 output = ctx .outputs .config_file ,
5354 substitutions = {
5455 "TEMPLATE_args" : str (args ),
5556 "TEMPLATE_browser" : ctx .attr .browser ,
57+ "TEMPLATE_jasmine_random" : "false" if seed else "true" ,
58+ "TEMPLATE_jasmine_seed" : seed if seed else "undefined" ,
5659 },
5760 )
5861 return [DefaultInfo (files = depset ([output_file ]))]
@@ -71,6 +74,13 @@ _make_karma_config = rule(
7174 default = "" ,
7275 doc = "The browser to run" ,
7376 ),
77+ "seed" : attr .string (
78+ default = "" ,
79+ doc = """Use this seed for test order.
80+
81+ If not specified or empty, use a random seed every time.
82+ """ ,
83+ ),
7484 "template" : attr .label (
7585 default = Label ("@//tools:karma_template.conf.js" ),
7686 allow_single_file = True ,
@@ -84,6 +94,7 @@ _make_karma_config = rule(
8494def tfjs_web_test (name , ci = True , args = [], ** kwargs ):
8595 tags = kwargs .pop ("tags" , [])
8696 local_browser = kwargs .pop ("local_browser" , "" )
97+ seed = kwargs .pop ("seed" , "" )
8798 headless = kwargs .pop ("headless" , True )
8899
89100 browsers = kwargs .pop ("browsers" , [
@@ -111,6 +122,7 @@ def tfjs_web_test(name, ci = True, args = [], **kwargs):
111122 name = config_file ,
112123 args = args ,
113124 browser = local_browser ,
125+ seed = seed ,
114126 )
115127
116128 karma_web_test (
@@ -131,6 +143,7 @@ def tfjs_web_test(name, ci = True, args = [], **kwargs):
131143 name = config_file ,
132144 browser = browser ,
133145 args = args ,
146+ seed = seed ,
134147 )
135148
136149 additional_tags = ["no-remote-exec" ]
0 commit comments