Commit Graph

255 Commits

Author SHA1 Message Date
Justin M. Keyes
5f5f2d8945 test: rmdir(): recursively delete 2016-06-06 11:04:09 -04:00
KillTheMule
48b2faead8 test/functional/helpers.lua: Fix dedent() #4735
The character class %s also matches a newline in lua, that's not really what we
want here. It works in the other cases in this function, so I left them, but
the final gsub should preserve newlines.
2016-05-10 06:59:45 -04:00
KillTheMule
360d0513d1 Satisfy testlint.
For that, make luatest ignore the preload.lua files.
2016-04-28 19:30:17 +02:00
Thiago de Arruda
c18d5917e3 Update lua client to 0.0.1-24
The new version of the lua client uses libmpack as a backend, and some test
scripts had to be updated to reflect that.
2016-04-13 09:21:32 -03:00
Thiago de Arruda
704f3dd855 Synchronize shada reset helper with other functional tests 2016-04-11 23:07:52 -03:00
Björn Linse
8eb8ebf905 tests: update tests to use [gs]et_lines instead of [gs]et_line_slice 2016-04-01 11:29:51 +02:00
Thiago de Arruda
34a1bc1a46 Remove goto statement in lua code.
`goto` is another luajit extension not compatible with 5.1.
2016-03-07 03:58:35 -03:00
Thiago de Arruda
35d8d10a6a Remove dependency on ffi module 2016-03-07 03:58:29 -03:00
watiko
59b04d856b tests: Make helper.source() return tempname. 2016-01-10 10:44:57 +09:00
Björn Linse
70f6e2ce52 encoding: update tests 2016-01-02 23:22:13 +01:00
Rui Abreu Ferreira
a48508de0d test/functional: Fix api/vim_spec.lua.
On Windows the default file format is DOS i.e. newlines are \r\n
instead of \n.
2015-12-31 23:28:55 -05:00
Marco Hinz
d9fbc1865b test/functional: clean up according to luacheck (part 2) 2015-11-23 13:57:21 +01:00
ZyX
6b17d35ff1 functests: Use . for various folder defaults in tests 2015-10-23 15:56:51 +03:00
ZyX
1162962d8b functests: Refactor tests:
- Remove unused variables.
- Do not use helpers.nvim_feed in most cases.
- Do not use helpers.nvim and helpers.nvim_eval at all.
- Add helpers.funcs and helpers.\*meths special tables. Indexing such table 
  creates functions which call helpers.call or helpers.nvim (and similar) with 
  first argument equal to table index.
2015-10-08 22:01:12 +03:00
ZyX
b249529676 functests: Make one recover_spec test also use gdb or valgrind 2015-10-08 22:00:45 +03:00
ZyX
e2994a3c62 shada,functests: Test how ShaDa support code reacts on errors
Some notes:
- Replaced msgpack_unpacker usage with regular xmalloc’ed buffer. Also since
  msgpack_unpack_next (as well as msgpack_unpacker_next) is not ever going to
  return MSGPACK_UNPACK_EXTRA_BYTES this condition was checked manually.
  Function that does return this status is msgpack_unpack, but it is marked as
  obsolete.
- Zero type is checked prior to main switch in shada_read_next_item because
  otherwise check would be skipped.
- Zeroing entry at the start of shada_read_next_item makes it safer.
- dedent('') does not work.
- v:oldfiles list is only replaced with bang, if it is NULL or empty.
2015-10-08 22:00:15 +03:00
ZyX
e143be7f3d functests: Add tests for ShaDa variables dumping/reading 2015-10-08 21:59:52 +03:00
Thiago de Arruda
c1edd07990 shell: Ensure silent bang mappings won't cut output
Setting `msg_didout` after `call_shell` is enough as it will cause
`hit_return_msg()` to print on next line.

Close #3269
2015-10-01 15:22:48 -03:00
ZyX
10fd95a9ea functests/helpers: Add exc_exec function that checks the exception 2015-09-19 01:54:43 +03:00
Björn Linse
c8aaabc09c api: vim_err_write: add tests for multiline handling 2015-09-16 21:42:57 +02:00
Björn Linse
087f3bacaf encoding: test that &encoding cannot be changed
Helped-By: Justin M. Keyes <justinkz@gmail.com>
2015-09-08 10:56:15 +02:00
Björn Linse
ffff2c9c47 encoding: Update handling of encoding in tests
Always run tests with encoding=utf-8, regardless of user locale
Don't set &encoding after startup in tests

Helped-By: Michael Reed <m.reed@mykolab.com>
2015-09-08 10:54:31 +02:00
Björn Linse
2b6d1546ec test59: Store all text as utf-8 and convert when needed 2015-08-26 10:31:26 +02:00
Felipe Morales
45121a267f defaults: set 'laststatus' to 2. #2876 2015-08-24 00:48:32 -04:00
Justin M. Keyes
d21690a66e test: cover :grep
References #3156
2015-08-11 12:49:50 -04:00
Marco Hinz
0f34b256aa Test: add new helper function: rmdir()
- lfs.rmdir() only removes empty directories

- os.remove() supercedes lfs.rmdir(); removes files and empty directories

- helpers.rmdir() first removes all files within a directory, then the
  directory itself
2015-07-20 22:19:07 +02:00
Lucas Hoffmann
652ee0348c tests: Use write_file() in source(). 2015-06-30 18:06:06 +02:00
Lucas Hoffmann
f0850775bf tests: Add helpers.write_file() to write short files. 2015-06-30 18:06:06 +02:00
Felipe Morales
8e3f67f2a0 defaults: enable 'autoindent' #2857
Re: https://github.com/neovim/neovim/issues/2676
2015-06-20 14:02:56 -04:00
Justin M. Keyes
04806dee4b test: helpers.lua: add temporary set_session() function
This function is needed until helpers.lua is refactored to support
multiple sessions.
2015-04-12 01:02:58 -04:00
Thiago de Arruda
1ee7ca7bc0 test: Improve functional test debuggability and efficiency
- Read TEST_TAG/TEST_FILTER env vars from cmake/RunTests.cmake. Setting these
  environment variables will pass --tags/--filter to busted, which can used to
  filter which tests are executed.
- Remove calls to nvim msgpack-rpc API outside tests. This removes the
  requirement of having a static `clear` call in test/functional/helpers.lua
- Use the new busted command-line option "--lazy" to ensure the setup/teardown
  hooks are only executed when a suite runs at least one test.

Now its possible to run/debug a single test like this:

```sh
TEST_FILTER='some test string' make test
```

Which will only run tests containing "some test string" in the title.
Another option is:

```sh
TEST_TAG=some-tag make test
```

After putting #some-tag into the test title. This also improves debugging
experience because there will be no unnecessary gdbserver instances whe GDB=1 is
passed.
2015-03-24 12:46:15 -03:00
Thiago de Arruda
47e90ea1c5 test: Extract code to spawn nvim into the "spawn" helper function
This is can be used for spawning nvim outside a test context. Also refactor
screen.lua to use this function when loading the color map(It is better because
the GDB/VALGRIND environment variables are ignored)
2015-03-24 12:46:15 -03:00
John Szakmeister
ea35062589 Merge pull request #2075 from jszakmeister/dont-hardcode-tty-test-path
tests: don't hardcode the path to tty-test
2015-03-01 15:24:00 -05:00
John Szakmeister
235909044a tests: require luassert in the helpers
This is necessary for newer versions of Busted, otherwise assert will be
nil and the tests will die.

Note: this does not mean the tests now work with the latest Busted.
There are still several issues preventing that from happening.
2015-03-01 09:00:27 -05:00
John Szakmeister
c1e8d12aa3 tests: don't hardcode the path to tty-test
This fixes the build for those who drive the build directly using
CMake.
2015-02-28 10:46:56 -05:00
Thiago de Arruda
e6208df73e test: Add synchronization helper for functional tests
The `wait` function will only return after all input has been processed by nvim.
It is useful to time assertions correctly.
2015-02-16 23:17:38 -03:00
Thiago de Arruda
4c92a0baca deps: Add Luajit compilation flags to improve debugging 2015-02-10 09:57:24 -03:00
Florian Walch
2eda611cbc Travis: Fail fast, disable JIT for functional tests.
Disable JIT to find cause for random `PANIC: unprotected error in call to Lua API` on Travis (OS X).
2015-02-02 17:23:03 +01:00
Thiago de Arruda
41225fe4f6 test: Fix hanging test suite after failures
When a test that fails leaves nvim in a 'Press Enter...' state, the whole suite
will hang because the `qa!` command executed before the next test won't be
processed until '<enter>' is sent.

Now the lua client can send a signal with when `Session:exit()` is called, so
the `qa!` request is no longer necessary.

Also:

- Set noswapfile at startup to prevent tests from leaving .s* swap files(should
  also improve test environment determinism)
- Use `assert(false, msg) instead of `error(msg)` to report screen assertion
  failures.
2015-01-23 18:58:19 -03:00
Thiago de Arruda
3f0983e400 test: Set some options to reduce nondeterminism in functional tests
- shortmess+=I: Remove intro screen
- background=light: Disregard COLORFGBG environment variable
2015-01-22 08:54:42 -03:00
Thiago de Arruda
1192fbd08a test: Add screen test facility
- Add screen.lua which implements a remote screen to verify screen state by
  tests under functional/ui
- Add some basic screen/highlight tests
2014-12-09 08:36:16 -03:00
Thiago de Arruda
a31b06c44d deps: Update lua client 2014-12-05 14:23:37 -03:00
Thiago de Arruda
99809903bb deps: Update bundled lua client version
The new version fixes defunct processes which causes random test failures on
some systems(#1519)
2014-11-25 14:47:54 -03:00
Thiago de Arruda
aa22612112 test: Add gdbserver support on helpers.lua
The $GDB env var can be set to run tests under gdbserver. If $VALGRIND is also
set, it will add the --vgdb=yes command-line option to valgrind instead of
starting gdbserver.
2014-11-23 08:56:43 -03:00
Thiago de Arruda
179c51319d test: Refactor functional helpers to use vim_input
The vim_input function accepts raw terminal input and so is better to emulate
real user, especially because it is not deferred as vim_feedkeys.

Using this function required a number of changes:

- expect() was refactored to use curbuf_contents()
- The vim_eval function in request() was moved to curbuf_contents(). For most
  cases this is enough(we only care for synchronizing api calls with user input
  when verifying buffer contents).
- <C-@>(NUL) is preprocessed before being passed to replace_termcodes.
- Legacy test 4 had a bug that only became visible when using vim_input, it is
  fixed now.
- An extra blank line deletion was required for test 101

The last two items show that vim_feedkeys because it is not 100% equivalent to
receiving terminal input.
2014-11-21 15:39:04 -03:00
Rainer Borene
e0332e7f7c legacy tests: implement :source helper method. 2014-11-20 21:06:37 -03:00
Thiago de Arruda
63a98fca55 test: Fix nondeterminism in tests with notifications
Tests which spin the event loop and stop it in a notification handler have a
chance of re-entering the event loop due to the `vim_eval` call in the
`request()` helper(assuming the request call is what triggered the
notification). Since this will cause an error to be thrown by the lua client,
don't send the extra `vim_eval` request when the loop has been stopped.
2014-11-10 18:46:09 -03:00
Thiago de Arruda
88a49148b3 test: Pass --show-possibly-lost=no to valgrind in helpers.lua
This command-line flag will suppress all warnings about interior pointers,
which are used in hashtab.c.
2014-11-07 01:40:18 -03:00
Thiago de Arruda
168a46fd31 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.
2014-11-07 00:55:58 -03:00
Rainer Borene
649aeceb38 legacy tests: improvements to functional helpers.lua
- Clean vim registers and functions before each test
- Add eval workaround to the request helper method
- Export dedent method
2014-11-04 12:57:32 -03:00
Thiago de Arruda
53ce5493fa test: Small fixes and improvements to functional helpers.lua
- Move the cleanup function definition into `restart()` so restart can be
  selectively used as a hook
- Improve error handling: Before this, errors while running the event loop would
  cause busted to get stuck. Now the error is properly raised by stopping the
  event loop first.
2014-10-28 09:11:40 -03:00
Thiago de Arruda
0c2ec77ae0 test: Use lua to perform sanity API checks
Sanity API checks made by the python-client in the api-python travis target were
converted to lua and will now live in this repository. This will simplify
performing breaking changes to the API as it won't be necessary to send parallel
PRs the python-client.
2014-10-16 14:06:54 -03:00
Thiago de Arruda
69561ea922 test: Remove run-functional-tests.py
Now that the lua client is available, python/lupa are no longer necessary to run
the functional tests. The helper functions previously defined in
run-functional-tests.py were adapted to test/functional/helpers.lua.
2014-10-16 09:21:37 -03:00
Thiago de Arruda
f6a008a182 test: Add 'eval' functional helper
The eval helper transforms vimL expressions into lua tables, it's useful for
verifying function output.
2014-10-01 09:31:57 -03:00
Thiago de Arruda
42d5b526b9 test: Replace vroom by lua/busted for functional tests
The 'lupa' python package provides a simple way to seamless integrate lua and
python code.

This commit replaces vroom by a python script that exposes the 'neovim' package
to a lua state, and invokes busted to run functional tests. This is a temporary
solution that will enable writing functional tests using lua/bused while a lua
client library is not available.

The reason for dropping vroom is flexibility: Lua/busted has a nice DSL-style
syntax while also providing the customization power of a full programming
language. Another reason is to use a single framework for unit/functional tests.

Two other changes were performed in this commit:

- Instead of "gcc-unittest/gcc-ia32", the travis builds for gcc are now
  identified by "gcc/gcc-32". They will run unit/functional tests for both 64
  and 32 bits.
- Old integration tests(in src/nvim/testdir) are now ran by the 'oldtest' target
2014-09-30 17:37:16 -03:00