...

Text file src/github.com/google/flatbuffers/tests/BUILD.bazel

Documentation: github.com/google/flatbuffers/tests

     1load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
     2load("@rules_cc//cc:defs.bzl", "cc_test")
     3load("//:build_defs.bzl", "DEFAULT_FLATC_ARGS", "flatbuffer_cc_library")
     4
     5package(default_visibility = ["//visibility:private"])
     6
     7# rules_js works around various JS tooling limitations by copying everything
     8# into the output directory. Make the test data available to the tests this way.
     9copy_to_bin(
    10    name = "test_data_copied_to_bin",
    11    srcs = glob([
    12        "*.mon",
    13        "*.json",
    14    ]),
    15    visibility = ["//tests/ts:__subpackages__"],
    16)
    17
    18# Test binary.
    19cc_test(
    20    name = "flatbuffers_test",
    21    testonly = 1,
    22    srcs = [
    23        "64bit/evolution/v1_generated.h",
    24        "64bit/evolution/v2_generated.h",
    25        "64bit/offset64_test.cpp",
    26        "64bit/offset64_test.h",
    27        "64bit/test_64bit_bfbs_generated.h",
    28        "64bit/test_64bit_generated.h",
    29        "alignment_test.cpp",
    30        "alignment_test.h",
    31        "alignment_test_generated.h",
    32        "evolution_test.cpp",
    33        "evolution_test.h",
    34        "evolution_test/evolution_v1_generated.h",
    35        "evolution_test/evolution_v2_generated.h",
    36        "flexbuffers_test.cpp",
    37        "flexbuffers_test.h",
    38        "fuzz_test.cpp",
    39        "fuzz_test.h",
    40        "is_quiet_nan.h",
    41        "json_test.cpp",
    42        "json_test.h",
    43        "key_field/key_field_sample_generated.h",
    44        "key_field_test.cpp",
    45        "key_field_test.h",
    46        "monster_test.cpp",
    47        "monster_test.h",
    48        "monster_test_bfbs_generated.h",
    49        "namespace_test/namespace_test1_generated.h",
    50        "namespace_test/namespace_test2_generated.h",
    51        "native_inline_table_test_generated.h",
    52        "native_type_test_impl.cpp",
    53        "native_type_test_impl.h",
    54        "optional_scalars_generated.h",
    55        "optional_scalars_test.cpp",
    56        "optional_scalars_test.h",
    57        "parser_test.cpp",
    58        "parser_test.h",
    59        "proto_test.cpp",
    60        "proto_test.h",
    61        "reflection_test.cpp",
    62        "reflection_test.h",
    63        "test.cpp",
    64        "test_assert.cpp",
    65        "test_assert.h",
    66        "test_builder.cpp",
    67        "test_builder.h",
    68        "union_underlying_type_test_generated.h",
    69        "union_vector/union_vector_generated.h",
    70        "util_test.cpp",
    71        "util_test.h",
    72    ],
    73    copts = [
    74        "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
    75    ],
    76    data = [
    77        ":alignment_test.fbs",
    78        ":arrays_test.bfbs",
    79        ":arrays_test.fbs",
    80        ":arrays_test.golden",
    81        ":evolution_test/evolution_v1.fbs",
    82        ":evolution_test/evolution_v1.json",
    83        ":evolution_test/evolution_v2.fbs",
    84        ":evolution_test/evolution_v2.json",
    85        ":include_test/include_test1.fbs",
    86        ":include_test/sub/include_test2.fbs",
    87        ":key_field/key_field_sample.fbs",
    88        ":monster_extra.fbs",
    89        ":monster_test.bfbs",
    90        ":monster_test.fbs",
    91        ":monsterdata_extra.json",
    92        ":monsterdata_test.golden",
    93        ":monsterdata_test.json",
    94        ":name_clash_test/invalid_test1.fbs",
    95        ":name_clash_test/invalid_test2.fbs",
    96        ":name_clash_test/valid_test1.fbs",
    97        ":name_clash_test/valid_test2.fbs",
    98        ":native_type_test.fbs",
    99        ":optional_scalars.fbs",
   100        ":optional_scalars.json",
   101        ":optional_scalars_defaults.json",
   102        ":prototest/imported.proto",
   103        ":prototest/non-positive-id.proto",
   104        ":prototest/test.golden.fbs",
   105        ":prototest/test.proto",
   106        ":prototest/test_id.golden.fbs",
   107        ":prototest/test_include.golden.fbs",
   108        ":prototest/test_include_id.golden.fbs",
   109        ":prototest/test_suffix.golden.fbs",
   110        ":prototest/test_suffix_id.golden.fbs",
   111        ":prototest/test_union.golden.fbs",
   112        ":prototest/test_union_id.golden.fbs",
   113        ":prototest/test_union_include.golden.fbs",
   114        ":prototest/test_union_include_id.golden.fbs",
   115        ":prototest/test_union_suffix.golden.fbs",
   116        ":prototest/test_union_suffix_id.golden.fbs",
   117        ":prototest/twice-id.proto",
   118        ":prototest/use-reserved-id.proto",
   119        ":unicode_test.json",
   120        ":union_vector/union_vector.fbs",
   121        ":union_vector/union_vector.json",
   122    ],
   123    includes = [
   124        "",
   125        "include/",
   126    ],
   127    deps = [
   128        ":alignment_test_cc_fbs",
   129        ":arrays_test_cc_fbs",
   130        ":monster_extra_cc_fbs",
   131        ":monster_test_cc_fbs",
   132        ":native_type_test_cc_fbs",
   133        "//:flatbuffers",
   134        "//src:generate_fbs",
   135    ],
   136)
   137
   138# Test bzl rules
   139
   140cc_library(
   141    name = "test_assert",
   142    srcs = ["test_assert.cpp"],
   143    hdrs = ["test_assert.h"],
   144    visibility = ["//grpc/tests:__subpackages__"],
   145    deps = ["//:flatbuffers"],
   146)
   147
   148cc_library(
   149    name = "test_builder",
   150    srcs = ["test_builder.cpp"],
   151    hdrs = ["test_builder.h"],
   152    visibility = ["//grpc/tests:__subpackages__"],
   153    deps = [
   154        ":monster_test_grpc",
   155        ":test_assert",
   156        "//:flatbuffers",
   157    ],
   158)
   159
   160cc_library(
   161    name = "monster_test_grpc",
   162    srcs = [
   163        "monster_test.grpc.fb.cc",
   164        "monster_test.grpc.fb.h",
   165        "monster_test_generated.h",
   166    ],
   167    hdrs = [
   168        "monster_test.grpc.fb.h",
   169        "monster_test_bfbs_generated.h",
   170        "monster_test_generated.h",
   171    ],
   172    includes = ["."],
   173    visibility = ["//grpc/tests:__subpackages__"],
   174    deps = [
   175        "//:flatbuffers",
   176        "@com_github_grpc_grpc//:grpc++",
   177    ],
   178)
   179
   180flatbuffer_cc_library(
   181    name = "include_test_fbs",
   182    srcs = [
   183        "include_test/include_test1.fbs",
   184        "include_test/sub/include_test2.fbs",
   185    ],
   186    include_paths = ["tests/include_test"],
   187)
   188
   189flatbuffer_cc_library(
   190    name = "monster_test_cc_fbs",
   191    srcs = ["monster_test.fbs"],
   192    outs = ["monster_test_bfbs_generated.h"],
   193    flatc_args = DEFAULT_FLATC_ARGS + [
   194        "--bfbs-comments",
   195        "--bfbs-builtins",
   196        "--bfbs-gen-embed",
   197        "--bfbs-filenames tests",
   198    ],
   199    include_paths = ["tests/include_test"],
   200    visibility = ["//grpc/tests:__subpackages__"],
   201    deps = [":include_test_fbs"],
   202)
   203
   204# Test that running without --no-includes works properly (monster_test doesn't
   205# work cleanly due to the circular dependency in the include_tests/ files).
   206include_test_args = [
   207    "--gen-object-api",
   208    "--gen-compare",
   209    "--gen-mutable",
   210    "--reflect-names",
   211    "--cpp-ptr-type flatbuffers::unique_ptr",
   212    "--force-empty",
   213]
   214
   215flatbuffer_cc_library(
   216    name = "included_test_fbs",
   217    srcs = ["included_test.fbs"],
   218    flatc_args = include_test_args,
   219)
   220
   221flatbuffer_cc_library(
   222    name = "includer_test_fbs",
   223    srcs = ["includer_test.fbs"],
   224    flatc_args = include_test_args,
   225    deps = [":included_test_fbs"],
   226)
   227
   228cc_library(
   229    name = "include_build_test",
   230    srcs = ["include_build_test.cc"],
   231    deps = [":includer_test_fbs"],
   232)
   233
   234flatbuffer_cc_library(
   235    name = "monster_extra_cc_fbs",
   236    srcs = ["monster_extra.fbs"],
   237)
   238
   239flatbuffer_cc_library(
   240    name = "arrays_test_cc_fbs",
   241    srcs = ["arrays_test.fbs"],
   242    flatc_args = [
   243        "--gen-object-api",
   244        "--gen-compare",
   245        "--no-includes",
   246        "--gen-mutable",
   247        "--reflect-names",
   248        "--cpp-ptr-type flatbuffers::unique_ptr",
   249        "--scoped-enums",
   250    ],
   251)
   252
   253flatbuffer_cc_library(
   254    name = "native_type_test_cc_fbs",
   255    srcs = ["native_type_test.fbs"],
   256    flatc_args = [
   257        "--gen-object-api",
   258        "--gen-mutable",
   259        "--cpp-ptr-type flatbuffers::unique_ptr",
   260    ],
   261)
   262
   263flatbuffer_cc_library(
   264    name = "alignment_test_cc_fbs",
   265    srcs = ["alignment_test.fbs"],
   266)

View as plain text