Skip to content

Commit

Permalink
Restore integration and doctest support in CI
Browse files Browse the repository at this point in the history
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:

rust-lang/rust#67295

As such, this internal crate feature will have to do.
  • Loading branch information
ebkalderon committed Jan 27, 2023
1 parent 9252ae6 commit fe456d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand All @@ -72,13 +73,19 @@ pub trait Version {
})
.map_err(Error::library)?;

#[cfg(not(feature = "ci"))]
#[cfg(windows)]
let lib = LIBRARY
.get_or_try_init(|| {
libloading::os::windows::Library::open_already_loaded(lib_path).map(Into::into)
})
.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<GetApiFn> =
lib.get(b"RENDERDOC_GetAPI\0").map_err(Error::symbol)?;

Expand Down

0 comments on commit fe456d5

Please sign in to comment.