From 168a46fd316812ad0393101cf65eef1442d2605a Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 6 Nov 2014 23:54:49 -0300 Subject: test: Improve test environment setup and error handling/reporting During test setup, we used to call a vimscript function(BeforeEachTest) that attempted to restore Nvim to it's initial state as much as possible in order to provide a clean environment for running new tests. This approach has proven to be unreliable, as some tests leave state that can affect other tests, eventually causing failures that are difficult to debug. This commit changes the 'clear' function so it will restart Nvim every time it is called, which is a slower, but more reliable solution that will simplify spotting bugs in the future. Some other improvements/fixes were also performed: - Whenever an error is detected in a handler passed to "run()", the event loop will be stopped and the error will be propagated to the main thread. - Errors and the "cleanup()" function will always send a quit command to the current Nvim instance. This should prevent memory starvation when running tests under valgrind(where each Nvim instance can consume a lot of memory). - Fixed a wrong assertion in server_requests_spec.lua. Previously the failure was undetected in a notification handler. - Fixed some tests to expect fully clean registers. The deleted cleanup function used to put an empty string in every register, but that resulted in a extra line being added. --- test/functional/legacy/006_argument_list_spec.lua | 2 +- test/functional/legacy/007_ball_buffer_list_spec.lua | 2 +- test/functional/legacy/021_control_wi_spec.lua | 2 +- test/functional/legacy/023_edit_arguments_spec.lua | 4 ++-- test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua | 2 +- test/functional/legacy/options_spec.lua | 3 +-- 6 files changed, 7 insertions(+), 8 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/006_argument_list_spec.lua b/test/functional/legacy/006_argument_list_spec.lua index 30fb9a55ff..1266a876d4 100644 --- a/test/functional/legacy/006_argument_list_spec.lua +++ b/test/functional/legacy/006_argument_list_spec.lua @@ -50,7 +50,7 @@ describe('argument list', function() execute('%d') execute('0put=@a') - execute('1d | $d') + execute('$d') eq(dedent([[ start of test file Xxx1 diff --git a/test/functional/legacy/007_ball_buffer_list_spec.lua b/test/functional/legacy/007_ball_buffer_list_spec.lua index 6d89323215..295f63f044 100644 --- a/test/functional/legacy/007_ball_buffer_list_spec.lua +++ b/test/functional/legacy/007_ball_buffer_list_spec.lua @@ -51,7 +51,7 @@ describe(':ball', function() execute('bf') execute('%d') execute('0put=@a') - execute('1d | $d') + execute('$d') expect([[ start of test file Xxx4 diff --git a/test/functional/legacy/021_control_wi_spec.lua b/test/functional/legacy/021_control_wi_spec.lua index f1f529e9a8..9fd83fec5f 100644 --- a/test/functional/legacy/021_control_wi_spec.lua +++ b/test/functional/legacy/021_control_wi_spec.lua @@ -31,7 +31,7 @@ describe('CTRL-W CTRL-I', function() -- Clean buffer and put register feed('ggdG"ap') - execute('1,2d') + execute('1d') -- The buffer should now contain: expect([[ diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua index b5955c5987..e68af9758d 100644 --- a/test/functional/legacy/023_edit_arguments_spec.lua +++ b/test/functional/legacy/023_edit_arguments_spec.lua @@ -35,8 +35,8 @@ describe(':edit', function() execute('%d') execute('0put a') - -- Remove empty lines - execute('1d | $d') + -- Remove empty line + execute('$d') -- The buffer should now contain expect([[ diff --git a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua index ed1a914c0f..42fb5ed2b3 100644 --- a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua +++ b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua @@ -25,7 +25,7 @@ describe('writing and reading a file of over 100 Kbyte', function() execute('6005yank A') execute('%d') execute('0put a') - execute('1d | $d') + execute('$d') execute('w!') expect([[ diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua index 983d168609..773acb9663 100644 --- a/test/functional/legacy/options_spec.lua +++ b/test/functional/legacy/options_spec.lua @@ -2,11 +2,10 @@ -- other tests, so restart nvim in the teardown hook local helpers = require('test.functional.helpers') -local restart, command, clear = helpers.restart, helpers.command, helpers.clear +local command, clear = helpers.command, helpers.clear describe('options', function() setup(clear) - teardown(restart) it('is working', function() command('options') -- cgit