代码之家  ›  专栏  ›  技术社区  ›  Curious

如何将自定义标志传递给“bazel test”命令

  •  4
  • Curious  · 技术社区  · 7 年前

    我已经用过 gflags 在我的测试中定义自定义标志。如何在运行测试时通过 bazel test 命令?

    例如:我可以使用以下命令多次运行测试:

    bazel test //xyz:my_test --runs_per_test 10 
    

    在同一个命令中,我想传递在 my_test --use_xxx ,我该怎么做?

    1 回复  |  直到 7 年前
        1
  •  7
  •   Jin    7 年前

    Use the --test_arg flag .

    bazel test //xyz:my_test --runs_per_test=10 --test_arg=--use_xxx --test_arg=--some_number=42
    

    从文档中:

    --test_arg arg :将命令行选项/标志/参数传递给每个测试进程。这个 选项可以多次用于传递多个参数,例如。 --test_arg=--logtostderr --test_arg=--v=3 .

    你也可以 specify arguments for the test as part of the BUILD definition :

    cc_test(
        name = "my_test",
        srcs = [".."],
        deps = [".."],
        args = ["--use_xxx", "--some_number=42"],
    )
    
    推荐文章