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

Windows sh_test invocation and test environment different from Linux causing unexpected results #10959

Closed
sunjayBhatia opened this issue Mar 12, 2020 · 4 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@sunjayBhatia
Copy link

sunjayBhatia commented Mar 12, 2020

Description of the problem / feature request:

bazel sh_test works differently on Windows than Linux (and presumably other *nix). The path to the shell script that is run is a resolved symlink within the bazel test tree. See the minimal repro below.

When we run the tests on Linux, the path of the executable shell script that is invoked is from within the runfiles directory but on Windows it is not. This causes differences in behavior in the test environment that lead to unexpected results/failures. It appears this is simply the result of symlinks being resolved on Windows and not Linux to invoke the script.

We ran across this issue first trying to get the envoy project tests compiling and running on Windows.

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

See this repo for a minimal reproduction example: https://github.com/greenhouse-org/bazel-issue-repro/tree/c7ebe740e6cf12b58c7c7e156d9f5d2670329aad/sh_test_symlinks

Envoy example: https://github.com/envoyproxy/envoy/tree/b7a8c98cfc20e3033819228d5a9c555a6c5c6aaa/test/exe

What operating system are you running Bazel on?

Microsoft Windows [Version 10.0.17763.973] (output of ver)

What's the output of bazel info release?

release 2.0.0

Have you found anything relevant by searching the web?

Not at the moment

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

See the linked repo README.md for logs of the expected and failed outputs.

@dslomov dslomov added area-Windows Windows-specific issues and feature requests untriaged labels Mar 16, 2020
@meteorcloudy
Copy link
Member

@sunjayBhatia The root cause for this issue is that we don't build a runfiles symlink tree on Windows by default.
You have two options:

  • Enable runfiles tree on Windows by --enable_runfiles. This will requires the user has Windows admin right or Windows developer mode is enabled.
  • Use runfiles library to access data files. See the documentation here

@sunjayBhatia
Copy link
Author

sunjayBhatia commented Mar 24, 2020

@meteorcloudy we are enabling runfiles in our environment, symlinks are being created but the test program is not invoked via the symlink, the original sh script is invoked which means the test environment on Windows is not the same as Linux etc.

@sunjayBhatia
Copy link
Author

We're using this pattern of an sh wrapper script in Envoy to work around #3510 apparently

workaround script: https://github.com/envoyproxy/envoy/blob/master/bazel/sh_test_wrapper.sh

invoked via rule: https://github.com/envoyproxy/envoy/blob/93dd9459b380bdb7c4a61d8e8c14fdb88580669c/bazel/envoy_test.bzl#L315-L322

@meteorcloudy
Copy link
Member

@sunjayBhatia I see, I will make it work when runfiles is enabled on Windows.

@meteorcloudy meteorcloudy self-assigned this Mar 24, 2020
@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) type: bug labels Mar 24, 2020
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
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 P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

4 participants