Skip to content

Commit 2e8560e

Browse files
author
Bryant Mairs
committed
Fix doctest that weren't run with the old doctest parser
The switch to Pulldown for the Markdown parser for Rustdoc has revealed that there were a large number of doctests that weren't being run. These tests failed to compile before, but will also fail to run because they attach to arbitrary user and group IDs, which likely don't exist on the system. These are therefore marked as `no_run`.
1 parent d374a1e commit 2e8560e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/unistd.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -1124,12 +1124,24 @@ pub fn getgroups() -> Result<Vec<Gid>> {
11241124
/// specific user and group. For example, given the user `www-data` with UID
11251125
/// `33` and the group `backup` with the GID `34`, one could switch the user as
11261126
/// follows:
1127-
/// ```
1127+
///
1128+
/// ```rust,no_run
1129+
/// # use std::error::Error;
1130+
/// # use nix::unistd::*;
1131+
/// #
1132+
/// # fn try_main() -> Result<(), Box<Error>> {
11281133
/// let uid = Uid::from_raw(33);
11291134
/// let gid = Gid::from_raw(34);
11301135
/// setgroups(&[gid])?;
11311136
/// setgid(gid)?;
11321137
/// setuid(uid)?;
1138+
/// #
1139+
/// # Ok(())
1140+
/// # }
1141+
/// #
1142+
/// # fn main() {
1143+
/// # try_main().unwrap();
1144+
/// # }
11331145
/// ```
11341146
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
11351147
pub fn setgroups(groups: &[Gid]) -> Result<()> {
@@ -1245,13 +1257,26 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
12451257
/// UID and GID for the user in the system's password database (usually found
12461258
/// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`,
12471259
/// respectively, one could switch the user as follows:
1248-
/// ```
1260+
///
1261+
/// ```rust,no_run
1262+
/// # use std::error::Error;
1263+
/// # use std::ffi::CString;
1264+
/// # use nix::unistd::*;
1265+
/// #
1266+
/// # fn try_main() -> Result<(), Box<Error>> {
12491267
/// let user = CString::new("www-data").unwrap();
12501268
/// let uid = Uid::from_raw(33);
12511269
/// let gid = Gid::from_raw(33);
12521270
/// initgroups(&user, gid)?;
12531271
/// setgid(gid)?;
12541272
/// setuid(uid)?;
1273+
/// #
1274+
/// # Ok(())
1275+
/// # }
1276+
/// #
1277+
/// # fn main() {
1278+
/// # try_main().unwrap();
1279+
/// # }
12551280
/// ```
12561281
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
12571282
pub fn initgroups(user: &CStr, group: Gid) -> Result<()> {

0 commit comments

Comments
 (0)