Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a predetermined seed for tfjs-layers tests #6878

Merged
merged 4 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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