ogham / rust-users

Library for Unix users and groups in Rust.
https://crates.io/crates/users
MIT License
99 stars 37 forks source link

Add support for OpenBSD #13

Closed wezm closed 7 years ago

wezm commented 7 years ago

Fixes #12

wezm commented 7 years ago

Tests pass but doc-tests fail with a cryptic error that I'm not sure about:

    Finished debug [unoptimized + debuginfo] target(s) in 3.73 secs
     Running target/debug/deps/users-7913eb1e16a8f6ad

running 17 tests
test base::test::group_by_name ... ok
test base::test::uid ... ok
test base::test::uid_for_username ... ok
test base::test::user_by_name ... ok
test base::test::user_info ... ok
test base::test::username ... ok
test base::test::username_for_uid_for_username ... ok
test mock::test::current_username ... ok
test mock::test::gid ... ok
test mock::test::group_name ... ok
test mock::test::no_current_username ... ok
test mock::test::no_gid ... ok
test mock::test::no_group_name ... ok
test mock::test::no_uid ... ok
test mock::test::no_username ... ok
test mock::test::uid ... ok
test mock::test::username ... ok

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests users
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Custom(Custom { kind: Other, error: StringError("no current exe available (short)") }) }', /usr/obj/ports/rust-1.16.0/rustc-1.16.0-src/src/libcore/result.rs:868
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: test failed

and the backtrace is generally unhelpful

stack backtrace:
   1:     0x17d29e72d8d3 - <unknown>
   2:     0x17d29e73b354 - <unknown>
   3:     0x17d29e73b020 - <unknown>
   4:     0x17d29e73b7e1 - <unknown>
   5:     0x17d29e73b642 - <unknown>
   6:     0x17d29e73b5c0 - <unknown>
   7:     0x17d29e73b541 - <unknown>
   8:     0x17d29e7530df - <unknown>
   9:     0x17d26528bd26 - <unknown>
  10:     0x17d26539d1a2 - <unknown>
  11:     0x17d2653ae035 - <unknown>
  12:     0x17d2652860fb - <unknown>
  13:     0x17d29e744196 - <unknown>
  14:     0x17d2652aa783 - <unknown>
  15:     0x17d29e73a530 - <unknown>
  16:     0x17d2f9c5d0cd - <unknown>
  17:     0x17d2159f903a - <unknown>
ltratt commented 7 years ago

The doc backtrace is a limitation of the rust ports pre-1.19 -- it's now fixed in @semarie's latest port. With your commits the tests now pass and I think this PR is worth merging (since without it things like exa can't compile on OpenBSD):

    Finished dev [unoptimized + debuginfo] target(s) in 2.73 secs
     Running target/debug/deps/users-0d27e7338d0eb9df

running 17 tests
test base::test::uid ... ok
test base::test::uid_for_username ... ok
test base::test::group_by_name ... ok
test base::test::user_info ... ok
test base::test::username ... ok
test base::test::user_by_name ... ok
test mock::test::current_username ... ok
test base::test::username_for_uid_for_username ... ok
test mock::test::gid ... ok
test mock::test::group_name ... ok
test mock::test::no_current_username ... ok
test mock::test::no_gid ... ok
test mock::test::no_group_name ... ok
test mock::test::no_uid ... ok
test mock::test::no_username ... ok
test mock::test::uid ... ok
test mock::test::username ... ok

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests users

running 6 tests
test src/lib.rs -  (line 92) ... ok
test src/lib.rs -  (line 67) ... ok
test src/switch.rs - switch::switch_user_group (line 127) ... ok
test src/lib.rs -  (line 35) ... ok
test src/mock.rs - mock (line 19) ... ok
test src/mock.rs - mock (line 42) ... ok

[Admittedly there are compiler warnings on Rust 1.19, but I don't believe they're related to this PR.]