Skip to content

Move back to the main nightly channel #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,9 @@ jobs:
- build: beta
os: ubuntu-latest
rust: beta
# FIXME need to wait for rust-lang/rust#67065 to get into nightlies,
# and then this can be updated to `nightly` again.
- build: nightly
os: ubuntu-latest
rust: nightly-2019-12-03
rust: nightly
- build: macos
os: macos-latest
rust: stable
Expand Down Expand Up @@ -186,7 +184,7 @@ jobs:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2019-08-15
toolchain: nightly
- uses: ./.github/actions/binary-compatible-builds
- run: mkdir crates/misc/py/wheelhouse
shell: bash
Expand Down
36 changes: 20 additions & 16 deletions crates/test-programs/wasi-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
pub mod utils;
pub mod wasi_wrappers;

use libc;
use std::ffi::CString;
use std::io;
use wasi_old::wasi_unstable;

/// Opens a fresh file descriptor for `path` where `path` should be a preopened
/// directory. This is intended to be used with `wasi_unstable`, not with
/// `wasi_snapshot_preview1`. This is getting phased out and will likely be
/// deleted soon.
pub fn open_scratch_directory(path: &str) -> Result<wasi_unstable::Fd, String> {
// Open the scratch directory.
let dir_fd: wasi_unstable::Fd = unsafe {
let cstr = CString::new(path.as_bytes()).unwrap();
libc::open(cstr.as_ptr(), libc::O_RDONLY | libc::O_DIRECTORY)
} as wasi_unstable::Fd;
unsafe {
for i in 3.. {
let stat = match wasi_unstable::fd_prestat_get(i) {
Ok(s) => s,
Err(_) => break,
};
if stat.pr_type != wasi::PREOPENTYPE_DIR {
continue;
}
let mut dst = Vec::with_capacity(stat.u.dir.pr_name_len);
if wasi::fd_prestat_dir_name(i, dst.as_mut_ptr(), dst.capacity()).is_err() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is it OK to mix wasi_unstable and wasi for the syscalls here? I mean, first, we call wasi_unstable::fd_prestat_get just to later on call wasi::fd_prestat_dir_name. It might be OK, but definitely looks confusing!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh oops this was a mistake! I'll switch this as well to match the above

continue;
}
dst.set_len(stat.u.dir.pr_name_len);
if dst == path.as_bytes() {
return Ok(wasi::path_open(i, 0, ".", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and here as well, we call wasi::path_open instead of wasi_unstable::path_open.

.expect("failed to open dir"));
}
}

if (dir_fd as std::os::raw::c_int) < 0 {
Err(format!(
"error opening scratch directory '{}': {}",
path,
io::Error::last_os_error()
))
} else {
Ok(dir_fd)
Err(format!("failed to find scratch dir"))
}
}

Expand Down