2020-05-19 15:08:49 -04:00
|
|
|
# Copyright Google LLC All Rights Reserved.
|
2019-04-23 14:50:11 -04:00
|
|
|
#
|
|
|
|
# Use of this source code is governed by an MIT-style license that can be
|
|
|
|
# found in the LICENSE file at https://angular.io/license
|
|
|
|
|
2019-10-25 04:13:43 -04:00
|
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test")
|
2019-04-23 14:50:11 -04:00
|
|
|
|
|
|
|
"""
|
|
|
|
Macro that can be used to track the size of a given input file by inspecting
|
|
|
|
the corresponding source map. A golden file is used to compare the current
|
|
|
|
file size data against previously approved file size data
|
|
|
|
"""
|
|
|
|
|
2019-05-03 09:48:23 -04:00
|
|
|
def js_size_tracking_test(
|
|
|
|
name,
|
|
|
|
src,
|
2019-09-11 13:46:40 -04:00
|
|
|
source_map,
|
|
|
|
golden_file,
|
|
|
|
max_percentage_diff,
|
|
|
|
max_byte_diff,
|
2019-11-22 15:11:48 -05:00
|
|
|
angular_ivy_enabled = "False",
|
2019-05-03 09:48:23 -04:00
|
|
|
data = [],
|
|
|
|
**kwargs):
|
2019-04-23 14:50:11 -04:00
|
|
|
all_data = data + [
|
|
|
|
"//tools/size-tracking",
|
|
|
|
"@npm//source-map",
|
|
|
|
"@npm//chalk",
|
|
|
|
]
|
2019-07-22 11:00:45 -04:00
|
|
|
entry_point = "//tools/size-tracking:index.ts"
|
2019-04-23 14:50:11 -04:00
|
|
|
|
|
|
|
nodejs_test(
|
|
|
|
name = name,
|
|
|
|
data = all_data,
|
|
|
|
entry_point = entry_point,
|
2019-11-22 15:11:48 -05:00
|
|
|
configuration_env_vars = ["angular_ivy_enabled"],
|
2019-09-11 13:46:40 -04:00
|
|
|
templated_args = [
|
|
|
|
src,
|
|
|
|
source_map,
|
|
|
|
golden_file,
|
|
|
|
"%d" % max_percentage_diff,
|
|
|
|
"%d" % max_byte_diff,
|
|
|
|
"false",
|
2019-11-22 15:11:48 -05:00
|
|
|
angular_ivy_enabled,
|
2019-09-11 13:46:40 -04:00
|
|
|
],
|
2019-04-23 14:50:11 -04:00
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
|
|
|
nodejs_binary(
|
|
|
|
name = "%s.accept" % name,
|
|
|
|
testonly = True,
|
|
|
|
data = all_data,
|
|
|
|
entry_point = entry_point,
|
2019-11-22 15:11:48 -05:00
|
|
|
configuration_env_vars = ["angular_ivy_enabled"],
|
|
|
|
templated_args = [src, source_map, golden_file, "0", "0", "true", angular_ivy_enabled],
|
2019-04-23 14:50:11 -04:00
|
|
|
**kwargs
|
|
|
|
)
|