|
1 | 1 | " Test for MacVim behaviors and regressions
|
2 | 2 |
|
3 | 3 | source check.vim
|
| 4 | +source term_util.vim |
4 | 5 | CheckFeature gui_macvim
|
5 | 6 |
|
6 | 7 | " Tests for basic existence of commands and options to make sure no
|
@@ -54,3 +55,43 @@ func Test_macvim_mappings()
|
54 | 55 | call feedkeys("\<ForceClick>", "xt")
|
55 | 56 | call assert_equal(5, g:marker_value)
|
56 | 57 | endfunc
|
| 58 | + |
| 59 | +" Test that we correctly set the locale to have .UTF-8 if launching from the |
| 60 | +" Dock or the $LANG env variable is not set. |
| 61 | +func Test_macvim_default_locale_utf8() |
| 62 | + CheckRunVimInTerminal |
| 63 | + if !has('terminal') || !executable('/bin/sh') |
| 64 | + return |
| 65 | + endif |
| 66 | + let buf = term_start('/bin/sh') |
| 67 | + |
| 68 | + " Wait for shell prompt. |
| 69 | + call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) |
| 70 | + |
| 71 | + " Unset the $LANG environmental variable. This causes Vim to try to set a |
| 72 | + " default one in macOS. |
| 73 | + call term_sendkeys(buf, "unset LANG\<CR>") |
| 74 | + |
| 75 | + " Run Vim and ask it to output the $LANG variable. It should be |
| 76 | + " automatically created since it doesn't exist. |
| 77 | + call term_sendkeys(buf, v:progpath |
| 78 | + \ . " --clean -X" |
| 79 | + \ . " -c 'echo $LANG'\<CR>") |
| 80 | + |
| 81 | + " Wait for Vim to come up and show something in the status line. |
| 82 | + let term_rows = term_getsize(buf)[0] |
| 83 | + call term_wait(buf) |
| 84 | + call WaitFor({-> len(term_getline(buf, term_rows)) > 0}) |
| 85 | + |
| 86 | + " Check that the locale actually has .UTF-8 in it. We can't check for |
| 87 | + " "en_US.UTF-8" because we shouldn't assume what locale the tester is |
| 88 | + " using. |
| 89 | + call assert_match('^[a-zA-Z-_]\+\.UTF-8$', term_getline(buf, term_rows), "Default locale doesn't have UTF-8 encoding set") |
| 90 | + |
| 91 | + " Cleanly exist from Vim/terminal and clean up. |
| 92 | + call term_sendkeys(buf, ":qall!\<CR>") |
| 93 | + call term_wait(buf) |
| 94 | + call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) |
| 95 | + call StopShellInTerminal(buf) |
| 96 | + exe buf . 'bwipe!' |
| 97 | +endfunc |
0 commit comments