这篇文章上次修改于 767 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

1 为 test 添加标签

cc_test(
    name = "dispatcher_test",
    size = "small",
    srcs = ["dispatcher_test.cc"],
    deps = [
        "//base/testing:test_main",
    ],
    tags = ["ci", "no_asan],
)

2 运行特定标签的 test

运行包含标签 ci 的 test:

basel test `bazel query "attr(tags, '\\bci\\b', //...)`

运行包含标签 ci,但不包含标签 no_asan 的 test:

bazel test `bazel query "attr(tags, '\\bci\\b', //...) except attr(tags, '\\bno_asan\\b', //...)"`

运行同时包含标签 ci 和 no_asan 的 test:

basel test `bazel query "attr(tags, '\\bci\\b', //...) intersect attr(tags, '\\bno_asan\\b', //...)"`