blob: 2ac06c37d387666f5297c63cac5e95eb404e0df6 [file] [log] [blame]
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//bazel/go:go_test.bzl", "go_test")
load(":index.bzl", "html_insert_assets")
go_library(
name = "html_insert_assets_lib",
srcs = ["html_insert_assets.go"],
importpath = "go.skia.org/infra/infra-sk/html_insert_assets",
visibility = ["//visibility:private"],
deps = ["@org_golang_x_net//html"],
)
go_binary(
name = "html_insert_assets",
embed = [":html_insert_assets_lib"],
visibility = ["//visibility:public"],
)
go_test(
name = "html_insert_assets_test",
srcs = ["html_insert_assets_test.go"],
data = glob(["testdata/**"]),
embed = [":html_insert_assets_lib"],
deps = [
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)
html_insert_assets(
name = "actual_output",
css_serving_path = "/dist/index.css",
css_src = ":testdata/bundle.css",
html_out = ":testdata/actual_output.html",
html_src = ":testdata/input.html",
js_serving_path = "/dist/index.js",
js_src = ":testdata/bundle.js",
nonce = "{% .Nonce %}",
)
# The "diff" binary returns a non-zero exit code if the two files do not match.
TEST = """
#!/bin/sh
diff $(rootpath :testdata/expected_output.html) $(rootpath :testdata/actual_output.html)
"""
genrule(
name = "gen_test",
srcs = [
":testdata/expected_output.html",
":testdata/actual_output.html",
],
outs = ["test.sh"],
cmd = "echo '%s' > $@" % TEST,
)
sh_test(
name = "test",
srcs = ["test.sh"],
data = [
":testdata/actual_output.html",
":testdata/expected_output.html",
],
)