Skip to content

Commit 6f7b11a

Browse files
committed
test suite: Output UTF-8 from cmd.exe on Windows
1 parent 6d718f2 commit 6f7b11a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/liblibc/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,7 @@ pub mod types {
18271827
pub type HINSTANCE = HANDLE;
18281828
pub type HMODULE = HINSTANCE;
18291829

1830+
pub type UINT = c_uint;
18301831
pub type LONG = c_long;
18311832
pub type PLONG = *mut c_long;
18321833

@@ -6170,7 +6171,7 @@ pub mod funcs {
61706171

61716172
pub mod kernel32 {
61726173
use types::os::arch::c95::{c_uint};
6173-
use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE,
6174+
use types::os::arch::extra::{BOOL, UINT, DWORD, SIZE_T, HMODULE,
61746175
LPCWSTR, LPWSTR,
61756176
LPWCH, LPDWORD, LPVOID,
61766177
LPCVOID, LPOVERLAPPED,
@@ -6355,6 +6356,7 @@ pub mod funcs {
63556356
lpNumberOfBytesTransferred: LPDWORD,
63566357
bWait: BOOL) -> BOOL;
63576358
pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL;
6359+
pub fn SetConsoleOutputCP(wCodePageID: UINT) -> BOOL;
63586360
}
63596361
}
63606362

src/libtest/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,17 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::Res
681681
}
682682
}
683683

684+
#[cfg(windows)]
685+
fn setup_utf8_console() {
686+
// Tests on Windows use cmd.exe commands like `set` or `cd`,
687+
// their output should be encoded in UTF-8 (issue #25268)
688+
unsafe { libc::SetConsoleOutputCP(65001); }
689+
}
690+
#[cfg(not(windows))]
691+
fn setup_utf8_console() {
692+
}
693+
694+
setup_utf8_console();
684695
let mut st = try!(ConsoleTestState::new(opts, None::<io::Stdout>));
685696
fn len_if_padded(t: &TestDescAndFn) -> usize {
686697
match t.testfn.padding() {

0 commit comments

Comments
 (0)