Merge branch 'master' of github.com:RustPython/RustPython into clippy-warnings

This commit is contained in:
Windel Bouwman
2019-08-18 16:36:15 +02:00
2 changed files with 42 additions and 2 deletions

View File

@@ -12,8 +12,9 @@ before_cache:
matrix:
fast_finish: true
include:
- name: Run Rust tests
- name: Run Rust tests(linux)
language: rust
os: linux
rust: stable
cache: cargo
script:
@@ -24,6 +25,19 @@ matrix:
# See: https://docs.travis-ci.com/user/caching/#caches-and-build-matrices
- JOBCACHE=1
- name: Run Rust tests(osx)
language: rust
os: osx
rust: stable
cache: cargo
script:
- cargo build --verbose --all
- cargo test --verbose --all
env:
# Prevention of cache corruption.
# See: https://docs.travis-ci.com/user/caching/#caches-and-build-matrices
- JOBCACHE=11
# To test the snippets, we use Travis' Python environment (because
# installing rust ourselves is a lot easier than installing Python)
- name: Python test snippets

View File

@@ -262,7 +262,7 @@ fn get_right_permission(
let others_permissions = get_permissions(others_mode);
let user_id = nix::unistd::getuid();
let groups_ids = nix::unistd::getgroups()?;
let groups_ids = getgroups()?;
if file_owner == user_id {
Ok(owner_permissions)
@@ -273,6 +273,32 @@ fn get_right_permission(
}
}
#[cfg(target_os = "macos")]
fn getgroups() -> nix::Result<Vec<Gid>> {
use libc::{c_int, gid_t};
use std::ptr;
let ret = unsafe { libc::getgroups(0, ptr::null_mut()) };
let mut groups = Vec::<Gid>::with_capacity(Errno::result(ret)? as usize);
loop {
let ret = unsafe {
libc::getgroups(
groups.capacity() as c_int,
groups.as_mut_ptr() as *mut gid_t,
)
};
return Errno::result(ret).map(|s| {
unsafe { groups.set_len(s as usize) };
groups
});
}
}
#[cfg(target_os = "linux")]
fn getgroups() -> nix::Result<Vec<Gid>> {
nix::unistd::getgroups()
}
#[cfg(unix)]
fn os_access(path: PyStringRef, mode: u8, vm: &VirtualMachine) -> PyResult<bool> {
use std::os::unix::fs::MetadataExt;