From fe456d59928ba66a70a160695791a760c8afaabc Mon Sep 17 00:00:00 2001 From: Eyal Kalderon Date: Fri, 27 Jan 2023 05:36:10 -0500 Subject: [PATCH] Restore integration and doctest support in CI This commit adds an unstable `ci` feature which reverts back the previous non-compliant opening method because it enables tests to run in CI without needing to painstakingly extract the test binary names from `cargo build --tests --message-format json` and spawn each one in `renderdoccmd capture $NAME`. Besides, this strategy is impossible anyway because doctests compiled on-the-fly by `rustdoc` and do not have external binaries with which to launch with RenderDoc. We also cannot make the `RTLD_NOLOAD` conditional, i.e. `#[cfg(any(test, doctest))]` and `#[cfg(not(any(test, doctest)))]`, due to: https://github.com/rust-lang/rust/issues/67295 As such, this internal crate feature will have to do. --- Cargo.toml | 6 ++++++ src/version.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 300093e..811e84a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,12 @@ all-features = true [badges] circle-ci = { repository = "ebkalderon/renderdoc-rs" } +[features] +default = [] + +# Private feature only intended for doctests in CI +ci = [] + [dependencies] bitflags = "1.0" float-cmp = "0.9" diff --git a/src/version.rs b/src/version.rs index 4649f84..6d42db0 100644 --- a/src/version.rs +++ b/src/version.rs @@ -61,6 +61,7 @@ pub trait Version { let lib_path = "libVkLayer_GLES_RenderDoc.so"; unsafe { + #[cfg(not(feature = "ci"))] #[cfg(unix)] let lib = LIBRARY .get_or_try_init(|| { @@ -72,6 +73,7 @@ pub trait Version { }) .map_err(Error::library)?; + #[cfg(not(feature = "ci"))] #[cfg(windows)] let lib = LIBRARY .get_or_try_init(|| { @@ -79,6 +81,11 @@ pub trait Version { }) .map_err(Error::library)?; + #[cfg(feature = "ci")] + let lib = LIBRARY + .get_or_try_init(|| Library::new(lib_path)) + .map_err(Error::library)?; + let get_api: Symbol = lib.get(b"RENDERDOC_GetAPI\0").map_err(Error::symbol)?;