-
Notifications
You must be signed in to change notification settings - Fork 83
/
BUILD.bazel
154 lines (139 loc) · 4.15 KB
/
BUILD.bazel
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
147
148
149
150
151
152
153
154
package(default_testonly = 1)
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("@rules_java//java:defs.bzl", "java_binary", "java_test")
load(":cc-test.bzl", "cc_toolchain_test")
load(":java-test.bzl", "java_runtime_test")
load(":location_expansion_unit_test.bzl", "expand_location_unit_test_suite")
expand_location_unit_test_suite()
[
# All of these tests use the "hello" binary to see
# whether different invocations of `nixpkgs_package`
# produce a valid bazel repository.
sh_test(
name = "run-{0}".format(test),
timeout = "short",
srcs = ["test_bin.sh"],
args = ["$(location @{0}//:bin)".format(test)],
data = ["@{0}//:bin".format(test)],
)
for test in [
"hello",
"expr-test",
"attribute-test",
"expr-attribute-test",
"nix-file-test",
"nix-file-deps-test",
"nixpkgs-git-repository-test",
"relative-imports",
]
] + [
# These tests use the nix package generated by ./output.nix
# Checks whether the `:include` filegroup of `nixpkgs_package`
# repositories works as intended
# (that the expected number of files are inside the target)
sh_test(
name = "run-test-include",
timeout = "short",
srcs = ["test_output.sh"],
args = [
"2",
"$(locations @output-filegroup-test//:include)",
],
data = ["@output-filegroup-test//:include"],
),
# Checks whether specifying a manual filegroup in the
# `nixpkgs_package` BUILD file works as well.
sh_test(
name = "run-test-manual-filegroup",
timeout = "short",
srcs = ["test_output.sh"],
args = [
"3",
"$(locations @output-filegroup-manual-test//:manual-filegroup)",
],
data = ["@output-filegroup-manual-test//:manual-filegroup"],
),
]
# Test nixopts location expansion
sh_test(
name = "location-expansion-test",
srcs = ["location_expansion.sh"],
args = [
"$(POSIX_DIFF)",
"$(rootpath //tests:location_expansion/test_file)",
"$(rootpath @nixpkgs_location_expansion_test//:out/local_file)",
"$(rootpath @nixpkgs_location_expansion_test//:out/external_file)",
],
data = [
"//tests:location_expansion/test_file",
"@nixpkgs_location_expansion_test//:out/external_file",
"@nixpkgs_location_expansion_test//:out/local_file",
],
toolchains = ["@rules_sh//sh/posix:make_variables"],
)
# Test nixpkgs_cc_configure() by building some CC code.
cc_binary(
name = "cc-test",
srcs = ["cc-test.cc"],
)
cc_binary(
name = "c-test",
srcs = ["c-test.c"],
)
# Test that nixpkgs_cc_configure is selected.
cc_toolchain_test(
name = "cc-toolchain",
)
# Test nixpkgs_java_configure() by building some Java code.
java_test(
name = "java-test",
test_class = "JavaTest",
srcs = ["JavaTest.java"],
)
# Test that nixpkgs_java_runtime is selected.
java_runtime_test(
name = "java-runtime",
)
# Test nixpkgs_python_configure() by running some Python code.
test_suite(
name = "python-test",
tests = [
"@nixpkgs_python_configure_test//:python2-test",
"@nixpkgs_python_configure_test//:python3-test",
],
)
# Test nixpkgs_sh_posix_configure() checking that Unix commands are in Nix store.
sh_test(
name = "run-test-posix-toolchain",
timeout = "short",
srcs = ["test_posix_toolchain.sh"],
args = [
"$(POSIX_AWK)",
"$(POSIX_CAT)",
"$(POSIX_GREP)",
"$(POSIX_MAKE)",
],
toolchains = ["@rules_sh//sh/posix:make_variables"],
)
# Test nixpkgs_go_configure()
go_binary(
name = "go-test",
srcs = ["go-test.go"],
)
sh_test(
name = "run-test-invalid-nixpkgs-package",
timeout = "short",
srcs = ["test_invalid_nixpkgs_package.sh"],
data = [
"//nixpkgs:srcs",
"//tests/invalid_nixpkgs_package:srcs",
"@nix-unstable//:bin",
] + select({
"@platforms//os:linux": ["@busybox_static//:bin"],
"//conditions:default": [],
}),
target_compatible_with = [
# busybox_static is not available on MacOS.
"@platforms//os:linux",
],
)