尝试在Windows 10上使用bazel运行gtest时出现“无法chdir”

时间:2019-12-16 05:41:25

标签: windows googletest bazel

我正在运行命令bazel run //examples:gtest_example,它将产生结果输出

INFO: Analyzed target //examples:gtest_example (1 packages loaded, 134 targets configured).
INFO: Found 1 target...
Target //examples:gtest_example up-to-date:
  bazel-bin/examples/gtest_example.exe
INFO: Elapsed time: 0.230s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Executing tests from //examples:gtest_example
-----------------------------------------------------------------------------
ERROR(tools/test/windows/tw.cc:462) value: 2 (0x00000002), arg: c:\users\mark\_bazel~1\v57xrjki\execroot\berobot\bazel-out\x64_windows-fastbuild\bin\examples\gtest_example.exe.runfiles\berobot: Could not chdir

报告的错误是准确的,因为不存在c:\users\mark\_bazel~1\v57xrjki\execroot\berobot\bazel-out\x64_windows-fastbuild\bin\examples\gtest_example.exe.runfiles\berobot,因为最终文件夹berobot不存在。如果创建它,则测试成功。但是,如果我bazel clean,测试将再次失败,直到我手动创建文件夹为止。

更多信息

/examples/BUILD中,我有

cc_test(
    name = "gtest_example",
    srcs = ["gtest_example.cc"],
    deps = [
        "@gtest//:gtest_main",
    ],
)

examples/gtest_example.cpp是普通的Google测试程序。我认为这与错误无关。

在我的WORKSPACE中,

workspace(name = "berobot")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "gtest",
    url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
     sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
    strip_prefix = "googletest-release-1.10.0",
)

Bazel文档

这里是bazel docs的引文。它说

目录布局如下:

       <workspace-name>/                 <== Working tree for the Bazel build & root of symlink forest: execRoot
          _bin/                           <== Helper tools are linked from or copied to here.

          bazel-out/                      <== All actual output of the build is under here: outputPath
            local_linux-fastbuild/        <== one subdirectory per unique target BuildConfiguration instance;
                                              this is currently encoded
              bin/                        <== Bazel outputs binaries for target configuration here: $(BINDIR)
                foo/bar/_objs/baz/        <== Object files for a cc_* rule named //foo/bar:baz
                  foo/bar/baz1.o          <== Object files from source //foo/bar:baz1.cc
                  other_package/other.o   <== Object files from source //other_package:other.cc
                foo/bar/baz               <== foo/bar/baz might be the artifact generated by a cc_binary named
                                              //foo/bar:baz
                foo/bar/baz.runfiles/     <== The runfiles symlink farm for the //foo/bar:baz executable.
                  MANIFEST
                  <workspace-name>/

最后一行是相关的。在我看来,runfiles目录中的目录<workspace-name>尚未创建。

0 个答案:

没有答案