Skip to content

Commit eb63865

Browse files
committed
Apply missing formatting
1 parent b00fe8c commit eb63865

8 files changed

Lines changed: 48 additions & 44 deletions

File tree

tests/rust/wasm32-wasip1/src/bin/fd_advise.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{env, process};
2-
use wasi_tests::{open_scratch_directory};
2+
use wasi_tests::open_scratch_directory;
33

44
unsafe fn test_fd_advise(dir_fd: wasi::Fd) {
55
const FILE_NAME: &str = "fd_advise_file.cleanup";
@@ -43,11 +43,12 @@ unsafe fn test_fd_advise(dir_fd: wasi::Fd) {
4343

4444
match wasi::fd_allocate(file_fd, 100, 100) {
4545
Ok(()) => {
46-
let stat =
47-
wasi::fd_filestat_get(file_fd).expect("failed to fdstat 3");
46+
let stat = wasi::fd_filestat_get(file_fd).expect("failed to fdstat 3");
4847
assert_eq!(stat.size, 200, "file size should be 200");
49-
},
50-
Err(err) => { assert_eq!(err, wasi::ERRNO_NOTSUP, "allocating size"); }
48+
}
49+
Err(err) => {
50+
assert_eq!(err, wasi::ERRNO_NOTSUP, "allocating size");
51+
}
5152
}
5253

5354
wasi::fd_close(file_fd).expect("failed to close");

tests/rust/wasm32-wasip1/src/bin/file_allocate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
3939
wasi::fd_allocate(file_fd, 90, 20).expect("allocating size larger than current size");
4040
stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
4141
assert_eq!(stat.size, 110, "file size should increase from 100 to 110");
42-
},
43-
Err(err) => { assert_eq!(err, wasi::ERRNO_NOTSUP, "allocating size"); }
42+
}
43+
Err(err) => {
44+
assert_eq!(err, wasi::ERRNO_NOTSUP, "allocating size");
45+
}
4446
}
4547
wasi::fd_close(file_fd).expect("closing a file");
4648
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");

tests/rust/wasm32-wasip1/src/bin/path_filestat.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
1111

1212
// Create a file in the scratch directory.
1313
let open_file = |fdflags| -> Result<wasi::Fd, wasi::Errno> {
14-
let rights = wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE |
15-
wasi::RIGHTS_PATH_FILESTAT_GET;
16-
return wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, rights, 0,
17-
fdflags);
14+
let rights = wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_PATH_FILESTAT_GET;
15+
return wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, rights, 0, fdflags);
1816
};
1917

20-
let (file_fd, fdflags) =
21-
match open_file(wasi::FDFLAGS_APPEND | wasi::FDFLAGS_SYNC) {
22-
Ok(fd) => { (fd, wasi::FDFLAGS_APPEND | wasi::FDFLAGS_SYNC) }
23-
Err(wasi::ERRNO_NOTSUP) => {
24-
(open_file(wasi::FDFLAGS_APPEND).expect("opening file"),
25-
wasi::FDFLAGS_APPEND)
26-
}
27-
Err(err) => {
28-
eprintln!("error opening file: {}", err);
29-
process::exit(1);
30-
}
31-
};
18+
let (file_fd, fdflags) = match open_file(wasi::FDFLAGS_APPEND | wasi::FDFLAGS_SYNC) {
19+
Ok(fd) => (fd, wasi::FDFLAGS_APPEND | wasi::FDFLAGS_SYNC),
20+
Err(wasi::ERRNO_NOTSUP) => (
21+
open_file(wasi::FDFLAGS_APPEND).expect("opening file"),
22+
wasi::FDFLAGS_APPEND,
23+
),
24+
Err(err) => {
25+
eprintln!("error opening file: {}", err);
26+
process::exit(1);
27+
}
28+
};
3229

3330
assert!(
3431
file_fd > libc::STDERR_FILENO as wasi::Fd,

tests/rust/wasm32-wasip3/src/bin/filesystem-advise.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ wit_bindgen::generate!({
1616
generate_all
1717
});
1818

19-
use wasi::filesystem::types::Descriptor;
2019
use wasi::filesystem::types::Advice;
20+
use wasi::filesystem::types::Descriptor;
2121
use wasi::filesystem::types::{DescriptorFlags, ErrorCode, OpenFlags, PathFlags};
2222

2323
async fn test_advise(dir: &Descriptor) {

tests/rust/wasm32-wasip3/src/bin/filesystem-flags-and-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ wit_bindgen::generate!({
1717
});
1818

1919
use wasi::filesystem::types::Descriptor;
20-
use wasi::filesystem::types::{DescriptorFlags, ErrorCode, OpenFlags, PathFlags};
2120
use wasi::filesystem::types::DescriptorType;
21+
use wasi::filesystem::types::{DescriptorFlags, ErrorCode, OpenFlags, PathFlags};
2222

2323
async fn test_flags_and_type(dir: &Descriptor) {
2424
// get-flags: async func() -> result<descriptor-flags, error-code>;

tests/rust/wasm32-wasip3/src/bin/filesystem-hard-links.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,24 @@ async fn test_hard_links(dir: &Descriptor) {
4242
// FIXME: https://github.com/WebAssembly/wasi-filesystem/issues/191
4343
// assert_eq!(ln_follow("parent/foo", "a.txt").await,
4444
// Err(ErrorCode::NotPermitted));
45-
assert_eq!(ln("parent/foo", "a.txt").await,
46-
Err(ErrorCode::NotPermitted));
47-
assert_eq!(ln("a.txt", "parent/foo").await,
48-
Err(ErrorCode::NotPermitted));
45+
assert_eq!(
46+
ln("parent/foo", "a.txt").await,
47+
Err(ErrorCode::NotPermitted)
48+
);
49+
assert_eq!(
50+
ln("a.txt", "parent/foo").await,
51+
Err(ErrorCode::NotPermitted)
52+
);
4953
ln("a.txt", "c.cleanup").await.unwrap();
5054
rm("c.cleanup").await.unwrap();
5155
mkdir("d.cleanup").await.unwrap();
5256
ln("a.txt", "d.cleanup/q.txt").await.unwrap();
5357
rm("d.cleanup/q.txt").await.unwrap();
5458
// https://github.com/WebAssembly/wasi-filesystem/issues/184
55-
assert_eq!(ln("d.cleanup", "e.cleanup").await,
56-
Err(ErrorCode::NotPermitted));
59+
assert_eq!(
60+
ln("d.cleanup", "e.cleanup").await,
61+
Err(ErrorCode::NotPermitted)
62+
);
5763
rmdir("d.cleanup").await.unwrap();
5864
}
5965

tests/rust/wasm32-wasip3/src/bin/filesystem-read-directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ wit_bindgen::generate!({
1717
});
1818

1919
use wasi::filesystem::types::Descriptor;
20-
use wasi::filesystem::types::DirectoryEntry;
2120
use wasi::filesystem::types::DescriptorType;
21+
use wasi::filesystem::types::DirectoryEntry;
2222

2323
async fn test_read_directory(dir: &Descriptor) {
2424
// read-directory: async func() -> tuple<stream<directory-entry>, future<result<_, error-code>>>;

tests/rust/wasm32-wasip3/src/bin/http-response.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@ wit_bindgen::generate!({
1313
generate_all
1414
});
1515

16-
use wasi::http::types::{
17-
Fields, HeaderError, Response
18-
};
16+
use wasi::http::types::{Fields, HeaderError, Response};
1917

2018
fn test_response_field_default_values(response: &Response) {
2119
assert_eq!(response.get_status_code(), 200);
2220
}
2321

2422
fn test_status_codes(response: &Response) {
25-
for valid in [100, 101,
26-
200, 201, 202, 203, 204, 205, 206,
27-
300, 301, 302, 303, 304, 305, 306, 307, 308,
28-
400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
29-
410, 411, 412, 413, 414, 415, 416, 417,
30-
421, 422, 426,
31-
500, 501, 502, 503, 504, 505] {
23+
for valid in [
24+
100, 101, 200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307, 308,
25+
400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
26+
421, 422, 426, 500, 501, 502, 503, 504, 505,
27+
] {
3228
assert_eq!(response.set_status_code(valid as u16), Ok(()));
3329
assert_eq!(response.get_status_code(), valid);
3430
}
@@ -38,8 +34,10 @@ fn test_status_codes(response: &Response) {
3834
}
3935

4036
fn test_immutable_headers(headers: &Fields) {
41-
assert_eq!(headers.append("Last-Modified", b"whatever"),
42-
Err(HeaderError::Immutable));
37+
assert_eq!(
38+
headers.append("Last-Modified", b"whatever"),
39+
Err(HeaderError::Immutable)
40+
);
4341
}
4442

4543
fn test_headers_same(left: &Fields, right: &Fields) {

0 commit comments

Comments
 (0)