Mercurial > vim
comparison src/testdir/test_terminal.vim @ 12043:2796a2c9fc17 v8.0.0902
patch 8.0.0902: cannot specify directory or environment for a job
commit https://github.com/vim/vim/commit/05aafed54b50b602315ae55d83a7d089804cecb0
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 11 19:12:11 2017 +0200
patch 8.0.0902: cannot specify directory or environment for a job
Problem: Cannot specify directory or environment for a job.
Solution: Add the "cwd" and "env" arguments to job options. (Yasuhiro
Matsumoto, closes #1160)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 11 Aug 2017 19:15:04 +0200 |
parents | 9897241c08b5 |
children | 278aabefc7f9 |
comparison
equal
deleted
inserted
replaced
12042:3b09a43a3830 | 12043:2796a2c9fc17 |
---|---|
6 | 6 |
7 source shared.vim | 7 source shared.vim |
8 | 8 |
9 " Open a terminal with a shell, assign the job to g:job and return the buffer | 9 " Open a terminal with a shell, assign the job to g:job and return the buffer |
10 " number. | 10 " number. |
11 func Run_shell_in_terminal() | 11 func Run_shell_in_terminal(options) |
12 let buf = term_start(&shell) | 12 let buf = term_start(&shell, a:options) |
13 | 13 |
14 let termlist = term_list() | 14 let termlist = term_list() |
15 call assert_equal(1, len(termlist)) | 15 call assert_equal(1, len(termlist)) |
16 call assert_equal(buf, termlist[0]) | 16 call assert_equal(buf, termlist[0]) |
17 | 17 |
30 call WaitFor('job_status(g:job) == "dead"') | 30 call WaitFor('job_status(g:job) == "dead"') |
31 call assert_equal('dead', job_status(g:job)) | 31 call assert_equal('dead', job_status(g:job)) |
32 endfunc | 32 endfunc |
33 | 33 |
34 func Test_terminal_basic() | 34 func Test_terminal_basic() |
35 let buf = Run_shell_in_terminal() | 35 let buf = Run_shell_in_terminal({}) |
36 if has("unix") | 36 if has("unix") |
37 call assert_match("^/dev/", job_info(g:job).tty) | 37 call assert_match("^/dev/", job_info(g:job).tty) |
38 call assert_match("^/dev/", term_gettty('')) | 38 call assert_match("^/dev/", term_gettty('')) |
39 else | 39 else |
40 call assert_match("^winpty://", job_info(g:job).tty) | 40 call assert_match("^winpty://", job_info(g:job).tty) |
49 | 49 |
50 unlet g:job | 50 unlet g:job |
51 endfunc | 51 endfunc |
52 | 52 |
53 func Test_terminal_make_change() | 53 func Test_terminal_make_change() |
54 let buf = Run_shell_in_terminal() | 54 let buf = Run_shell_in_terminal({}) |
55 call Stop_shell_in_terminal(buf) | 55 call Stop_shell_in_terminal(buf) |
56 call term_wait(buf) | 56 call term_wait(buf) |
57 | 57 |
58 setlocal modifiable | 58 setlocal modifiable |
59 exe "normal Axxx\<Esc>" | 59 exe "normal Axxx\<Esc>" |
63 exe buf . 'bwipe' | 63 exe buf . 'bwipe' |
64 unlet g:job | 64 unlet g:job |
65 endfunc | 65 endfunc |
66 | 66 |
67 func Test_terminal_wipe_buffer() | 67 func Test_terminal_wipe_buffer() |
68 let buf = Run_shell_in_terminal() | 68 let buf = Run_shell_in_terminal({}) |
69 call assert_fails(buf . 'bwipe', 'E517') | 69 call assert_fails(buf . 'bwipe', 'E517') |
70 exe buf . 'bwipe!' | 70 exe buf . 'bwipe!' |
71 call WaitFor('job_status(g:job) == "dead"') | 71 call WaitFor('job_status(g:job) == "dead"') |
72 call assert_equal('dead', job_status(g:job)) | 72 call assert_equal('dead', job_status(g:job)) |
73 call assert_equal("", bufname(buf)) | 73 call assert_equal("", bufname(buf)) |
74 | 74 |
75 unlet g:job | 75 unlet g:job |
76 endfunc | 76 endfunc |
77 | 77 |
78 func Test_terminal_hide_buffer() | 78 func Test_terminal_hide_buffer() |
79 let buf = Run_shell_in_terminal() | 79 let buf = Run_shell_in_terminal({}) |
80 quit | 80 quit |
81 for nr in range(1, winnr('$')) | 81 for nr in range(1, winnr('$')) |
82 call assert_notequal(winbufnr(nr), buf) | 82 call assert_notequal(winbufnr(nr), buf) |
83 endfor | 83 endfor |
84 call assert_true(bufloaded(buf)) | 84 call assert_true(bufloaded(buf)) |
264 bwipe! | 264 bwipe! |
265 call assert_equal([6, 20], size) | 265 call assert_equal([6, 20], size) |
266 endfunc | 266 endfunc |
267 | 267 |
268 func Test_finish_close() | 268 func Test_finish_close() |
269 return | |
270 " TODO: use something that takes much less than a whole second | |
271 echo 'This will take five seconds...' | |
269 call assert_equal(1, winnr('$')) | 272 call assert_equal(1, winnr('$')) |
270 | 273 |
271 " TODO: use something that takes much less than a whole second | |
272 if has('win32') | 274 if has('win32') |
273 let cmd = $windir . '\system32\timeout.exe 1' | 275 let cmd = $windir . '\system32\timeout.exe 1' |
274 else | 276 else |
275 let cmd = 'sleep 1' | 277 let cmd = 'sleep 1' |
276 endif | 278 endif |
302 sleep 1200 msec | 304 sleep 1200 msec |
303 call assert_equal(2, winnr('$')) | 305 call assert_equal(2, winnr('$')) |
304 | 306 |
305 bwipe | 307 bwipe |
306 endfunc | 308 endfunc |
309 | |
310 func Test_terminal_cwd() | |
311 if !has('unix') | |
312 return | |
313 endif | |
314 call mkdir('Xdir') | |
315 let buf = term_start('pwd', {'cwd': 'Xdir'}) | |
316 sleep 100m | |
317 call term_wait(buf) | |
318 call assert_equal(getcwd() . '/Xdir', getline(1)) | |
319 | |
320 exe buf . 'bwipe' | |
321 call delete('Xdir', 'rf') | |
322 endfunc | |
323 | |
324 func Test_terminal_env() | |
325 if !has('unix') | |
326 return | |
327 endif | |
328 let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) | |
329 call term_wait(buf) | |
330 call term_sendkeys(buf, "echo $TESTENV\r") | |
331 call term_wait(buf) | |
332 call Stop_shell_in_terminal(buf) | |
333 call term_wait(buf) | |
334 call assert_equal('correct', getline(2)) | |
335 | |
336 exe buf . 'bwipe' | |
337 endfunc |