| 1 |
load("@rules_cc//cc:defs.bzl", "cc_test") |
| 2 |
|
| 3 |
package(default_visibility = ["//visibility:public"]) |
| 4 |
|
| 5 |
CONFIGS = glob( |
| 6 |
["*.json"], |
| 7 |
exclude = ["*.schema.json"], |
| 8 |
) |
| 9 |
|
| 10 |
# Bazel 10 no longer lets source files inherit package default_visibility, so |
| 11 |
# export the config JSONs explicitly (e.g. //data/dictionary references t2s.json). |
| 12 |
exports_files( |
| 13 |
CONFIGS, |
| 14 |
visibility = ["//visibility:public"], |
| 15 |
) |
| 16 |
|
| 17 |
filegroup( |
| 18 |
name = "config", |
| 19 |
srcs = CONFIGS, |
| 20 |
) |
| 21 |
|
| 22 |
filegroup( |
| 23 |
name = "config_schema", |
| 24 |
srcs = ["opencc_config.schema.json"], |
| 25 |
) |
| 26 |
|
| 27 |
filegroup( |
| 28 |
name = "config_schema_validation_test_src", |
| 29 |
srcs = ["ConfigSchemaValidationTest.cpp"], |
| 30 |
) |
| 31 |
|
| 32 |
[ |
| 33 |
cc_test( |
| 34 |
name = "config_dict_validation_" + config[:-5], |
| 35 |
size = "small", |
| 36 |
srcs = ["ConfigDictValidationTest.cpp"], |
| 37 |
local_defines = [ |
| 38 |
"BAZEL", |
| 39 |
"OPENCC_CONFIG_DICT_TEST_FILE=\\\"" + config + "\\\"", |
| 40 |
], |
| 41 |
data = [ |
| 42 |
config, |
| 43 |
"//data/dictionary:binary_dictionaries", |
| 44 |
"//test/testcases", |
| 45 |
], |
| 46 |
deps = [ |
| 47 |
"//src:simple_converter_lib", |
| 48 |
"@bazel_tools//tools/cpp/runfiles", |
| 49 |
"@googletest//:gtest_main", |
| 50 |
"//deps/rapidjson-1.1.0:rapidjson", |
| 51 |
], |
| 52 |
) |
| 53 |
for config in CONFIGS |
| 54 |
] |
| 55 |
|
| 56 |
test_suite( |
| 57 |
name = "config_dict_validation_test", |
| 58 |
tests = [ |
| 59 |
":config_dict_validation_" + config[:-5] |
| 60 |
for config in CONFIGS |
| 61 |
], |
| 62 |
) |
| 63 |
|
| 64 |
[ |
| 65 |
cc_test( |
| 66 |
name = "config_schema_validation_" + config[:-5], |
| 67 |
size = "small", |
| 68 |
srcs = ["ConfigSchemaValidationTest.cpp"], |
| 69 |
local_defines = [ |
| 70 |
"BAZEL", |
| 71 |
"OPENCC_CONFIG_SCHEMA_TEST_FILE=\\\"data/config/" + config + "\\\"", |
| 72 |
], |
| 73 |
data = [ |
| 74 |
config, |
| 75 |
":config_schema", |
| 76 |
], |
| 77 |
deps = [ |
| 78 |
"@bazel_tools//tools/cpp/runfiles", |
| 79 |
"@googletest//:gtest_main", |
| 80 |
"//deps/rapidjson-1.1.0:rapidjson", |
| 81 |
], |
| 82 |
) |
| 83 |
for config in CONFIGS |
| 84 |
] |
| 85 |
|
| 86 |
test_suite( |
| 87 |
name = "config_schema_validation_test", |
| 88 |
tests = [ |
| 89 |
":config_schema_validation_" + config[:-5] |
| 90 |
for config in CONFIGS |
| 91 |
], |
| 92 |
) |