bazelbuild / bazelbuild/bazel

Document how to run (GNU/Linux) GUI tests in Bazel

Open
#22,446 3 comments 0 reactions 1 assignee Claimed by @oquenchil View on GitHub
P2 team-Local-Exec type: support / not a bug (process)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

It is unclear how to run GUI tests. For example

```
bazel test //:my_gui_test --test_arg=--enable_display=true --test_env=DISPLAY --test_output=all
```

where `:my_gui_test` contains

```
if (glfwInit() != GLFW_TRUE) {
return absl::AbortedError("GLFW failed to initialize.");
}
```

fails with logs (logging code not displayed)

```
Authorization required, but no authorization protocol specified
[16:19:58.798375] [error] GLFW error 65544: X11: Failed to open display :0
```
The same code works just fine in a `cc_binary` when actually executed in the user environment. It seems that, for some reason, test code cannot connect to X11 display.

So, something is different about the test environment in this respect, but I can't seem to find any mention in the docs. Any pointers? Thanks!

### Which category does this issue belong to?

_No response_

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

Try to open a window from a test, e.g. using GLFW like in the description.

### Which operating system are you running Bazel on?

Ubuntu 24.04, Debian testing

### What is the output of `bazel info release`?

release 7.1.2

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

_No response_

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

_No response_

### Have you found anything relevant by searching the web?

Tangentially related: https://bazel.build/docs/android-instrumentation-test

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

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.