()
| 303 | /// Initializes per-test global state. |
| 304 | #[allow(unsafe_code)] |
| 305 | fn set() -> Self { |
| 306 | let previous_sdl_videodriver = env::var_os("SDL_VIDEODRIVER"); |
| 307 | let previous_sdl_render_driver = env::var_os("SDL_RENDER_DRIVER"); |
| 308 | // The global `TEST_LOCK` guarantees that no other SDL test mutates the process |
| 309 | // environment while these values are temporarily overridden. |
| 310 | unsafe { |
| 311 | // On Windows, the SDL2 library that we use doesn't have offscreen support |
| 312 | // and, on macOS, offscreen fails to initialize as it needs OpenGL to be |
| 313 | // present. So... for now, only do the nice thing on Linux. |
| 314 | if cfg!(target_os = "linux") { |
| 315 | env::set_var("SDL_VIDEODRIVER", "offscreen"); |
| 316 | env::set_var("SDL_RENDER_DRIVER", "software"); |
| 317 | } |
| 318 | } |
| 319 | Self { previous_sdl_videodriver, previous_sdl_render_driver } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | impl Drop for TestLockState { |
no outgoing calls