Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc_test doesn't appear to copy data files correctly on windows #8843

Closed
mason-bially opened this issue Jul 9, 2019 · 10 comments
Closed

cc_test doesn't appear to copy data files correctly on windows #8843

mason-bially opened this issue Jul 9, 2019 · 10 comments
Labels
area-Windows Windows-specific issues and feature requests team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@mason-bially
Copy link

mason-bially commented Jul 9, 2019

Description of the problem / feature request:

On windows I can't seem to get the cc_test rule to copy data files that my tests depend on. The .runfiles folder has a MANIFEST with the links listed and an empty folder named after my WORKSPACE.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

The repo I found the bug on https://github.com/mason-bially/PEGTL

Run bazel test ... all of the file_*.cpp tests will fail on windows but succeed on another platform (there are some other tests I haven't finished setting up, notably contrib_json.cpp which are expected to fail).

What operating system are you running Bazel on?

Windows

What's the output of bazel info release?

release 0.27.1

Have you found anything relevant by searching the web?

It maybe related to my earlier issue: #8820

This issue appears to have been open for a while #4102

Any other information, logs, or outputs that you want to share?

@aiuto aiuto added area-Windows Windows-specific issues and feature requests untriaged labels Jul 11, 2019
@laszlocsomor
Copy link
Contributor

This should be better documented, sorry it isn't. (#6402)

This behavior is normal on Windows: data-dependencies on Linux/macOS create a tree of symlinks, but not on Windows, only the MANIFEST file as you noticed.

If you use Windows 10 version 1703 or newer, and enabled Developer Mode, then you can use the --enable_runfiles flag to generate the runfiles tree. This gives you the same behavior as you get on Linux and macOS: the data-dependencies are there.

Otherwise you can use one of the runfiles-libraries built into Bazel. For C++ see instructions here:

// Runfiles lookup library for Bazel-built C++ binaries and tests.

@laszlocsomor
Copy link
Contributor

I recommend using the runfiles library even if you use --enable_runfiles, because it finds the runfiles directory or runfiles manifest next to (or near) the binary, so your binary will work even when launched from bazel-bin/.

@laszlocsomor
Copy link
Contributor

The downside of using the runfiles library is that its init code is rigid: you have to use std::string and cannot use std::wstring (so you must convert argv[0] if you use wmain). That's a missing feature I never had time to implement.

@mason-bially
Copy link
Author

mason-bially commented Jul 13, 2019

Yea it also prevents gluing bazel on-top of existing tests. If you don't mind expanding, what is the limitation on windows? It seems like plenty of other bazel symlink style shenanigans work perfectly fine on it.
And, can it be fixed? If so, how would one go about doing that (like what files or classes would need to be changed)?

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Jul 15, 2019

The working symlinks are in fact junctions -- a symlink [1] that can only point to directories.
Creating junctions requires no Admin privileges, i.e. you need not run Bazel as Admin. Creating file symlinks required Admin rights until Windows 10 Creators Update (version 1703).

[1] Technically not a symlink, but it behaves like one. See https://superuser.com/a/343079

@mason-bially
Copy link
Author

mason-bially commented Jul 16, 2019

So then will --enable_runfiles run as default behavior on windows once the creators update gets pushed to the mainstream windows 10 versions?

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Jul 17, 2019

Maybe, see #8704. Do you know where mainstream windows 10 is?

@mason-bially
Copy link
Author

mason-bially commented Jul 18, 2019

@laszlocsomor I'm not sure I understand the question. I mean Windows 1703 (decoded as March 2017, though it launched in April) was over 2 years ago, and with the auto update behavior of windows 10 I sincerely doubt anyone is that far behind without being on an older OS entirely.

@laszlocsomor
Copy link
Contributor

Sorry about the confusion. You wrote:

once the creators update gets pushed to the mainstream windows 10 versions?

I thought you implied Creators Update wasn't mainstream yet. Did I misunderstand?

@mason-bially
Copy link
Author

mason-bially commented Jul 19, 2019

Oh my fault I didn't actually parse the version number in my head when I asked.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
… create

the runfiles directory. This breaks cc_tests that use data.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371805839
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
…hould

fix the test targets that use resources.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371809343
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
…hould

fix the test targets that use resources.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371809343
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
…hould

fix the test targets that use resources.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371809343
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
…hould

fix the test targets that use resources.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371809343
copybara-service bot pushed a commit to google-research/mozolm that referenced this issue May 4, 2021
…hould

fix the test targets that use resources.

See: bazelbuild/bazel#8843
PiperOrigin-RevId: 371819537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
Development

No branches or pull requests

4 participants