首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过bazel获取test的日志信息?

如何通过bazel获取test的日志信息?
EN

Stack Overflow用户
提问于 2020-02-11 17:19:11
回答 1查看 10.1K关注 0票数 7

我正在使用bazel为我的项目构建和运行测试。

我想更深入地了解我的测试是如何运行的。我希望能够在我的java应用程序中看到记录器捕获的输出。

我尝试添加-s参数来启动我的测试,如下所示:bazel test -s //myproject:integration-test

它为我提供了有关如何调用测试的更多信息:

代码语言:javascript
复制
remote: Resolving deltas: 100% (101/101), completed with 18 local objects.
To github.com:Canva/canva.git
$ bazel test -s //myproject:integration-tests
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/nix/store/qsmyc0p2z1z3m06ch37hz49m0hz2c270-bazel-rc
INFO: Invocation ID: 2d17fb35-c72b-4152-bf14-2805027c6c01
INFO: Analyzed target //myproject:integration-tests (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
SUBCOMMAND: # //myproject:integration-tests [action 'Testing //myproject:integration-tests', configuration: cd8c76baa0169ef7c8b826ed0feb93200dd87a70639fd99286b8801aa9226239]
(cd /private/var/tmp/_bazel_antkong/cf188c7bd288685357ff03fcbb494066/execroot/com_canva_canva && \
  exec env - \
    CI='' \
    DISPLAY=:1 \
    EXPERIMENTAL_SPLIT_XML_GENERATION=1 \
    FLAVOR=local \
    JAVA_RUNFILES=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
    PATH=/nix/store/6ajpp69s5lf5krrdzy3mw1fs22vg1fqq-user-environment/bin \
    PYTHON_RUNFILES=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
    RUNFILES_DIR=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
    RUN_UNDER_RUNFILES=1 \
    TEST_BINARY=myproject/integration-tests \
    TEST_INFRASTRUCTURE_FAILURE_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.infrastructure_failure \
    TEST_LOGSPLITTER_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.raw_splitlogs/test.splitlogs \
    TEST_PREMATURE_EXIT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.exited_prematurely \
    TEST_SIZE=large \
    TEST_SRCDIR=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
    TEST_TARGET=//myproject:integration-tests \
    TEST_TIMEOUT=900 \
    TEST_TMPDIR=_tmp/73bce5ef685ff9d5d824b9a0b736db87 \
    TEST_UNDECLARED_OUTPUTS_ANNOTATIONS=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest/ANNOTATIONS \
    TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest \
    TEST_UNDECLARED_OUTPUTS_DIR=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs \
    TEST_UNDECLARED_OUTPUTS_MANIFEST=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest/MANIFEST \
    TEST_UNDECLARED_OUTPUTS_ZIP=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs/outputs.zip \
    TEST_UNUSED_RUNFILES_LOG_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.unused_runfiles_log \
    TEST_WARNINGS_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.warnings \
    TEST_WORKSPACE=com_canva_canva \
    TZ=UTC \
    XAUTHORITY=/dev/null \
    XML_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.xml \
  external/bazel_tools/tools/test/test-setup.sh myproject/integration-tests)
Aspect @mypy_integration//:mypy.bzl%mypy_aspect of //myproject:integration-tests up-to-date (nothing to build)
INFO: Elapsed time: 6.692s, Critical Path: 5.34s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed successfully, 2 total actions
//myproject:integration-tests                                      PASSED in 5.1s

Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 2 total actions

然而,这实际上不是我想要的。我希望能够在java代码中看到通过对记录器的调用记录的输出:

代码语言:javascript
复制
  private static final Logger logger = LoggerFactory.getLogger(
      MyProject.class);

  ...

  logger.info('It is executed')

有没有什么开关我可以用来让bazel打开日志?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-11 18:15:40

运行bazel测试时,请使用-- test _output标志。参见docs

代码语言:javascript
复制
bazel test --test_output=errors //...

上面的代码将在发生错误时显示测试输出,但您也可以请求它显示输出,而不考虑成功和失败:

代码语言:javascript
复制
bazel test --test_output=all //...
票数 18
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60165413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档