Mercurial > vim
comparison src/testdir/test_clientserver.vim @ 13798:415185e2c970 v8.0.1771
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
commit https://github.com/vim/vim/commit/50182fa84e20a0547f3e2bd6683ef799fcd27855
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 28 21:34:40 2018 +0200
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Problem: In tests, when WaitFor() fails it doesn't say why. (James McCoy)
Solution: Add WaitForAssert(), which produces an assert error when it fails.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 28 Apr 2018 21:45:06 +0200 |
parents | 87ffb7f85b28 |
children | ba7727889385 |
comparison
equal
deleted
inserted
replaced
13797:2dc47db0d0d5 | 13798:415185e2c970 |
---|---|
26 endif | 26 endif |
27 | 27 |
28 let name = 'XVIMTEST' | 28 let name = 'XVIMTEST' |
29 let cmd .= ' --servername ' . name | 29 let cmd .= ' --servername ' . name |
30 let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) | 30 let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) |
31 call WaitFor({-> job_status(job) == "run"}) | 31 call WaitForAssert({-> assert_equal("run", job_status(job))}) |
32 | 32 |
33 " Takes a short while for the server to be active. | 33 " Takes a short while for the server to be active. |
34 " When using valgrind it takes much longer. | 34 " When using valgrind it takes much longer. |
35 call WaitFor('serverlist() =~ "' . name . '"') | 35 call WaitForAssert({-> assert_match(name, serverlist())}) |
36 call assert_match(name, serverlist()) | |
37 | 36 |
38 call remote_foreground(name) | 37 call remote_foreground(name) |
39 | 38 |
40 call remote_send(name, ":let testvar = 'yes'\<CR>") | 39 call remote_send(name, ":let testvar = 'yes'\<CR>") |
41 call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"') | 40 call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"') |
52 else | 51 else |
53 call remote_send(name, ":gui -f\<CR>") | 52 call remote_send(name, ":gui -f\<CR>") |
54 endif | 53 endif |
55 " Wait for the server to be up and answering requests. | 54 " Wait for the server to be up and answering requests. |
56 sleep 100m | 55 sleep 100m |
57 call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""') | 56 call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")}) |
58 call assert_true(remote_expr(name, "v:version", "", 1) != "") | |
59 | 57 |
60 call remote_send(name, ":let testvar = 'maybe'\<CR>") | 58 call remote_send(name, ":let testvar = 'maybe'\<CR>") |
61 call WaitFor('remote_expr("' . name . '", "testvar", "", 1) == "maybe"') | 59 call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))}) |
62 call assert_equal('maybe', remote_expr(name, "testvar", "", 2)) | |
63 endif | 60 endif |
64 | 61 |
65 call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241') | 62 call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241') |
66 | 63 |
67 " Expression evaluated locally. | 64 " Expression evaluated locally. |
92 call assert_equal('another', g:peek_result) | 89 call assert_equal('another', g:peek_result) |
93 call assert_equal('another', remote_read(g:myserverid, 2)) | 90 call assert_equal('another', remote_read(g:myserverid, 2)) |
94 | 91 |
95 call remote_send(name, ":qa!\<CR>") | 92 call remote_send(name, ":qa!\<CR>") |
96 try | 93 try |
97 call WaitFor({-> job_status(job) == "dead"}) | 94 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
98 finally | 95 finally |
99 if job_status(job) != 'dead' | 96 if job_status(job) != 'dead' |
100 call assert_report('Server did not exit') | 97 call assert_report('Server did not exit') |
101 call job_stop(job, 'kill') | 98 call job_stop(job, 'kill') |
102 endif | 99 endif |