forked from tensorflow/tensorboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_testing.bzl
83 lines (76 loc) · 2.99 KB
/
web_testing.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Provides Bazel test targets for Web Component Tester tests."""
load("@io_bazel_rules_webtesting//web:py.bzl", "py_web_test_suite")
def _tf_web_test_python_stub_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
output = ctx.outputs.main,
substitutions = {
"{BINARY_PATH}": ctx.executable.web_library.short_path,
"{WEB_PATH}": ctx.attr.web_path,
},
)
_tf_web_test_python_stub = rule(
implementation = _tf_web_test_python_stub_impl,
attrs = {
"web_library": attr.label(executable = True, cfg = "host", mandatory = True),
"web_path": attr.string(mandatory = True),
"main": attr.output(),
"_template": attr.label(
default = Label("//tensorboard/defs:web_test_python_stub.template.py"),
allow_single_file = True,
),
},
)
def tf_web_test(name, web_library, src, **kwargs):
"""Run tests defined by a `tf_web_library`.
By default, the test will have timeout = "short" and flaky = True.
These options can be overridden.
Args:
name: name to use for the test target
web_library: label of a `tf_web_library` target that defines the
test cases to be run
src: web path to the main HTML entry point of the test cases, which
should be the concatenation of the tf_web_library's `path` with
the name of the main HTML source file; e.g.:
"/vz-foo/test/tests.html"
**kwargs: forwarded to `py_web_test_suite` and thus indirectly to
the `py_test` native rule
"""
python_stub_name = name + "_python_stub"
python_stub_output = name + ".py"
_tf_web_test_python_stub(
name = python_stub_name,
web_library = web_library,
web_path = src,
main = python_stub_output,
testonly = 1,
)
kwargs.setdefault("flaky", True)
kwargs.setdefault("timeout", "moderate")
kwargs.setdefault("tags", []).append("webtest")
py_web_test_suite(
name = name,
srcs = [python_stub_output],
browsers = ["//tensorboard/functionaltests/browsers:chromium"],
data = [web_library],
srcs_version = "PY2AND3",
deps = [
"@io_bazel_rules_webtesting//testing/web",
"@org_pythonhosted_urllib3//:org_pythonhosted_urllib3",
"//tensorboard/functionaltests:wct_test_driver",
],
**kwargs
)