-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeps.bzl
146 lines (131 loc) · 3.87 KB
/
deps.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# From:
# https://stackoverflow.com/questions/47192668/idiomatic-retrieval-of-the-bazel-execution-path#
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
BATS_CORE_BUILD_CONTENT = """
sh_library(
name = "bats_lib",
srcs = glob(["libexec/**"]),
)
sh_binary(
name = "bats",
srcs = ["bin/bats"],
visibility = ["//visibility:public"],
deps = [":bats_lib"],
)
sh_library(
name = "file_setup_teardown_lib",
srcs = ["test/file_setup_teardown.bats"],
visibility = ["//visibility:public"],
data = glob(["test/fixtures/file_setup_teardown/**"]),
)
sh_library(
name = "junit_formatter_lib",
srcs = ["test/junit-formatter.bats"],
visibility = ["//visibility:public"],
data = glob(["test/fixtures/junit-formatter/**"]),
)
sh_library(
name = "parallel_lib",
srcs = ["test/parallel.bats"],
visibility = ["//visibility:public"],
data = glob([
"test/concurrent-coordination.bash",
"test/fixtures/parallel/**",
]),
)
sh_library(
name = "run_lib",
srcs = ["test/run.bats"],
visibility = ["//visibility:public"],
data = glob(["test/fixtures/run/**"]),
)
sh_library(
name = "suite_lib",
srcs = ["test/suite.bats"],
visibility = ["//visibility:public"],
data = glob(["test/fixtures/suite/**"]),
)
sh_library(
name = "test_helper",
srcs = ["test/test_helper.bash"],
visibility = ["//visibility:public"],
)
sh_library(
name = "trace_lib",
srcs = ["test/trace.bats"],
visibility = ["//visibility:public"],
data = glob(["test/fixtures/trace/**"]),
)
exports_files(glob(["test/*.bats"]))
"""
BATS_ASSERT_BUILD_CONTENT = """
filegroup(
name = "load_files",
srcs = [
"load.bash",
] + glob([
"src/**/*.bash",
]),
visibility = ["//visibility:public"],
)
"""
BATS_SUPPORT_BUILD_CONTENT = """
filegroup(
name = "load_files",
srcs = [
"load.bash",
] + glob([
"src/**/*.bash",
]),
visibility = ["//visibility:public"],
)
"""
def bazel_bats_dependencies(
version = "1.7.0",
sha256 = "ac70c2a153f108b1ac549c2eaa4154dea4a7c1cc421e3352f0ce6ea49435454e",
bats_assert_version = None,
bats_assert_sha256 = None,
bats_support_version = None,
bats_support_sha256 = None
):
if not sha256:
fail("sha256 for bats-core was not supplied.")
maybe(
http_archive,
name = "bats_core",
build_file_content = BATS_CORE_BUILD_CONTENT,
urls = [
"https://github.com/bats-core/bats-core/archive/refs/tags/v%s.tar.gz" % version,
],
strip_prefix = "bats-core-%s" % version,
sha256 = sha256,
)
if bats_assert_version:
if not bats_support_version:
fail("bats-assert version was set, but was missing set version for dependency bats-support.")
if not bats_assert_sha256:
fail("sha256 for bats-assert was not supplied.")
maybe(
http_archive,
name = "bats_assert",
build_file_content = BATS_ASSERT_BUILD_CONTENT,
sha256 = bats_assert_sha256,
strip_prefix = "bats-assert-%s" % bats_assert_version,
urls = [
"https://github.com/bats-core/bats-assert/archive/refs/tags/v%s.tar.gz" % bats_assert_version,
],
)
if bats_support_version:
if not bats_support_sha256:
fail("sha256 for bats-support was not supplied.")
maybe(
http_archive,
name = "bats_support",
build_file_content = BATS_SUPPORT_BUILD_CONTENT,
sha256 = bats_support_sha256,
strip_prefix = "bats-support-%s" % bats_support_version,
urls = [
"https://github.com/bats-core/bats-support/archive/refs/tags/v%s.tar.gz" % bats_support_version,
],
)