Skip to content

Commit

Permalink
Use a predetermined seed for tfjs-layers tests (#6878)
Browse files Browse the repository at this point in the history
Run tfjs-layers tests in a static, non-random order. This is a temporary fix for #6543.
  • Loading branch information
mattsoulanille authored Sep 30, 2022
1 parent d94faba commit feb0eeb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tfjs-layers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ tfjs_web_test(
"win_10_chrome",
],
headless = False,
seed = "12345",
static_files = [
# Listed here so sourcemaps are served
"//tfjs-layers/src:tfjs-layers_test_bundle",
Expand All @@ -77,6 +78,7 @@ tfjs_web_test(
"bs_ios_12",
],
headless = False,
seed = "12345",
static_files = [
# Listed here so sourcemaps are served
"//tfjs-layers/src:tfjs-layers_test_bundle",
Expand Down
8 changes: 7 additions & 1 deletion tools/karma_template.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ module.exports = function(config) {
browserSocketTimeout: 1.2e5,
...extraConfig,
customLaunchers: CUSTOM_LAUNCHERS,
client: {args: TEMPLATE_args},
client: {
args: TEMPLATE_args,
jasmine: {
random: TEMPLATE_jasmine_random,
seed: "TEMPLATE_jasmine_seed",
},
},
});
}
13 changes: 13 additions & 0 deletions tools/tfjs_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ def _make_karma_config_impl(ctx):
if grep:
args = args + ["--grep=" + grep]

seed = ctx.attr.seed
ctx.actions.expand_template(
template = ctx.file.template,
output = ctx.outputs.config_file,
substitutions = {
"TEMPLATE_args": str(args),
"TEMPLATE_browser": ctx.attr.browser,
"TEMPLATE_jasmine_random": "false" if seed else "true",
"TEMPLATE_jasmine_seed": seed if seed else "undefined",
},
)
return [DefaultInfo(files = depset([output_file]))]
Expand All @@ -71,6 +74,13 @@ _make_karma_config = rule(
default = "",
doc = "The browser to run",
),
"seed": attr.string(
default = "",
doc = """Use this seed for test order.
If not specified or empty, use a random seed every time.
""",
),
"template": attr.label(
default = Label("@//tools:karma_template.conf.js"),
allow_single_file = True,
Expand All @@ -84,6 +94,7 @@ _make_karma_config = rule(
def tfjs_web_test(name, ci = True, args = [], **kwargs):
tags = kwargs.pop("tags", [])
local_browser = kwargs.pop("local_browser", "")
seed = kwargs.pop("seed", "")
headless = kwargs.pop("headless", True)

browsers = kwargs.pop("browsers", [
Expand Down Expand Up @@ -111,6 +122,7 @@ def tfjs_web_test(name, ci = True, args = [], **kwargs):
name = config_file,
args = args,
browser = local_browser,
seed = seed,
)

karma_web_test(
Expand All @@ -131,6 +143,7 @@ def tfjs_web_test(name, ci = True, args = [], **kwargs):
name = config_file,
browser = browser,
args = args,
seed = seed,
)

additional_tags = ["no-remote-exec"]
Expand Down

0 comments on commit feb0eeb

Please sign in to comment.