File: defs.bzl

package info (click to toggle)
golang-github-google-flatbuffers 24.12.23-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,704 kB
  • sloc: cpp: 53,217; python: 6,900; cs: 5,566; java: 4,370; php: 1,460; javascript: 1,061; xml: 1,016; sh: 886; makefile: 13
file content (48 lines) | stat: -rw-r--r-- 1,623 bytes parent folder | download | duplicates (4)
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
"""Helper macros and rules for tests."""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

def flatbuffers_as_external_repo_test(name, directory):
    """Run all tests in a bazel workspace that imports flatbuffers as an external repository.

    Args:
        name: The name of the test target.
        directory: The directory in which the bazel workspace is located. This is the directory
            that imports flatbuffers as an external repository.
    """
    expand_template(
        name = name + "__template_expansion",
        out = name + ".sh",
        substitutions = {
            "{{REPOSITORY_DIR}}": paths.join(native.package_name(), directory),
        },
        template = "//tests:bazel_repository_test_template.sh",
    )

    native.sh_test(
        name = name,
        srcs = [":%s.sh" % name],
        data = [
            "//:distribution",
            "@bazel_linux_x86_64//file",
        ] + native.glob(
            [
                directory + "/**/*",
            ],
            exclude = [
                directory + "/bazel-*/**",
            ],
        ),
        tags = [
            # Since we have bazel downloading external repositories inside this
            # test, we need to give it access to the internet.
            "requires-network",
        ],
        # We only have x86_64 Linux bazel exposed so restrict the test to that.
        target_compatible_with = [
            "@platforms//cpu:x86_64",
            "@platforms//os:linux",
        ],
        deps = ["@bazel_tools//tools/bash/runfiles"],
    )