2019-04-23 14:50:11 -04:00
|
|
|
# Copyright Google Inc. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
|
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test")
|
|
|
|
|
|
|
|
"""
|
|
|
|
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,
|
|
|
|
sourceMap,
|
|
|
|
goldenFile,
|
|
|
|
maxPercentageDiff,
|
|
|
|
maxByteDiff,
|
|
|
|
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,
|
|
|
|
configuration_env_vars = ["compile"],
|
2019-05-03 09:48:23 -04:00
|
|
|
templated_args = [src, sourceMap, goldenFile, "%d" % maxPercentageDiff, "%d" % maxByteDiff, "false"],
|
2019-04-23 14:50:11 -04:00
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
|
|
|
nodejs_binary(
|
|
|
|
name = "%s.accept" % name,
|
|
|
|
testonly = True,
|
|
|
|
data = all_data,
|
|
|
|
entry_point = entry_point,
|
|
|
|
configuration_env_vars = ["compile"],
|
2019-05-03 09:48:23 -04:00
|
|
|
templated_args = [src, sourceMap, goldenFile, "0", "0", "true"],
|
2019-04-23 14:50:11 -04:00
|
|
|
**kwargs
|
|
|
|
)
|