Skip to content

Commit 0ec4d34

Browse files
committed
auto merge of #9211 : klutzy/rust/win32-fix, r=alexcrichton
2 parents 250c3d4 + 6d9c399 commit 0ec4d34

File tree

8 files changed

+47
-35
lines changed

8 files changed

+47
-35
lines changed

src/libextra/fileinput.rs

-9
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ mod test {
433433
}
434434

435435
#[test]
436-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
437436
fn test_make_path_option_vec() {
438437
let strs = [~"some/path",
439438
~"some/other/path"];
@@ -448,7 +447,6 @@ mod test {
448447
}
449448
450449
#[test]
451-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
452450
fn test_fileinput_read_byte() {
453451
let filenames = make_path_option_vec(vec::from_fn(
454452
3,
@@ -479,7 +477,6 @@ mod test {
479477
}
480478
481479
#[test]
482-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
483480
fn test_fileinput_read() {
484481
let filenames = make_path_option_vec(vec::from_fn(
485482
3,
@@ -500,7 +497,6 @@ mod test {
500497
}
501498

502499
#[test]
503-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
504500
fn test_input_vec() {
505501
let mut all_lines = ~[];
506502
let filenames = make_path_option_vec(vec::from_fn(
@@ -524,7 +520,6 @@ mod test {
524520
}
525521

526522
#[test]
527-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
528523
fn test_input_vec_state() {
529524
let filenames = make_path_option_vec(vec::from_fn(
530525
3,
@@ -547,7 +542,6 @@ mod test {
547542
}
548543

549544
#[test]
550-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
551545
fn test_empty_files() {
552546
let filenames = make_path_option_vec(vec::from_fn(
553547
3,
@@ -572,7 +566,6 @@ mod test {
572566
}
573567
574568
#[test]
575-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
576569
fn test_no_trailing_newline() {
577570
let f1 =
578571
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
@@ -598,7 +591,6 @@ mod test {
598591
599592
600593
#[test]
601-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
602594
fn test_next_file() {
603595
let filenames = make_path_option_vec(vec::from_fn(
604596
3,
@@ -630,7 +622,6 @@ mod test {
630622
631623
#[test]
632624
#[should_fail]
633-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
634625
fn test_input_vec_missing_file() {
635626
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
636627
println(line);

src/libstd/os.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -1135,18 +1135,19 @@ pub fn last_os_error() -> ~str {
11351135
#[fixed_stack_segment]; #[inline(never)];
11361136

11371137
use libc::types::os::arch::extra::DWORD;
1138-
use libc::types::os::arch::extra::LPSTR;
1138+
use libc::types::os::arch::extra::LPWSTR;
11391139
use libc::types::os::arch::extra::LPVOID;
1140+
use libc::types::os::arch::extra::WCHAR;
11401141

11411142
#[cfg(target_arch = "x86")]
11421143
#[link_name = "kernel32"]
11431144
#[abi = "stdcall"]
11441145
extern "stdcall" {
1145-
fn FormatMessageA(flags: DWORD,
1146+
fn FormatMessageW(flags: DWORD,
11461147
lpSrc: LPVOID,
11471148
msgId: DWORD,
11481149
langId: DWORD,
1149-
buf: LPSTR,
1150+
buf: LPWSTR,
11501151
nsize: DWORD,
11511152
args: *c_void)
11521153
-> DWORD;
@@ -1155,11 +1156,11 @@ pub fn last_os_error() -> ~str {
11551156
#[cfg(target_arch = "x86_64")]
11561157
#[link_name = "kernel32"]
11571158
extern {
1158-
fn FormatMessageA(flags: DWORD,
1159+
fn FormatMessageW(flags: DWORD,
11591160
lpSrc: LPVOID,
11601161
msgId: DWORD,
11611162
langId: DWORD,
1162-
buf: LPSTR,
1163+
buf: LPWSTR,
11631164
nsize: DWORD,
11641165
args: *c_void)
11651166
-> DWORD;
@@ -1173,11 +1174,11 @@ pub fn last_os_error() -> ~str {
11731174
let langId = 0x0800 as DWORD;
11741175
let err = errno() as DWORD;
11751176

1176-
let mut buf = [0 as c_char, ..TMPBUF_SZ];
1177+
let mut buf = [0 as WCHAR, ..TMPBUF_SZ];
11771178

11781179
unsafe {
11791180
do buf.as_mut_buf |buf, len| {
1180-
let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
1181+
let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
11811182
FORMAT_MESSAGE_IGNORE_INSERTS,
11821183
ptr::mut_null(),
11831184
err,
@@ -1190,9 +1191,7 @@ pub fn last_os_error() -> ~str {
11901191
}
11911192
}
11921193

1193-
do buf.as_imm_buf |buf, _len| {
1194-
str::raw::from_c_str(buf)
1195-
}
1194+
str::from_utf16(buf)
11961195
}
11971196
}
11981197

src/libstd/rt/io/file.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ fn file_test_smoke_test_impl() {
168168
}
169169

170170
#[test]
171-
#[ignore(cfg(windows))] // FIXME #8810
172171
fn file_test_io_smoke_test() {
173172
file_test_smoke_test_impl();
174173
}
@@ -236,7 +235,6 @@ fn file_test_io_non_positional_read_impl() {
236235
}
237236

238237
#[test]
239-
#[ignore(cfg(windows))] // FIXME #8810
240238
fn file_test_io_non_positional_read() {
241239
file_test_io_non_positional_read_impl();
242240
}
@@ -268,8 +266,8 @@ fn file_test_io_seeking_impl() {
268266
assert!(tell_pos_post_read == message.len() as u64);
269267
}
270268
}
269+
271270
#[test]
272-
#[ignore(cfg(windows))] // FIXME #8810
273271
fn file_test_io_seek_and_tell_smoke_test() {
274272
file_test_io_seeking_impl();
275273
}
@@ -300,8 +298,8 @@ fn file_test_io_seek_and_write_impl() {
300298
assert!(read_str == final_msg.to_owned());
301299
}
302300
}
301+
303302
#[test]
304-
#[ignore(cfg(windows))] // FIXME #8810
305303
fn file_test_io_seek_and_write() {
306304
file_test_io_seek_and_write_impl();
307305
}
@@ -340,8 +338,8 @@ fn file_test_io_seek_shakedown_impl() {
340338
unlink(filename);
341339
}
342340
}
341+
343342
#[test]
344-
#[ignore(cfg(windows))] // FIXME #8810
345343
fn file_test_io_seek_shakedown() {
346344
file_test_io_seek_shakedown_impl();
347345
}

src/libstd/rt/io/net/tcp.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,17 @@ mod test {
178178
}
179179

180180
#[test]
181-
#[ignore(cfg(windows))] // FIXME #8811
182181
fn connect_error() {
183182
do run_in_mt_newsched_task {
184183
let mut called = false;
185184
do io_error::cond.trap(|e| {
186-
assert_eq!(e.kind, ConnectionRefused);
185+
let expected_error = if cfg!(unix) {
186+
ConnectionRefused
187+
} else {
188+
// On Win32, opening port 1 gives WSAEADDRNOTAVAIL error.
189+
OtherIoError
190+
};
191+
assert_eq!(e.kind, expected_error);
187192
called = true;
188193
}).inside {
189194
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };

src/libstd/rt/io/support.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ mod test {
3333
use super::PathLike;
3434

3535
#[test]
36-
#[ignore(cfg(windows))] // FIXME #8812
3736
fn path_like_smoke_test() {
38-
let expected = "/home";
37+
let expected = if cfg!(unix) { "/home" } else { "C:\\" };
3938
let path = Path(expected);
4039
path.path_as_str(|p| assert!(p == expected));
4140
path.path_as_str(|p| assert!(p == expected));

src/libstd/rt/uv/file.rs

-2
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,11 @@ mod test {
408408
}
409409
410410
#[test]
411-
#[ignore(cfg(windows))] // FIXME #8814
412411
fn file_test_full_simple() {
413412
file_test_full_simple_impl();
414413
}
415414
416415
#[test]
417-
#[ignore(cfg(windows))] // FIXME #8814
418416
fn file_test_full_simple_sync() {
419417
file_test_full_simple_impl_sync();
420418
}

src/libstd/rt/uv/uvio.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,6 @@ fn test_read_read_read() {
17401740
}
17411741

17421742
#[test]
1743-
#[ignore(cfg(windows))] // FIXME #8816
17441743
fn test_udp_twice() {
17451744
do run_in_mt_newsched_task {
17461745
let server_addr = next_test_ip4();
@@ -1892,7 +1891,6 @@ fn file_test_uvio_full_simple_impl() {
18921891
}
18931892

18941893
#[test]
1895-
#[ignore(cfg(windows))] // FIXME #8816
18961894
fn file_test_uvio_full_simple() {
18971895
do run_in_mt_newsched_task {
18981896
file_test_uvio_full_simple_impl();

src/libstd/rt/uv/uvll.rs

+27-3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub enum uv_handle_type {
237237
UV_HANDLE_TYPE_MAX
238238
}
239239

240+
#[cfg(unix)]
240241
#[deriving(Eq)]
241242
pub enum uv_req_type {
242243
UV_UNKNOWN_REQ,
@@ -251,6 +252,31 @@ pub enum uv_req_type {
251252
UV_REQ_TYPE_MAX
252253
}
253254

255+
// uv_req_type may have additional fields defined by UV_REQ_TYPE_PRIVATE.
256+
// See UV_REQ_TYPE_PRIVATE at libuv/include/uv-win.h
257+
#[cfg(windows)]
258+
#[deriving(Eq)]
259+
pub enum uv_req_type {
260+
UV_UNKNOWN_REQ,
261+
UV_REQ,
262+
UV_CONNECT,
263+
UV_WRITE,
264+
UV_SHUTDOWN,
265+
UV_UDP_SEND,
266+
UV_FS,
267+
UV_WORK,
268+
UV_GETADDRINFO,
269+
UV_ACCEPT,
270+
UV_FS_EVENT_REQ,
271+
UV_POLL_REQ,
272+
UV_PROCESS_EXIT,
273+
UV_READ,
274+
UV_UDP_RECV,
275+
UV_WAKEUP,
276+
UV_SIGNAL_REQ,
277+
UV_REQ_TYPE_MAX
278+
}
279+
254280
#[deriving(Eq)]
255281
pub enum uv_membership {
256282
UV_LEAVE_GROUP,
@@ -298,10 +324,8 @@ fn handle_sanity_check() {
298324
}
299325

300326
#[test]
301-
#[ignore(cfg(windows))] // FIXME #8817
302-
#[fixed_stack_segment]
303-
#[inline(never)]
304327
fn request_sanity_check() {
328+
#[fixed_stack_segment]; #[inline(never)];
305329
unsafe {
306330
assert_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max());
307331
}

0 commit comments

Comments
 (0)