aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/gen/BUILD
blob: 68deaa8009b5c64b41af7cec5d6a3ad21a7ec889 (plain)
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
# Build rules to test genrules under bazel.
# TODO(bazel-team): Convert to unit test, or remove when the temporary Docker
# override flags are removed.

package(default_visibility = ["//visibility:public"])

filegroup(
    name = "srcs",
    srcs = glob(["**"]),
    visibility = ["//src:__pkg__"],
)

# A rule that can help check if Docker container is enabled.
genrule(
    name = "hostname",
    outs = ["hostname.txt"],
    cmd = "hostname > $@",
)

# A rule to help check if the right uid is set.
genrule(
    name = "uid",
    outs = ["uid.txt"],
    cmd = "id -u > $@; (whoami >> $@ || echo 'No whoami!')",
)

# A genrule to check if output/stdout/strerr are piped correctly.
genrule(
    name = "stdout-stderr",
    outs = ["output.txt"],
    cmd = "echo 'To file.' > $@; echo 'to stdout.'; (>&2 echo 'to stderr.');",
)

# A use case that fails if it's built in a Docker container running under root.
genrule(
    name = "mine",
    outs = ["mine.txt"],
    cmd = "echo 'this is mine!' > $@; chmod 700 $@;",
)

# A use case that fails if it's built in a Docker container running under root.
genrule(
    name = "vars",
    outs = ["vars.txt"],
    cmd = "set > $@",
)