README.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. This directory contains tests for various Vim features.
  2. For testing an indent script see runtime/indent/testdir/README.txt.
  3. If it makes sense, add a new test method to an already existing file. You may
  4. want to separate it from other tests with comment lines.
  5. TO ADD A NEW STYLE TEST:
  6. 1) Create a test_<subject>.vim file.
  7. 2) Add test_<subject>.res to NEW_TESTS_RES in Make_all.mak in alphabetical
  8. order.
  9. 3) Also add an entry "test_<subject>" to NEW_TESTS in Make_all.mak.
  10. 4) Use make test_<subject> to run a single test.
  11. At 2), instead of running the test separately, it can be included in
  12. "test_alot". Do this for quick tests without side effects. The test runs a
  13. bit faster, because Vim doesn't have to be started, one Vim instance runs many
  14. tests.
  15. At 4), to run a test in GUI, add "GUI_FLAG=-g" to the make command.
  16. What you can use (see test_assert.vim for an example):
  17. - Call assert_equal(), assert_true(), assert_false(), etc.
  18. - Use assert_fails() to check for expected errors.
  19. - Use try/catch to avoid an exception aborts the test.
  20. - Use test_alloc_fail() to have memory allocation fail. This makes it possible
  21. to check memory allocation failures are handled gracefully. You need to
  22. change the source code to add an ID to the allocation. Add a new one to
  23. alloc_id_T, before aid_last.
  24. - Use test_override() to make Vim behave differently, e.g. if char_avail()
  25. must return FALSE for a while. E.g. to trigger the CursorMovedI autocommand
  26. event. See test_cursor_func.vim for an example.
  27. - If the bug that is being tested isn't fixed yet, you can throw an exception
  28. with "Skipped" so that it's clear this still needs work. E.g.: throw
  29. "Skipped: Bug with <c-e> and popupmenu not fixed yet"
  30. - The following environment variables are recognized and can be set to
  31. influence the behavior of the test suite (see runtest.vim for details)
  32. - $TEST_MAY_FAIL=Test_channel_one - ignore those failing tests
  33. - $TEST_FILTER=Test_channel - only run test that match this pattern
  34. - $TEST_SKIP_PAT=Test_channel - skip tests that match this pattern
  35. - $TEST_NO_RETRY=yes - do not try to re-run failing tests
  36. You can also set them in Vim:
  37. :let $TEST_MAY_FAIL = 'Test_channel_one'
  38. :let $TEST_FILTER = '_set_mode'
  39. :let $TEST_SKIP_PAT = 'Test_loop_forever'
  40. :let $TEST_NO_RETRY = 'yes'
  41. Use an empty string to revert, e.g.:
  42. :let $TEST_FILTER = ''
  43. - See the start of runtest.vim for more help.
  44. TO ADD A SCREEN DUMP TEST:
  45. Mostly the same as writing a new style test. Additionally, see help on
  46. "terminal-dumptest". Put the reference dump in "dumps/Test_func_name.dump".
  47. OLD STYLE TESTS:
  48. There are a few tests that are used when Vim was built without the +eval
  49. feature. These cannot use the "assert" functions, therefore they consist of a
  50. .in file that contains Normal mode commands between STARTTEST and ENDTEST.
  51. They modify the file and the result gets written in the test.out file. This
  52. is then compared with the .ok file. If they are equal the test passed. If
  53. they differ the test failed.
  54. RUNNING THE TESTS:
  55. To run a single test from the src directory:
  56. $ make test_<name>
  57. The below commands should be run from the src/testdir directory.
  58. To run a single test:
  59. $ make test_<name>.res
  60. The file 'messages' contains the messages generated by the test script. If a
  61. test fails, then the test.log file contains the error messages. If all the
  62. tests are successful, then this file will be an empty file.
  63. - To run a single test function from a test script:
  64. $ ../vim -u NONE -S runtest.vim <test_file>.vim <function_name>
  65. - To execute only specific test functions, add a second argument:
  66. $ ../vim -u NONE -S runtest.vim test_channel.vim open_delay
  67. - To run all the tests:
  68. $ make
  69. - To run the test on MS-Windows using the MSVC nmake:
  70. > nmake -f Make_dos.mak
  71. - To run the tests with GUI Vim:
  72. $ make GUI_FLAG=-g
  73. or
  74. $ make VIMPROG=../gvim
  75. - To cleanup the temporary files after running the tests:
  76. $ make clean