Fix t/op/magic.t on Windows
authorSteve Hay <steve.m.hay@googlemail.com>
Wed, 15 Aug 2012 08:02:12 +0000 (09:02 +0100)
committerSteve Hay <steve.m.hay@googlemail.com>
Wed, 15 Aug 2012 08:02:12 +0000 (09:02 +0100)
These tests have been failing since they were added by 613c63b465, but
we can now fix them using new Win32 APIs.

t/op/magic.t

index ebf99a7..38e4fd0 100644 (file)
@@ -70,7 +70,11 @@ sub env_is {
     if ($Is_MSWin32) {
         # cmd.exe will echo 'variable=value' but 4nt will echo just the value
         # -- Nikola Knezevic
+       require Win32;
+       my $cp = Win32::GetConsoleOutputCP();
+       Win32::SetConsoleOutputCP(Win32::GetACP());
         (my $set = `set $key`) =~ s/\r\n$/\n/;
+       Win32::SetConsoleOutputCP($cp);
         like $set, qr/^(?:\Q$key\E=)?\Q$val\E$/, $desc;
     } elsif ($Is_VMS) {
         is `write sys\$output f\$trnlnm("\Q$key\E")`, "$val\n", $desc;