diff options
author | Bryant Mairs <bryantmairs@google.com> | 2017-12-10 19:20:24 -0800 |
---|---|---|
committer | Bryant Mairs <bryantmairs@google.com> | 2017-12-10 19:20:30 -0800 |
commit | 2e8560edc1d8a041da3dbac8050a300958b9a087 (patch) | |
tree | 6dbd1d374c5c9b9ba0e084b4b56f0b5f24754be9 | |
parent | d374a1ecd3f69027a2ce28e87806f459ef3f9105 (diff) | |
download | nix-2e8560edc1d8a041da3dbac8050a300958b9a087.zip |
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`.
-rw-r--r-- | src/unistd.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index 52dfbb70..c6ad6912 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1124,12 +1124,24 @@ pub fn getgroups() -> Result<Vec<Gid>> { /// specific user and group. For example, given the user `www-data` with UID /// `33` and the group `backup` with the GID `34`, one could switch the user as /// follows: -/// ``` +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box<Error>> { /// let uid = Uid::from_raw(33); /// let gid = Gid::from_raw(34); /// setgroups(&[gid])?; /// setgid(gid)?; /// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } /// ``` #[cfg(not(any(target_os = "ios", target_os = "macos")))] pub fn setgroups(groups: &[Gid]) -> Result<()> { @@ -1245,13 +1257,26 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> { /// UID and GID for the user in the system's password database (usually found /// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`, /// respectively, one could switch the user as follows: -/// ``` +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use std::ffi::CString; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box<Error>> { /// let user = CString::new("www-data").unwrap(); /// let uid = Uid::from_raw(33); /// let gid = Gid::from_raw(33); /// initgroups(&user, gid)?; /// setgid(gid)?; /// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } /// ``` #[cfg(not(any(target_os = "ios", target_os = "macos")))] pub fn initgroups(user: &CStr, group: Gid) -> Result<()> { |