neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 052498ed42780a76daea589d063cd8947a894673
parent c5af5c0b9ab84c86f84e32210512923e7eb641ba
Author: dundargoc <gocdundar@gmail.com>
Date:   Sat, 20 Apr 2024 17:44:13 +0200

test: improve test conventions

Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.

Diffstat:
Mruntime/doc/dev_tools.txt | 3+--
Dscripts/legacy2luatest.pl | 300-------------------------------------------------------------------------------
Mtest/README.md | 11+++++++----
Mtest/benchmark/autocmd_spec.lua | 6+++---
Mtest/benchmark/bench_regexp_spec.lua | 7++++---
Mtest/benchmark/preload.lua | 2+-
Mtest/benchmark/screenpos_spec.lua | 14++++++++------
Mtest/benchmark/treesitter_spec.lua | 8++++----
Mtest/functional/api/autocmd_spec.lua | 13+++++++------
Mtest/functional/api/buffer_spec.lua | 30++++++++++++++++--------------
Mtest/functional/api/buffer_updates_spec.lua | 24+++++++++++++-----------
Mtest/functional/api/command_spec.lua | 19++++++++++---------
Mtest/functional/api/extmark_spec.lua | 21+++++++++++----------
Mtest/functional/api/highlight_spec.lua | 18++++++++++--------
Mtest/functional/api/keymap_spec.lua | 31++++++++++++++++---------------
Mtest/functional/api/menu_spec.lua | 8++++----
Mtest/functional/api/proc_spec.lua | 11++++++-----
Mtest/functional/api/server_notifications_spec.lua | 14++++++++------
Mtest/functional/api/server_requests_spec.lua | 39++++++++++++++++++++-------------------
Mtest/functional/api/tabpage_spec.lua | 18++++++++++--------
Mtest/functional/api/ui_spec.lua | 18++++++++++--------
Mtest/functional/api/version_spec.lua | 8+++++---
Mtest/functional/api/vim_spec.lua | 85++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mtest/functional/api/window_spec.lua | 40+++++++++++++++++++++-------------------
Mtest/functional/autocmd/autocmd_oldtest_spec.lua | 15++++++++-------
Mtest/functional/autocmd/autocmd_spec.lua | 27++++++++++++++-------------
Mtest/functional/autocmd/bufenter_spec.lua | 15++++++++-------
Mtest/functional/autocmd/bufmodifiedset_spec.lua | 11++++++-----
Mtest/functional/autocmd/cmdline_spec.lua | 17+++++++++--------
Mtest/functional/autocmd/cursorhold_spec.lua | 11++++++-----
Mtest/functional/autocmd/cursormoved_spec.lua | 13+++++++------
Mtest/functional/autocmd/dirchanged_spec.lua | 13+++++++------
Mtest/functional/autocmd/filetype_spec.lua | 10+++++-----
Mtest/functional/autocmd/focus_spec.lua | 8+++++---
Mtest/functional/autocmd/modechanged_spec.lua | 10++++++----
Mtest/functional/autocmd/recording_spec.lua | 9+++++----
Mtest/functional/autocmd/safestate_spec.lua | 12+++++++-----
Mtest/functional/autocmd/searchwrapped_spec.lua | 13+++++++------
Mtest/functional/autocmd/show_spec.lua | 15++++++++-------
Mtest/functional/autocmd/signal_spec.lua | 11++++++-----
Mtest/functional/autocmd/tabclose_spec.lua | 10++++++----
Mtest/functional/autocmd/tabnew_spec.lua | 9+++++----
Mtest/functional/autocmd/tabnewentered_spec.lua | 15++++++++-------
Mtest/functional/autocmd/termxx_spec.lua | 15++++++++-------
Mtest/functional/autocmd/textchanged_spec.lua | 16+++++++++-------
Mtest/functional/autocmd/textyankpost_spec.lua | 10++++++----
Mtest/functional/autocmd/win_scrolled_resized_spec.lua | 17+++++++++--------
Mtest/functional/core/channels_spec.lua | 18++++++++++--------
Mtest/functional/core/exit_spec.lua | 31++++++++++++++++---------------
Mtest/functional/core/fileio_spec.lua | 37+++++++++++++++++++------------------
Mtest/functional/core/job_spec.lua | 53+++++++++++++++++++++++++++--------------------------
Mtest/functional/core/log_spec.lua | 14++++++++------
Mtest/functional/core/main_spec.lua | 15++++++++-------
Mtest/functional/core/path_spec.lua | 18++++++++++--------
Mtest/functional/core/remote_spec.lua | 25+++++++++++++------------
Mtest/functional/core/spellfile_spec.lua | 13+++++++------
Mtest/functional/core/startup_spec.lua | 43++++++++++++++++++++++---------------------
Mtest/functional/editor/K_spec.lua | 14++++++++------
Mtest/functional/editor/completion_spec.lua | 20+++++++++++---------
Mtest/functional/editor/count_spec.lua | 11++++++-----
Mtest/functional/editor/ctrl_c_spec.lua | 10++++++----
Mtest/functional/editor/fold_spec.lua | 21+++++++++++----------
Mtest/functional/editor/jump_spec.lua | 15++++++++-------
Mtest/functional/editor/lang_spec.lua | 12+++++++-----
Mtest/functional/editor/langmap_spec.lua | 19++++++++++---------
Mtest/functional/editor/macro_spec.lua | 19++++++++++---------
Mtest/functional/editor/mark_spec.lua | 40+++++++++++++++++++++-------------------
Mtest/functional/editor/meta_key_spec.lua | 16+++++++++-------
Mtest/functional/editor/mode_cmdline_spec.lua | 12+++++++-----
Mtest/functional/editor/mode_insert_spec.lua | 20+++++++++++---------
Mtest/functional/editor/mode_normal_spec.lua | 14++++++++------
Mtest/functional/editor/put_spec.lua | 19++++++++++---------
Mtest/functional/editor/search_spec.lua | 8+++++---
Mtest/functional/editor/tabpage_spec.lua | 21+++++++++++----------
Mtest/functional/editor/undo_spec.lua | 25+++++++++++++------------
Mtest/functional/ex_cmds/append_spec.lua | 17+++++++++--------
Mtest/functional/ex_cmds/arg_spec.lua | 16+++++++++-------
Mtest/functional/ex_cmds/cd_spec.lua | 17+++++++++--------
Mtest/functional/ex_cmds/cmd_map_spec.lua | 22++++++++++++----------
Mtest/functional/ex_cmds/debug_spec.lua | 7++++---
Mtest/functional/ex_cmds/dict_notifications_spec.lua | 22++++++++++++----------
Mtest/functional/ex_cmds/digraphs_spec.lua | 9+++++----
Mtest/functional/ex_cmds/drop_spec.lua | 9+++++----
Mtest/functional/ex_cmds/echo_spec.lua | 23++++++++++++-----------
Mtest/functional/ex_cmds/edit_spec.lua | 10++++++----
Mtest/functional/ex_cmds/encoding_spec.lua | 8+++++---
Mtest/functional/ex_cmds/excmd_spec.lua | 12+++++++-----
Mtest/functional/ex_cmds/file_spec.lua | 12+++++++-----
Mtest/functional/ex_cmds/grep_spec.lua | 6++++--
Mtest/functional/ex_cmds/help_spec.lua | 15++++++++-------
Mtest/functional/ex_cmds/highlight_spec.lua | 16+++++++++-------
Mtest/functional/ex_cmds/ls_spec.lua | 16+++++++++-------
Mtest/functional/ex_cmds/make_spec.lua | 16+++++++++-------
Mtest/functional/ex_cmds/map_spec.lua | 21+++++++++++----------
Mtest/functional/ex_cmds/menu_spec.lua | 12+++++++-----
Mtest/functional/ex_cmds/mksession_spec.lua | 15++++++++-------
Mtest/functional/ex_cmds/mkview_spec.lua | 13+++++++------
Mtest/functional/ex_cmds/normal_spec.lua | 16+++++++++-------
Mtest/functional/ex_cmds/oldfiles_spec.lua | 17+++++++++--------
Mtest/functional/ex_cmds/print_commands_spec.lua | 6++++--
Mtest/functional/ex_cmds/profile_spec.lua | 15++++++++-------
Mtest/functional/ex_cmds/quickfix_commands_spec.lua | 17+++++++++--------
Mtest/functional/ex_cmds/quit_spec.lua | 5+++--
Mtest/functional/ex_cmds/script_spec.lua | 15++++++++-------
Mtest/functional/ex_cmds/sign_spec.lua | 10++++++----
Mtest/functional/ex_cmds/source_spec.lua | 28+++++++++++++++-------------
Mtest/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 40+++++++++++++++++++++-------------------
Mtest/functional/ex_cmds/syntax_spec.lua | 7++++---
Mtest/functional/ex_cmds/trust_spec.lua | 17+++++++++--------
Mtest/functional/ex_cmds/undojoin_spec.lua | 15++++++++-------
Mtest/functional/ex_cmds/verbose_spec.lua | 13+++++++------
Mtest/functional/ex_cmds/wincmd_spec.lua | 10++++++----
Mtest/functional/ex_cmds/write_spec.lua | 14++++++++------
Mtest/functional/ex_cmds/wundo_spec.lua | 11++++++++---
Mtest/functional/ex_cmds/wviminfo_spec.lua | 8+++++---
Mtest/functional/example_spec.lua | 9+++++----
Mtest/functional/legacy/002_filename_recognition_spec.lua | 7++++---
Mtest/functional/legacy/004_bufenter_with_modelines_spec.lua | 7++++---
Mtest/functional/legacy/005_bufleave_delete_buffer_spec.lua | 9+++++----
Mtest/functional/legacy/007_ball_buffer_list_spec.lua | 7++++---
Mtest/functional/legacy/008_autocommands_spec.lua | 10++++++----
Mtest/functional/legacy/011_autocommands_spec.lua | 8+++++---
Mtest/functional/legacy/012_directory_spec.lua | 21+++++++++++----------
Mtest/functional/legacy/015_alignment_spec.lua | 7++++---
Mtest/functional/legacy/018_unset_smart_indenting_spec.lua | 12++++++------
Mtest/functional/legacy/019_smarttab_expandtab_spec.lua | 7++++---
Mtest/functional/legacy/020_blockwise_visual_spec.lua | 7++++---
Mtest/functional/legacy/021_control_wi_spec.lua | 7++++---
Mtest/functional/legacy/023_edit_arguments_spec.lua | 9+++++----
Mtest/functional/legacy/025_jump_tag_hidden_spec.lua | 8+++++---
Mtest/functional/legacy/026_execute_while_if_spec.lua | 10+++++-----
Mtest/functional/legacy/028_source_ctrl_v_spec.lua | 7++++---
Mtest/functional/legacy/029_join_spec.lua | 12++++++------
Mtest/functional/legacy/030_fileformats_spec.lua | 12+++++++-----
Mtest/functional/legacy/031_close_commands_spec.lua | 18+++++++++---------
Mtest/functional/legacy/033_lisp_indent_spec.lua | 9+++++----
Mtest/functional/legacy/034_user_function_spec.lua | 7++++---
Mtest/functional/legacy/035_increment_and_decrement_spec.lua | 7++++---
Mtest/functional/legacy/036_regexp_character_classes_spec.lua | 10++++++----
Mtest/functional/legacy/038_virtual_replace_spec.lua | 7++++---
Mtest/functional/legacy/039_visual_block_mode_commands_spec.lua | 14++++++++------
Mtest/functional/legacy/043_magic_settings_spec.lua | 7++++---
Mtest/functional/legacy/044_099_regexp_multibyte_magic_spec.lua | 7++++---
Mtest/functional/legacy/046_multi_line_regexps_spec.lua | 7++++---
Mtest/functional/legacy/054_buffer_local_autocommands_spec.lua | 8++++----
Mtest/functional/legacy/055_list_and_dict_types_spec.lua | 7++++---
Mtest/functional/legacy/056_script_local_function_spec.lua | 7++++---
Mtest/functional/legacy/057_sort_spec.lua | 7++++---
Mtest/functional/legacy/060_exists_and_has_functions_spec.lua | 8+++++---
Mtest/functional/legacy/061_undo_tree_spec.lua | 17+++++++++--------
Mtest/functional/legacy/063_match_and_matchadd_spec.lua | 6+++---
Mtest/functional/legacy/065_float_and_logic_operators_spec.lua | 7++++---
Mtest/functional/legacy/066_visual_block_tab_spec.lua | 7++++---
Mtest/functional/legacy/067_augroup_exists_spec.lua | 7++++---
Mtest/functional/legacy/068_text_formatting_spec.lua | 12++++++------
Mtest/functional/legacy/069_multibyte_formatting_spec.lua | 6++++--
Mtest/functional/legacy/072_undo_file_spec.lua | 7++++---
Mtest/functional/legacy/074_global_var_in_viminfo_spec.lua | 6++++--
Mtest/functional/legacy/078_swapfile_recover_spec.lua | 5+++--
Mtest/functional/legacy/081_coptions_movement_spec.lua | 7++++---
Mtest/functional/legacy/082_string_comparison_spec.lua | 7++++---
Mtest/functional/legacy/083_tag_search_with_file_encoding_spec.lua | 8+++++---
Mtest/functional/legacy/090_sha256_spec.lua | 7++++---
Mtest/functional/legacy/091_context_variables_spec.lua | 7++++---
Mtest/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua | 7++++---
Mtest/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua | 7++++---
Mtest/functional/legacy/094_visual_mode_operators_spec.lua | 7++++---
Mtest/functional/legacy/095_regexp_multibyte_spec.lua | 7++++---
Mtest/functional/legacy/096_location_list_spec.lua | 7++++---
Mtest/functional/legacy/097_glob_path_spec.lua | 8+++++---
Mtest/functional/legacy/101_hlsearch_spec.lua | 7++++---
Mtest/functional/legacy/102_fnameescape_spec.lua | 7++++---
Mtest/functional/legacy/103_visual_mode_reset_spec.lua | 7++++---
Mtest/functional/legacy/106_errorformat_spec.lua | 7++++---
Mtest/functional/legacy/107_adjust_window_and_contents_spec.lua | 10+++++-----
Mtest/functional/legacy/108_backtrace_debug_commands_spec.lua | 9+++++----
Mtest/functional/legacy/arglist_spec.lua | 10++++++----
Mtest/functional/legacy/assert_spec.lua | 18++++++++++--------
Mtest/functional/legacy/autochdir_spec.lua | 12+++++++-----
Mtest/functional/legacy/autocmd_option_spec.lua | 31++++++++++++++++---------------
Mtest/functional/legacy/autocmd_spec.lua | 12+++++++-----
Mtest/functional/legacy/autoformat_join_spec.lua | 9+++++----
Mtest/functional/legacy/breakindent_spec.lua | 11++++++-----
Mtest/functional/legacy/changelist_spec.lua | 7++++---
Mtest/functional/legacy/charsearch_spec.lua | 7++++---
Mtest/functional/legacy/close_count_spec.lua | 13+++++++------
Mtest/functional/legacy/cmdline_spec.lua | 15++++++++-------
Mtest/functional/legacy/command_count_spec.lua | 7++++---
Mtest/functional/legacy/comparators_spec.lua | 8+++++---
Mtest/functional/legacy/conceal_spec.lua | 16+++++++++-------
Mtest/functional/legacy/cpoptions_spec.lua | 9+++++----
Mtest/functional/legacy/crash_spec.lua | 11++++++-----
Mtest/functional/legacy/debugger_spec.lua | 10++++++----
Mtest/functional/legacy/delete_spec.lua | 10++++++----
Mtest/functional/legacy/digraph_spec.lua | 7++++---
Mtest/functional/legacy/display_spec.lua | 12++++++------
Mtest/functional/legacy/edit_spec.lua | 11++++++-----
Mtest/functional/legacy/erasebackword_spec.lua | 5+++--
Mtest/functional/legacy/eval_spec.lua | 16+++++++++-------
Mtest/functional/legacy/ex_mode_spec.lua | 16+++++++++-------
Mtest/functional/legacy/excmd_spec.lua | 22++++++++++++----------
Mtest/functional/legacy/fixeol_spec.lua | 7++++---
Mtest/functional/legacy/fnamemodify_spec.lua | 10++++++----
Mtest/functional/legacy/fold_spec.lua | 15++++++++-------
Mtest/functional/legacy/function_sort_spec.lua | 11++++++-----
Mtest/functional/legacy/getcwd_spec.lua | 10++++++----
Mtest/functional/legacy/gf_spec.lua | 8+++++---
Mtest/functional/legacy/glob2regpat_spec.lua | 8+++++---
Mtest/functional/legacy/global_spec.lua | 11++++++-----
Mtest/functional/legacy/highlight_spec.lua | 16+++++++++-------
Mtest/functional/legacy/increment_spec.lua | 16+++++++++-------
Mtest/functional/legacy/insertcount_spec.lua | 7++++---
Mtest/functional/legacy/join_spec.lua | 8+++++---
Mtest/functional/legacy/lispwords_spec.lua | 12+++++++-----
Mtest/functional/legacy/listchars_spec.lua | 7++++---
Mtest/functional/legacy/listlbr_spec.lua | 7++++---
Mtest/functional/legacy/listlbr_utf8_spec.lua | 11++++++-----
Mtest/functional/legacy/mapping_spec.lua | 12+++++++-----
Mtest/functional/legacy/marks_spec.lua | 7++++---
Mtest/functional/legacy/match_spec.lua | 9+++++----
Mtest/functional/legacy/matchparen_spec.lua | 10+++++-----
Mtest/functional/legacy/memory_usage_spec.lua | 18++++++++++--------
Mtest/functional/legacy/messages_spec.lua | 17+++++++++--------
Mtest/functional/legacy/mksession_spec.lua | 10++++++----
Mtest/functional/legacy/move_spec.lua | 9+++++----
Mtest/functional/legacy/nested_function_spec.lua | 7++++---
Mtest/functional/legacy/normal_spec.lua | 14++++++++------
Mtest/functional/legacy/number_spec.lua | 11++++++-----
Mtest/functional/legacy/options_spec.lua | 12+++++++-----
Mtest/functional/legacy/prompt_buffer_spec.lua | 18++++++++++--------
Mtest/functional/legacy/put_spec.lua | 12+++++++-----
Mtest/functional/legacy/qf_title_spec.lua | 7++++---
Mtest/functional/legacy/scroll_opt_spec.lua | 11++++++-----
Mtest/functional/legacy/search_mbyte_spec.lua | 12++++++------
Mtest/functional/legacy/search_spec.lua | 18++++++++++--------
Mtest/functional/legacy/search_stat_spec.lua | 5+++--
Mtest/functional/legacy/signs_spec.lua | 5+++--
Mtest/functional/legacy/source_spec.lua | 8+++++---
Mtest/functional/legacy/statusline_spec.lua | 9+++++----
Mtest/functional/legacy/substitute_spec.lua | 12+++++++-----
Mtest/functional/legacy/syn_attr_spec.lua | 10++++++----
Mtest/functional/legacy/tabline_spec.lua | 9+++++----
Mtest/functional/legacy/tagcase_spec.lua | 16+++++++++-------
Mtest/functional/legacy/textobjects_spec.lua | 13+++++++------
Mtest/functional/legacy/undolevels_spec.lua | 10++++++----
Mtest/functional/legacy/utf8_spec.lua | 14++++++++------
Mtest/functional/legacy/vimscript_spec.lua | 11++++++-----
Mtest/functional/legacy/visual_spec.lua | 10+++++-----
Mtest/functional/legacy/window_cmd_spec.lua | 13+++++++------
Mtest/functional/legacy/wordcount_spec.lua | 12+++++++-----
Mtest/functional/legacy/writefile_spec.lua | 5+++--
Mtest/functional/lua/api_spec.lua | 13+++++++------
Mtest/functional/lua/base64_spec.lua | 8+++++---
Mtest/functional/lua/buffer_updates_spec.lua | 21+++++++++++----------
Mtest/functional/lua/command_line_completion_spec.lua | 7++++---
Mtest/functional/lua/commands_spec.lua | 23++++++++++++-----------
Mtest/functional/lua/comment_spec.lua | 13+++++++------
Mtest/functional/lua/diagnostic_spec.lua | 23++++++++++++-----------
Mtest/functional/lua/ffi_spec.lua | 8+++++---
Mtest/functional/lua/filetype_spec.lua | 16+++++++++-------
Mtest/functional/lua/fs_spec.lua | 15++++++++-------
Mtest/functional/lua/glob_spec.lua | 10++++++----
Mtest/functional/lua/highlight_spec.lua | 16+++++++++-------
Mtest/functional/lua/inspector_spec.lua | 10++++++----
Mtest/functional/lua/iter_spec.lua | 3++-
Mtest/functional/lua/json_spec.lua | 8+++++---
Mtest/functional/lua/loader_spec.lua | 9+++++----
Mtest/functional/lua/loop_spec.lua | 16+++++++++-------
Mtest/functional/lua/luaeval_spec.lua | 19++++++++++---------
Mtest/functional/lua/mpack_spec.lua | 7++++---
Mtest/functional/lua/overrides_spec.lua | 17+++++++++--------
Mtest/functional/lua/runtime_spec.lua | 17+++++++++--------
Mtest/functional/lua/secure_spec.lua | 27++++++++++++++-------------
Mtest/functional/lua/snippet_spec.lua | 17+++++++++--------
Mtest/functional/lua/spell_spec.lua | 8+++++---
Mtest/functional/lua/system_spec.lua | 8+++++---
Mtest/functional/lua/text_spec.lua | 6++++--
Mtest/functional/lua/thread_spec.lua | 14++++++++------
Mtest/functional/lua/ui_event_spec.lua | 18++++++++++--------
Mtest/functional/lua/ui_spec.lua | 14++++++++------
Mtest/functional/lua/uri_spec.lua | 8+++++---
Mtest/functional/lua/version_spec.lua | 10++++++----
Mtest/functional/lua/vim_spec.lua | 39++++++++++++++++++++-------------------
Mtest/functional/lua/watch_spec.lua | 10++++++----
Mtest/functional/lua/xdiff_spec.lua | 8+++++---
Mtest/functional/options/autochdir_spec.lua | 14++++++++------
Mtest/functional/options/chars_spec.lua | 14++++++++------
Mtest/functional/options/cursorbind_spec.lua | 11++++++-----
Mtest/functional/options/defaults_spec.lua | 32++++++++++++++++----------------
Mtest/functional/options/keymap_spec.lua | 12+++++++-----
Mtest/functional/options/modified_spec.lua | 8+++++---
Mtest/functional/options/mousescroll_spec.lua | 20+++++++++++---------
Mtest/functional/options/num_options_spec.lua | 6++++--
Mtest/functional/options/shortmess_spec.lua | 12+++++++-----
Mtest/functional/options/tabstop_spec.lua | 8++++----
Mtest/functional/options/winfixbuf_spec.lua | 7++++---
Mtest/functional/plugin/ccomplete_spec.lua | 12+++++++-----
Mtest/functional/plugin/cfilter_spec.lua | 10++++++----
Mtest/functional/plugin/editorconfig_spec.lua | 20+++++++++++---------
Mtest/functional/plugin/health_spec.lua | 35++++++++++++++++++-----------------
Mtest/functional/plugin/lsp/codelens_spec.lua | 9+++++----
Mtest/functional/plugin/lsp/completion_spec.lua | 8+++++---
Mtest/functional/plugin/lsp/diagnostic_spec.lua | 8+++++---
Mtest/functional/plugin/lsp/handler_spec.lua | 5+++--
Mtest/functional/plugin/lsp/incremental_sync_spec.lua | 11++++++-----
Mtest/functional/plugin/lsp/inlay_hint_spec.lua | 11++++++-----
Mtest/functional/plugin/lsp/semantic_tokens_spec.lua | 17+++++++++--------
Mtest/functional/plugin/lsp/snippet_spec.lua | 10++++++----
Mtest/functional/plugin/lsp/testutil.lua | 12++++++------
Mtest/functional/plugin/lsp/utils_spec.lua | 11++++++-----
Mtest/functional/plugin/lsp_spec.lua | 30++++++++++++++++--------------
Mtest/functional/plugin/man_spec.lua | 14++++++++------
Mtest/functional/plugin/matchparen_spec.lua | 11++++++-----
Mtest/functional/plugin/msgpack_spec.lua | 14++++++++------
Mtest/functional/plugin/shada_spec.lua | 10++++++----
Mtest/functional/plugin/tohtml_spec.lua | 15++++++++-------
Mtest/functional/plugin/tutor_spec.lua | 10++++++----
Mtest/functional/plugin/vim_syntax_spec.lua | 11++++++-----
Mtest/functional/preload.lua | 5++---
Mtest/functional/provider/clipboard_spec.lua | 12+++++++-----
Mtest/functional/provider/define_spec.lua | 16+++++++++-------
Mtest/functional/provider/nodejs_spec.lua | 12+++++++-----
Mtest/functional/provider/perl_spec.lua | 20+++++++++++---------
Mtest/functional/provider/provider_spec.lua | 8+++++---
Mtest/functional/provider/python3_spec.lua | 22++++++++++++----------
Mtest/functional/provider/ruby_spec.lua | 27++++++++++++++-------------
Mtest/functional/script/luacats_grammar_spec.lua | 3++-
Mtest/functional/script/luacats_parser_spec.lua | 3++-
Mtest/functional/script/text_utils_spec.lua | 8+++++---
Mtest/functional/shada/buffers_spec.lua | 10++++++----
Mtest/functional/shada/compatibility_spec.lua | 9+++++----
Mtest/functional/shada/errors_spec.lua | 7++++---
Mtest/functional/shada/history_spec.lua | 12+++++++-----
Mtest/functional/shada/marks_spec.lua | 18++++++++++--------
Mtest/functional/shada/merging_spec.lua | 12+++++++-----
Mtest/functional/shada/registers_spec.lua | 9+++++----
Mtest/functional/shada/shada_spec.lua | 15++++++++-------
Mtest/functional/shada/testutil.lua | 10++++++----
Mtest/functional/shada/variables_spec.lua | 9+++++----
Mtest/functional/terminal/altscreen_spec.lua | 8+++++---
Mtest/functional/terminal/api_spec.lua | 12+++++++-----
Mtest/functional/terminal/buffer_spec.lua | 28+++++++++++++++-------------
Mtest/functional/terminal/channel_spec.lua | 22++++++++++++----------
Mtest/functional/terminal/cursor_spec.lua | 14++++++++------
Mtest/functional/terminal/edit_spec.lua | 14++++++++------
Mtest/functional/terminal/ex_terminal_spec.lua | 20+++++++++++---------
Mtest/functional/terminal/highlight_spec.lua | 16+++++++++-------
Mtest/functional/terminal/mouse_spec.lua | 8+++++---
Mtest/functional/terminal/scrollback_spec.lua | 20+++++++++++---------
Mtest/functional/terminal/testutil.lua | 11++++++-----
Mtest/functional/terminal/tui_spec.lua | 44+++++++++++++++++++++++---------------------
Mtest/functional/terminal/window_spec.lua | 12+++++++-----
Mtest/functional/terminal/window_split_tab_spec.lua | 18++++++++++--------
Atest/functional/testnvim.lua | 1013+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dtest/functional/testutil.lua | 1063-------------------------------------------------------------------------------
Mtest/functional/treesitter/fold_spec.lua | 18++++++++++--------
Mtest/functional/treesitter/highlight_spec.lua | 19++++++++++---------
Mtest/functional/treesitter/inspect_tree_spec.lua | 14++++++++------
Mtest/functional/treesitter/language_spec.lua | 11++++++-----
Mtest/functional/treesitter/node_spec.lua | 11++++++-----
Mtest/functional/treesitter/parser_spec.lua | 21+++++++++++----------
Mtest/functional/treesitter/query_spec.lua | 17+++++++++--------
Mtest/functional/treesitter/utils_spec.lua | 9+++++----
Mtest/functional/ui/bufhl_spec.lua | 9+++++----
Mtest/functional/ui/cmdline_highlight_spec.lua | 17+++++++++--------
Mtest/functional/ui/cmdline_spec.lua | 20+++++++++++---------
Mtest/functional/ui/cursor_spec.lua | 18++++++++++--------
Mtest/functional/ui/decorations_spec.lua | 33+++++++++++++++++----------------
Mtest/functional/ui/diff_spec.lua | 15++++++++-------
Mtest/functional/ui/embed_spec.lua | 32++++++++++++++++----------------
Mtest/functional/ui/float_spec.lua | 40+++++++++++++++++++++-------------------
Mtest/functional/ui/fold_spec.lua | 20+++++++++++---------
Mtest/functional/ui/highlight_spec.lua | 20+++++++++++---------
Mtest/functional/ui/hlstate_spec.lua | 21+++++++++++----------
Mtest/functional/ui/inccommand_spec.lua | 28+++++++++++++++-------------
Mtest/functional/ui/inccommand_user_spec.lua | 18++++++++++--------
Mtest/functional/ui/input_spec.lua | 24+++++++++++++-----------
Mtest/functional/ui/linematch_spec.lua | 23++++++++++++-----------
Mtest/functional/ui/messages_spec.lua | 38++++++++++++++++++++------------------
Mtest/functional/ui/mode_spec.lua | 7++++---
Mtest/functional/ui/mouse_spec.lua | 22++++++++++++----------
Mtest/functional/ui/multibyte_spec.lua | 18++++++++++--------
Mtest/functional/ui/multigrid_spec.lua | 16+++++++++-------
Mtest/functional/ui/options_spec.lua | 10++++++----
Mtest/functional/ui/output_spec.lua | 27++++++++++++++-------------
Mtest/functional/ui/popupmenu_spec.lua | 24+++++++++++++-----------
Mtest/functional/ui/quickfix_spec.lua | 7++++---
Mtest/functional/ui/screen.lua | 10++++++----
Mtest/functional/ui/screen_basic_spec.lua | 16+++++++++-------
Mtest/functional/ui/searchhl_spec.lua | 16+++++++++-------
Mtest/functional/ui/sign_spec.lua | 8+++++---
Mtest/functional/ui/spell_spec.lua | 14++++++++------
Mtest/functional/ui/statuscolumn_spec.lua | 20+++++++++++---------
Mtest/functional/ui/statusline_spec.lua | 22++++++++++++----------
Mtest/functional/ui/syntax_conceal_spec.lua | 12+++++++-----
Mtest/functional/ui/tabline_spec.lua | 12+++++++-----
Mtest/functional/ui/title_spec.lua | 18++++++++++--------
Mtest/functional/ui/wildmode_spec.lua | 14++++++++------
Mtest/functional/ui/winbar_spec.lua | 18++++++++++--------
Mtest/functional/vimscript/api_functions_spec.lua | 18++++++++++--------
Mtest/functional/vimscript/buf_functions_spec.lua | 17+++++++++--------
Mtest/functional/vimscript/changedtick_spec.lua | 19++++++++++---------
Mtest/functional/vimscript/container_functions_spec.lua | 9+++++----
Mtest/functional/vimscript/ctx_functions_spec.lua | 21+++++++++++----------
Mtest/functional/vimscript/environ_spec.lua | 20+++++++++++---------
Mtest/functional/vimscript/errorlist_spec.lua | 19++++++++++---------
Mtest/functional/vimscript/eval_spec.lua | 37+++++++++++++++++++------------------
Mtest/functional/vimscript/executable_spec.lua | 10++++++----
Mtest/functional/vimscript/execute_spec.lua | 20+++++++++++---------
Mtest/functional/vimscript/exepath_spec.lua | 14++++++++------
Mtest/functional/vimscript/fnamemodify_spec.lua | 16+++++++++-------
Mtest/functional/vimscript/functions_spec.lua | 7++++---
Mtest/functional/vimscript/getline_spec.lua | 9+++++----
Mtest/functional/vimscript/glob_spec.lua | 6++++--
Mtest/functional/vimscript/has_spec.lua | 12+++++++-----
Mtest/functional/vimscript/hostname_spec.lua | 8+++++---
Mtest/functional/vimscript/input_spec.lua | 17+++++++++--------
Mtest/functional/vimscript/json_functions_spec.lua | 18++++++++++--------
Mtest/functional/vimscript/lang_spec.lua | 8+++++---
Mtest/functional/vimscript/let_spec.lua | 21+++++++++++----------
Mtest/functional/vimscript/map_functions_spec.lua | 25+++++++++++++------------
Mtest/functional/vimscript/match_functions_spec.lua | 11++++++-----
Mtest/functional/vimscript/minmax_functions_spec.lua | 11++++++-----
Mtest/functional/vimscript/modeline_spec.lua | 8+++++---
Mtest/functional/vimscript/msgpack_functions_spec.lua | 20+++++++++++---------
Mtest/functional/vimscript/null_spec.lua | 13+++++++------
Mtest/functional/vimscript/operators_spec.lua | 8+++++---
Mtest/functional/vimscript/printf_spec.lua | 13+++++++------
Mtest/functional/vimscript/reltime_spec.lua | 8+++++---
Mtest/functional/vimscript/screenchar_spec.lua | 8+++++---
Mtest/functional/vimscript/screenpos_spec.lua | 10++++++----
Mtest/functional/vimscript/server_spec.lua | 24+++++++++++++-----------
Mtest/functional/vimscript/setpos_spec.lua | 18++++++++++--------
Mtest/functional/vimscript/sort_spec.lua | 15++++++++-------
Mtest/functional/vimscript/special_vars_spec.lua | 16+++++++++-------
Mtest/functional/vimscript/state_spec.lua | 16+++++++++-------
Mtest/functional/vimscript/string_spec.lua | 18++++++++++--------
Mtest/functional/vimscript/system_spec.lua | 42+++++++++++++++++++++---------------------
Mtest/functional/vimscript/timer_spec.lua | 16+++++++++-------
Mtest/functional/vimscript/uniq_spec.lua | 9+++++----
Mtest/functional/vimscript/vvar_event_spec.lua | 8+++++---
Mtest/functional/vimscript/wait_spec.lua | 22++++++++++++----------
Mtest/functional/vimscript/writefile_spec.lua | 13+++++++------
Mtest/old/testdir/load.vim | 2+-
Mtest/testutil.lua | 53++++++++++++++++++++++++++++++++++++++++++++++++++++-
445 files changed, 4455 insertions(+), 4127 deletions(-)

diff --git a/runtime/doc/dev_tools.txt b/runtime/doc/dev_tools.txt @@ -87,9 +87,8 @@ Then, in another terminal: >bash gdb build/bin/nvim target remote localhost:7777 -< -- See also test/functional/testutil.lua https://github.com/neovim/neovim/blob/3098b18a2b63a841351f6d5e3697cb69db3035ef/test/functional/testutil.lua#L38-L44. +-- See `nvim_argv` in https://github.com/neovim/neovim/blob/master/test/functional/testnvim.lua. USING LLDB TO STEP THROUGH UNIT TESTS ~ diff --git a/scripts/legacy2luatest.pl b/scripts/legacy2luatest.pl @@ -1,300 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -use 5.010; -use autodie; - -use File::Basename; -use File::Spec::Functions; - -sub read_in_file { - my $in_file = $_[0]; - - # Will contain lines before first STARTTEST - # as Lua comments. - my @description_lines = (); - - # Will contain alternating blocks of lines of textual input - # (text between ENDTEST and EOF/next STARTTEST) and test commands - # (commands between STARTTEST and ENDTEST) as Lua code. - my @test_body_lines = (); - - # Will contain current command block, i.e. lines - # between STARTTEST and ENDTEST. - my @command_lines = (); - - # Will contain current input block, i.e. lines - # between ENDTEST and STARTTEST. - my @input_lines = (); - - open my $in_file_handle, '<', $in_file; - - use constant EMIT_DESCRIPTION => 0; - use constant EMIT_COMMAND => 1; - use constant EMIT_INPUT => 2; - - # Push lines from current input and - # command blocks into @test_body_lines - # in the correct order. - sub end_input { - my $input_lines = $_[0]; - my $command_lines = $_[1]; - my $test_body_lines = $_[2]; - - # If there are input lines, wrap with an `insert` - # command and add before the previous command block. - if (@{$input_lines}) { - my $last_input_line = pop @{$input_lines}; - unshift @{$command_lines}, ''; - unshift @{$command_lines}, $last_input_line . ']=])'; - unshift @{$command_lines}, @{$input_lines}; - unshift @{$command_lines}, "insert([=["; - - @{$input_lines} = (); - } - - # Output remaining command lines. - push @{$test_body_lines}, @{$command_lines}; - @{$command_lines} = (); - } - - sub format_comment { - # Handle empty comments. - if (/^$/) { - return ''; - } - - # Capitalize first character and emit as Lua comment. - my $comment = '-- ' . ucfirst $_; - - # Add trailing dot if not already there. - $comment .= '.' unless $comment =~ /\.$/; - - return $comment; - } - - my %states = ( - # Add test description to @description_lines. - EMIT_DESCRIPTION() => sub { - if (/^STARTTEST/) { - return EMIT_COMMAND; - } - - # If not an empty line, emit as Lua comment. - if (!/^$/) { - # Remove modeline - s/vim:.*set f\w+=vim//g; - # Remove trailing ":" - s/\s*:\s*$//g; - push @description_lines, '-- ' . $_; - } - - return EMIT_DESCRIPTION; - }, - # Add test commands to @command_lines. - EMIT_COMMAND() => sub { - if (/^ENDTEST/) { - return EMIT_INPUT; - } - - # If line starts with ':"', emit a comment. - if (/^:"/) { - # Remove Vim comment prefix. - s/^:"\s*//; - - push @command_lines, format_comment $_; - - return EMIT_COMMAND; - } - - # Extract possible inline comment. - if (/^[^"]*"[^"]*$/) { - # Remove command part and prepended whitespace. - s/^(.*?)\s*"\s*//; - - push @command_lines, format_comment $_; - - # Set implicit variable to command without comment. - $_ = $1; - } - - # Only continue if remaining command is not empty. - if (!/^:?\s*$/) { - # Replace terminal escape characters with <esc>. - s/\e/<esc>/g; - - my $startstr = "'"; - my $endstr = "'"; - - # If line contains single quotes or backslashes, use double - # square brackets to wrap string. - if (/'/ || /\\/) { - # If the line contains a closing square bracket, - # wrap it with [=[...]=]. - if (/\]/) { - $startstr = '[=['; - $endstr = ']=]'; - } else { - $startstr = '[['; - $endstr = ']]'; - } - } - - # Emit 'feed' if not a search ('/') or ex (':') command. - if (!/^\// && !/^:/) { - # If command does not end with <esc>, insert trailing <cr>. - my $command = 'feed(' . $startstr . $_; - $command .= '<cr>' unless /<esc>$/; - $command .= $endstr . ')'; - - push @command_lines, $command; - } else { - # Remove prepending ':'. - s/^://; - push @command_lines, 'execute(' . $startstr . $_ . $endstr . ')'; - } - } - - return EMIT_COMMAND; - }, - # Add input to @input_lines. - EMIT_INPUT() => sub { - if (/^STARTTEST/) { - end_input \@input_lines, \@command_lines, \@test_body_lines; - return EMIT_COMMAND; - } - - # Skip initial lines if they are empty. - if (@input_lines or !/^$/) { - push @input_lines, ' ' . $_; - } - return EMIT_INPUT; - }, - ); - - my $state = EMIT_DESCRIPTION; - - while (<$in_file_handle>) { - # Remove trailing newline character and process line. - chomp; - $state = $states{$state}->($_); - } - - # If not all lines have been processed yet, - # do it now. - end_input \@input_lines, \@command_lines, \@test_body_lines; - - close $in_file_handle; - - return (\@description_lines, \@test_body_lines); -} - -sub read_ok_file { - my $ok_file = $_[0]; - my @assertions = (); - - if (-f $ok_file) { - push @assertions, ''; - push @assertions, "-- Assert buffer contents."; - push @assertions, "expect([=["; - - open my $ok_file_handle, '<', $ok_file; - - while (<$ok_file_handle>) { - # Remove trailing newline character and process line. - chomp; - push @assertions, ' ' . $_; - } - - close $ok_file_handle; - - $assertions[-1] .= "]=])"; - } - - return \@assertions; -} - -my $legacy_testfile = $ARGV[0]; -my $out_dir = $ARGV[1]; - -if ($#ARGV != 1) { - say "Convert a legacy Vim test to a Neovim lua spec."; - say ''; - say "Usage: $0 legacy-testfile output-directory"; - say ''; - say "legacy-testfile: Path to .in or .ok file."; - say "output-directory: Directory where Lua spec will be saved to."; - say ''; - say "Note: Only works reliably for fairly simple tests."; - say " Manual adjustments to generated spec files are required."; - exit 1; -} - -my @legacy_suffixes = ('.in', '.ok'); -my ($base_name, $base_path, $suffix) = fileparse($legacy_testfile, @legacy_suffixes); -my $in_file = catfile($base_path, $base_name . '.in'); -my $ok_file = catfile($base_path, $base_name . '.ok'); - -# Remove leading 'test'. -my $test_name = $base_name; -$test_name =~ s/^test_?//; - -my $spec_file = do { - if ($test_name =~ /^([0-9]+)/) { - catfile($out_dir, sprintf('%03d', $1) . '_spec.lua') - } else { - catfile($out_dir, $test_name . '_spec.lua') - } -}; - -if (! -f $in_file) { - say "Test input file $in_file not found."; - exit 2; -} - -if (! -d $out_dir) { - say "Output directory $out_dir does not exist."; - exit 3; -} - -if (-f $spec_file) { - say "Output file $spec_file already exists."; - print "Overwrite (Y/n)? "; - my $input = <STDIN>; - chomp($input); - unless ($input =~ /^y|Y/) { - say "Aborting."; - exit 4; - } -} - -# Read .in and .ok files. -my ($description_lines, $test_body_lines) = read_in_file $in_file; -my $assertion_lines = read_ok_file $ok_file; - -# Append assertions to test body. -push @{$test_body_lines}, @{$assertion_lines} if @{$assertion_lines}; - -# Write spec file. -open my $spec_file_handle, ">", $spec_file; - -print $spec_file_handle <<"EOS"; -@{[join "\n", @{$description_lines}]} - -local t = require('test.functional.testutil') -local feed, insert, source = t.feed, t.insert, t.source -local clear, execute, expect = t.clear, t.execute, t.expect - -describe('$test_name', function() - before_each(clear) - - it('is working', function() -@{[join "\n", map { /^$/ ? '' : ' ' . $_ } @{$test_body_lines}]} - end) -end) -EOS - -close $spec_file_handle; - -say "Written to $spec_file." diff --git a/test/README.md b/test/README.md @@ -37,6 +37,7 @@ Layout - `/test/benchmark` : benchmarks - `/test/functional` : functional tests - `/test/unit` : unit tests +- `/test/old/testdir` : old tests (from Vim) - `/test/config` : contains `*.in` files which are transformed into `*.lua` files using `configure_file` CMake command: this is for accessing CMake variables in lua tests. @@ -44,11 +45,13 @@ Layout parser: normally used to make macros not accessible via this mechanism accessible the other way. - `/test/*/preload.lua` : modules preloaded by busted `--helper` option -- `/test/**/testutil.lua` : common utility functions for test code +- `/test/**/testutil.lua` : common utility functions in the context of the test + runner +- `/test/**/testnvim.lua` : common utility functions in the context of the + test session (RPC channel to the Nvim child process created by clear() for each test) - `/test/*/**/*_spec.lua` : actual tests. Files that do not end with `_spec.lua` are libraries like `/test/**/testutil.lua`, except that they have some common topic. -- `/test/old/testdir` : old tests (from Vim) Running tests @@ -119,7 +122,7 @@ Debugging tests If `$VALGRIND` is also set it will pass `--vgdb=yes` to valgrind instead of starting gdbserver directly. - See [test/functional/testutil.lua](https://github.com/neovim/neovim/blob/9cadbf1d36b63f53f0de48c8c5ff6c752ff05d70/test/functional/testutil.lua#L52-L69) for details. + See `nvim_argv` in https://github.com/neovim/neovim/blob/master/test/functional/testnvim.lua. - Hanging tests can happen due to unexpected "press-enter" prompts. The default screen width is 50 columns. Commands that try to print lines longer @@ -297,7 +300,7 @@ Number; !must be defined to function properly): - `VALGRIND` (F) (D): makes nvim instances to be run under `valgrind`. Log files are named `valgrind-%p.log` in this case. Note that non-empty valgrind log may fail tests. Valgrind arguments may be seen in - `/test/functional/testutil.lua`. May be used in conjunction with `GDB`. + `/test/functional/testnvim.lua`. May be used in conjunction with `GDB`. - `VALGRIND_LOG` (F) (S): overrides valgrind log file name used for `VALGRIND`. diff --git a/test/benchmark/autocmd_spec.lua b/test/benchmark/autocmd_spec.lua @@ -1,7 +1,7 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua local N = 7500 diff --git a/test/benchmark/bench_regexp_spec.lua b/test/benchmark/bench_regexp_spec.lua @@ -1,8 +1,9 @@ -- Test for benchmarking the RE engine. -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, command = t.clear, t.command +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, command = n.clear, n.command -- Temporary file for gathering benchmarking results for each regexp engine. local result_file = 'benchmark.out' diff --git a/test/benchmark/preload.lua b/test/benchmark/preload.lua @@ -1,4 +1,4 @@ -- Modules loaded here will not be cleared and reloaded by Busted. -- Busted started doing this to help provide more isolation. See issue #62 -- for more information about this. -local t = require('test.functional.testutil') +local n = require('test.functional.testnvim') diff --git a/test/benchmark/screenpos_spec.lua b/test/benchmark/screenpos_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local api = n.api + local function rand_utf8(count, seed) math.randomseed(seed) local symbols = { 'i', 'À', 'Ⱡ', '𐀀' } @@ -119,7 +121,7 @@ end local function benchmarks(benchmark_results) describe('screenpos() perf', function() - before_each(t.clear) + before_each(n.clear) -- no breakindent for li, lines_type in ipairs(benchmark_lines) do @@ -134,7 +136,7 @@ local function benchmarks(benchmark_results) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) -- for smaller screen expect (last line always different, first line same as others) - t.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) @@ -153,9 +155,9 @@ local function benchmarks(benchmark_results) local screen = Screen.new(width, height + 1) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) - t.command('set breakindent') + n.command('set breakindent') -- for smaller screen expect (last line always different, first line same as others) - t.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) diff --git a/test/benchmark/treesitter_spec.lua b/test/benchmark/treesitter_spec.lua @@ -1,7 +1,7 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua describe('treesitter perf', function() setup(function() @@ -9,7 +9,7 @@ describe('treesitter perf', function() end) it('can handle large folds', function() - t.command 'edit ./src/nvim/eval.c' + n.command 'edit ./src/nvim/eval.c' exec_lua [[ local parser = vim.treesitter.get_parser(0, "c", {}) vim.treesitter.highlighter.new(parser) diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq local neq = t.neq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local matches = t.matches -local api = t.api -local source = t.source +local api = n.api +local source = n.source local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua @@ -1,21 +1,23 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear + +local clear = n.clear local eq = t.eq local ok = t.ok -local describe_lua_and_rpc = t.describe_lua_and_rpc(describe) -local api = t.api -local fn = t.fn -local request = t.request -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local feed_command = t.feed_command -local insert = t.insert +local describe_lua_and_rpc = n.describe_lua_and_rpc(describe) +local api = n.api +local fn = n.fn +local request = n.request +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local feed_command = n.feed_command +local insert = n.insert local NIL = vim.NIL -local command = t.command -local feed = t.feed +local command = n.command +local feed = n.feed local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive describe('api/buf', function() before_each(clear) @@ -2066,7 +2068,7 @@ describe('api/buf', function() end) after_each(function() - t.rmdir(topdir .. '/Xacd') + n.rmdir(topdir .. '/Xacd') end) it('does not change cwd with non-current buffer', function() diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq, ok = t.eq, t.ok -local fn = t.fn -local api = t.api -local command, eval, next_msg = t.command, t.eval, t.next_msg -local nvim_prog = t.nvim_prog +local fn = n.fn +local api = n.api +local command, eval, next_msg = n.command, n.eval, n.next_msg +local nvim_prog = n.nvim_prog local pcall_err = t.pcall_err local sleep = vim.uv.sleep local write_file = t.write_file @@ -511,11 +513,11 @@ describe('API: buffer events:', function() -- create several new sessions, in addition to our main API local sessions = {} - local pipe = t.new_pipename() + local pipe = n.new_pipename() eval("serverstart('" .. pipe .. "')") - sessions[1] = t.connect(pipe) - sessions[2] = t.connect(pipe) - sessions[3] = t.connect(pipe) + sessions[1] = n.connect(pipe) + sessions[2] = n.connect(pipe) + sessions[3] = n.connect(pipe) local function request(sessionnr, method, ...) local status, rv = sessions[sessionnr]:request(method, ...) @@ -814,7 +816,7 @@ describe('API: buffer events:', function() clear() sleep(250) -- response - eq(true, t.request('nvim_buf_attach', 0, false, {})) + eq(true, n.request('nvim_buf_attach', 0, false, {})) -- notification eq({ [1] = 'notification', diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local NIL = vim.NIL -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local api = t.api +local api = n.api local matches = t.matches -local source = t.source +local source = n.source local pcall_err = t.pcall_err -local exec_lua = t.exec_lua -local assert_alive = t.assert_alive -local feed = t.feed -local fn = t.fn +local exec_lua = n.exec_lua +local assert_alive = n.assert_alive +local feed = n.feed +local fn = n.fn describe('nvim_get_commands', function() local cmd_dict = { diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua @@ -1,20 +1,21 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local request = t.request +local request = n.request local eq = t.eq local ok = t.ok local pcall_err = t.pcall_err -local insert = t.insert -local feed = t.feed -local clear = t.clear -local command = t.command -local exec = t.exec -local api = t.api -local assert_alive = t.assert_alive +local insert = n.insert +local feed = n.feed +local clear = n.clear +local command = n.command +local exec = n.exec +local api = n.api +local assert_alive = n.assert_alive local function expect(contents) - return eq(contents, t.curbuf_contents()) + return eq(contents, n.curbuf_contents()) end local function set_extmark(ns_id, id, line, col, opts) diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local eq, eval = t.eq, t.eval -local command = t.command -local exec_capture = t.exec_capture -local api = t.api -local fn = t.fn + +local clear = n.clear +local eq, eval = t.eq, n.eval +local command = n.command +local exec_capture = n.exec_capture +local api = n.api +local fn = n.fn local pcall_err = t.pcall_err local ok = t.ok -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive describe('API: highlight', function() clear() diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq, neq = t.eq, t.neq -local exec_lua = t.exec_lua -local exec = t.exec -local feed = t.feed -local fn = t.fn -local api = t.api +local exec_lua = n.exec_lua +local exec = n.exec +local feed = n.feed +local fn = n.fn +local api = n.api local matches = t.matches -local source = t.source +local source = n.source local pcall_err = t.pcall_err local shallowcopy = t.shallowcopy @@ -1146,7 +1147,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() feed('asdf\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap asdf')) + eq('\nNo mapping found', n.exec_capture('nmap asdf')) end) it('no double-free when unmapping simplifiable lua mappings', function() @@ -1170,13 +1171,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function() feed('<C-I>\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap <C-I>')) + eq('\nNo mapping found', n.exec_capture('nmap <C-I>')) end) it('can set descriptions on mappings', function() api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs')) - eq('\nn lhs rhs\n map description', t.exec_capture('nmap lhs')) + eq('\nn lhs rhs\n map description', n.exec_capture('nmap lhs')) end) it('can define !-mode abbreviations with lua callbacks', function() @@ -1331,7 +1332,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() it('does not crash when setting mapping in a non-existing buffer #13541', function() pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {}) - t.assert_alive() + n.assert_alive() end) it('can make lua mappings', function() @@ -1426,7 +1427,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() feed('asdf\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap asdf')) + eq('\nNo mapping found', n.exec_capture('nmap asdf')) end) it('no double-free when unmapping simplifiable lua mappings', function() @@ -1450,6 +1451,6 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() feed('<C-I>\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap <C-I>')) + eq('\nNo mapping found', n.exec_capture('nmap <C-I>')) end) end) diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua @@ -1,9 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local feed = t.feed +local clear = n.clear +local command = n.command +local feed = n.feed describe('update_menu notification', function() local screen diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local fn = t.fn +local fn = n.fn local neq = t.neq -local nvim_argv = t.nvim_argv -local request = t.request +local nvim_argv = n.nvim_argv +local request = n.request local retry = t.retry local NIL = vim.NIL local is_os = t.is_os diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local assert_log = t.assert_log -local eq, clear, eval, command, next_msg = t.eq, t.clear, t.eval, t.command, t.next_msg -local api = t.api -local exec_lua = t.exec_lua +local eq, clear, eval, command, next_msg = t.eq, n.clear, n.eval, n.command, n.next_msg +local api = n.api +local exec_lua = n.exec_lua local retry = t.retry -local assert_alive = t.assert_alive -local check_close = t.check_close +local assert_alive = n.assert_alive +local check_close = n.check_close local testlog = 'Xtest-server-notify-log' diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua @@ -1,17 +1,18 @@ -- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate -- `rpcrequest` calls we need the client event loop to be running. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear, eval = t.clear, t.eval -local eq, neq, run, stop = t.eq, t.neq, t.run, t.stop -local nvim_prog, command, fn = t.nvim_prog, t.command, t.fn -local source, next_msg = t.source, t.next_msg +local clear, eval = n.clear, n.eval +local eq, neq, run, stop = t.eq, t.neq, n.run, n.stop +local nvim_prog, command, fn = n.nvim_prog, n.command, n.fn +local source, next_msg = n.source, n.next_msg local ok = t.ok -local api = t.api -local spawn, merge_args = t.spawn, t.merge_args -local set_session = t.set_session +local api = n.api +local spawn, merge_args = n.spawn, n.merge_args +local set_session = n.set_session local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive describe('server -> client', function() local cid @@ -91,19 +92,19 @@ describe('server -> client', function() local function on_request(method, args) eq('rcall', method) - local n = unpack(args) * 2 - if n <= 16 then + local _n = unpack(args) * 2 + if _n <= 16 then local cmd - if n == 4 then - cmd = 'let g:result2 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')' - elseif n == 8 then - cmd = 'let g:result3 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')' - elseif n == 16 then - cmd = 'let g:result4 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')' + if _n == 4 then + cmd = 'let g:result2 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')' + elseif _n == 8 then + cmd = 'let g:result3 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')' + elseif _n == 16 then + cmd = 'let g:result4 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')' end command(cmd) end - return n + return _n end run(on_request, nil, on_setup) end) @@ -280,7 +281,7 @@ describe('server -> client', function() end) describe('connecting to another (peer) nvim', function() - local nvim_argv = merge_args(t.nvim_argv, { '--headless' }) + local nvim_argv = merge_args(n.nvim_argv, { '--headless' }) local function connect_test(server, mode, address) local serverpid = fn.getpid() local client = spawn(nvim_argv, false, nil, true) diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() -local clear, eq, ok = t.clear, t.eq, t.ok -local exec = t.exec -local feed = t.feed -local api = t.api -local fn = t.fn -local request = t.request +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, ok = n.clear, t.eq, t.ok +local exec = n.exec +local feed = n.feed +local api = n.api +local fn = n.fn +local request = n.request local NIL = vim.NIL local pcall_err = t.pcall_err -local command = t.command +local command = n.command describe('api/tabpage', function() before_each(clear) diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local exec = t.exec -local feed = t.feed -local api = t.api -local request = t.request +local eval = n.eval +local exec = n.exec +local feed = n.feed +local api = n.api +local request = n.request local pcall_err = t.pcall_err describe('nvim_ui_attach()', function() diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, fn, eq = t.clear, t.fn, t.eq -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, fn, eq = n.clear, n.fn, t.eq +local api = n.api local function read_mpack_file(fname) local fd = io.open(fname, 'rb') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua @@ -1,36 +1,37 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local uv = vim.uv local fmt = string.format local dedent = t.dedent -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local NIL = vim.NIL -local clear, eq, neq = t.clear, t.eq, t.neq -local command = t.command -local command_output = t.api.nvim_command_output -local exec = t.exec -local exec_capture = t.exec_capture -local eval = t.eval -local expect = t.expect -local fn = t.fn -local api = t.api +local clear, eq, neq = n.clear, t.eq, t.neq +local command = n.command +local command_output = n.api.nvim_command_output +local exec = n.exec +local exec_capture = n.exec_capture +local eval = n.eval +local expect = n.expect +local fn = n.fn +local api = n.api local matches = t.matches local pesc = vim.pesc -local mkdir_p = t.mkdir_p -local ok, nvim_async, feed = t.ok, t.nvim_async, t.feed -local async_meths = t.async_meths +local mkdir_p = n.mkdir_p +local ok, nvim_async, feed = t.ok, n.nvim_async, n.feed +local async_meths = n.async_meths local is_os = t.is_os -local parse_context = t.parse_context -local request = t.request -local rmdir = t.rmdir -local source = t.source -local next_msg = t.next_msg +local parse_context = n.parse_context +local request = n.request +local rmdir = n.rmdir +local source = n.source +local next_msg = n.next_msg local tmpname = t.tmpname local write_file = t.write_file -local exec_lua = t.exec_lua -local exc_exec = t.exc_exec -local insert = t.insert +local exec_lua = n.exec_lua +local exc_exec = n.exc_exec +local insert = n.insert local skip = t.skip local pcall_err = t.pcall_err @@ -722,12 +723,12 @@ describe('API', function() end) after_each(function() - t.rmdir('Xtestdir') + n.rmdir('Xtestdir') end) it('works', function() api.nvim_set_current_dir('Xtestdir') - eq(start_dir .. t.get_pathsep() .. 'Xtestdir', fn.getcwd()) + eq(start_dir .. n.get_pathsep() .. 'Xtestdir', fn.getcwd()) end) it('sets previous directory', function() @@ -1487,7 +1488,7 @@ describe('API', function() eq(NIL, api.nvim_get_var('Unknown_script_func')) -- Check if autoload works properly - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() local xconfig = 'Xhome' .. pathsep .. 'Xconfig' local xdata = 'Xhome' .. pathsep .. 'Xdata' local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep) @@ -1971,7 +1972,7 @@ describe('API', function() describe('RPC (K_EVENT)', function() it('does not complete ("interrupt") normal-mode operator-pending #6166', function() - t.insert([[ + n.insert([[ FIRST LINE SECOND LINE]]) api.nvim_input('gg') @@ -2008,7 +2009,7 @@ describe('API', function() it('does not complete ("interrupt") normal-mode map-pending #6166', function() command("nnoremap dd :let g:foo='it worked...'<CR>") - t.insert([[ + n.insert([[ FIRST LINE SECOND LINE]]) api.nvim_input('gg') @@ -2020,13 +2021,13 @@ describe('API', function() expect([[ FIRST LINE SECOND LINE]]) - eq('it worked...', t.eval('g:foo')) + eq('it worked...', n.eval('g:foo')) end) it('does not complete ("interrupt") insert-mode map-pending #6166', function() command('inoremap xx foo') command('set timeoutlen=9999') - t.insert([[ + n.insert([[ FIRST LINE SECOND LINE]]) api.nvim_input('ix') @@ -2173,32 +2174,32 @@ describe('API', function() describe('nvim_replace_termcodes', function() it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function() - eq('\128\254X', t.api.nvim_replace_termcodes('\128', true, true, true)) + eq('\128\254X', n.api.nvim_replace_termcodes('\128', true, true, true)) end) it('leaves non-K_SPECIAL string unchanged', function() - eq('abc', t.api.nvim_replace_termcodes('abc', true, true, true)) + eq('abc', n.api.nvim_replace_termcodes('abc', true, true, true)) end) it('converts <expressions>', function() - eq('\\', t.api.nvim_replace_termcodes('<Leader>', true, true, true)) + eq('\\', n.api.nvim_replace_termcodes('<Leader>', true, true, true)) end) it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function() -- K_SPECIAL KS_EXTRA KE_LEFTMOUSE -- 0x80 0xfd 0x2c -- 128 253 44 - eq('\128\253\44', t.api.nvim_replace_termcodes('<LeftMouse>', true, true, true)) + eq('\128\253\44', n.api.nvim_replace_termcodes('<LeftMouse>', true, true, true)) end) it('converts keycodes', function() - eq('\nx\27x\rx<x', t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)) + eq('\nx\27x\rx<x', n.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)) end) it('does not convert keycodes if special=false', function() eq( '<NL>x<Esc>x<CR>x<lt>x', - t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false) + n.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false) ) end) @@ -2227,18 +2228,18 @@ describe('API', function() api.nvim_feedkeys(':let x1="…"\n', '', true) -- Both nvim_replace_termcodes and nvim_feedkeys escape \x80 - local inp = t.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true) + local inp = n.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true) api.nvim_feedkeys(inp, '', true) -- escape_ks=true -- nvim_feedkeys with K_SPECIAL escaping disabled - inp = t.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true) + inp = n.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true) api.nvim_feedkeys(inp, '', false) -- escape_ks=false - t.stop() + n.stop() end -- spin the loop a bit - t.run(nil, nil, on_setup) + n.run(nil, nil, on_setup) eq('…', api.nvim_get_var('x1')) -- Because of the double escaping this is neq @@ -2381,7 +2382,7 @@ describe('API', function() {0:~ }|*6 {1:very fail} | ]]) - t.poke_eventloop() + n.poke_eventloop() -- shows up to &cmdheight lines async_meths.nvim_err_write('more fail\ntoo fail\n') @@ -2693,7 +2694,7 @@ describe('API', function() describe('nvim_list_runtime_paths', function() setup(function() - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() mkdir_p('Xtest' .. pathsep .. 'a') mkdir_p('Xtest' .. pathsep .. 'b') end) @@ -3200,7 +3201,7 @@ describe('API', function() end) describe('nvim_get_runtime_file', function() - local p = t.alter_slashes + local p = n.alter_slashes it('can find files', function() eq({}, api.nvim_get_runtime_file('bork.borkbork', false)) eq({}, api.nvim_get_runtime_file('bork.borkbork', true)) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua @@ -1,27 +1,29 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') + local clear, curbuf, curbuf_contents, curwin, eq, neq, matches, ok, feed, insert, eval = - t.clear, - t.api.nvim_get_current_buf, - t.curbuf_contents, - t.api.nvim_get_current_win, + n.clear, + n.api.nvim_get_current_buf, + n.curbuf_contents, + n.api.nvim_get_current_win, t.eq, t.neq, t.matches, t.ok, - t.feed, - t.insert, - t.eval -local poke_eventloop = t.poke_eventloop -local exec = t.exec -local exec_lua = t.exec_lua -local fn = t.fn -local request = t.request + n.feed, + n.insert, + n.eval +local poke_eventloop = n.poke_eventloop +local exec = n.exec +local exec_lua = n.exec_lua +local fn = n.fn +local request = n.request local NIL = vim.NIL -local api = t.api -local command = t.command +local api = n.api +local command = n.command local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive describe('API/win', function() before_each(clear) @@ -136,7 +138,7 @@ describe('API/win', function() end) after_each(function() - t.rmdir(topdir .. '/Xacd') + n.rmdir(topdir .. '/Xacd') end) it('does not change cwd with non-current window', function() @@ -1370,7 +1372,7 @@ describe('API/win', function() local tab1 = api.nvim_get_current_tabpage() local tab1_win = api.nvim_get_current_win() - t.command('tabnew') + n.command('tabnew') local tab2 = api.nvim_get_current_tabpage() local tab2_win = api.nvim_get_current_win() @@ -1790,7 +1792,7 @@ describe('API/win', function() end) after_each(function() - t.rmdir(topdir .. '/Xacd') + n.rmdir(topdir .. '/Xacd') end) it('does not change cwd with enter=false #15280', function() diff --git a/test/functional/autocmd/autocmd_oldtest_spec.lua b/test/functional/autocmd/autocmd_oldtest_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear +local clear = n.clear local eq = t.eq -local api = t.api -local fn = t.fn -local exec = t.exec -local feed = t.feed +local api = n.api +local fn = n.fn +local exec = n.exec +local feed = n.feed local assert_log = t.assert_log -local check_close = t.check_close +local check_close = n.check_close local is_os = t.is_os local testlog = 'Xtest_autocmd_oldtest_log' diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua @@ -1,24 +1,25 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_visible = t.assert_visible -local assert_alive = t.assert_alive +local assert_visible = n.assert_visible +local assert_alive = n.assert_alive local dedent = t.dedent local eq = t.eq local neq = t.neq -local eval = t.eval -local feed = t.feed -local clear = t.clear +local eval = n.eval +local feed = n.feed +local clear = n.clear local matches = t.matches -local api = t.api +local api = n.api local pcall_err = t.pcall_err -local fn = t.fn -local expect = t.expect -local command = t.command -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua +local fn = n.fn +local expect = n.expect +local command = n.command +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua local retry = t.retry -local source = t.source +local source = n.source describe('autocmd', function() before_each(clear) diff --git a/test/functional/autocmd/bufenter_spec.lua b/test/functional/autocmd/bufenter_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local request = t.request -local source = t.source +local eval = n.eval +local request = n.request +local source = n.source describe('autocmd BufEnter', function() before_each(clear) @@ -33,7 +34,7 @@ describe('autocmd BufEnter', function() end) it('triggered by ":split normal|:help|:bw"', function() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() command('split normal') command('wincmd j') command('help') diff --git a/test/functional/autocmd/bufmodifiedset_spec.lua b/test/functional/autocmd/bufmodifiedset_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local source = t.source -local request = t.request +local eval = n.eval +local source = n.source +local request = n.request describe('BufModified', function() before_each(clear) diff --git a/test/functional/autocmd/cmdline_spec.lua b/test/functional/autocmd/cmdline_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local expect = t.expect -local eval = t.eval -local next_msg = t.next_msg -local feed = t.feed -local api = t.api +local expect = n.expect +local eval = n.eval +local next_msg = n.next_msg +local feed = n.feed +local api = n.api describe('cmdline autocommands', function() local channel diff --git a/test/functional/autocmd/cursorhold_spec.lua b/test/functional/autocmd/cursorhold_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local feed = t.feed +local feed = n.feed local retry = t.retry -local exec = t.source +local exec = n.source local sleep = vim.uv.sleep -local api = t.api +local api = n.api before_each(clear) diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local api = t.api -local source = t.source -local command = t.command +local eval = n.eval +local api = n.api +local source = n.source +local command = n.command describe('CursorMoved', function() before_each(clear) diff --git a/test/functional/autocmd/dirchanged_spec.lua b/test/functional/autocmd/dirchanged_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local request = t.request +local eval = n.eval +local request = n.request local is_os = t.is_os describe('autocmd DirChanged and DirChangedPre', function() @@ -27,7 +28,7 @@ describe('autocmd DirChanged and DirChangedPre', function() end) teardown(function() for _, dir in pairs(dirs) do - t.rmdir(dir) + n.rmdir(dir) end end) diff --git a/test/functional/autocmd/filetype_spec.lua b/test/functional/autocmd/filetype_spec.lua @@ -1,14 +1,14 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local eval = t.eval -local clear = t.clear -local command = t.command +local eval = n.eval +local clear = n.clear +local command = n.command describe('autocmd FileType', function() before_each(clear) it('is triggered by :help only once', function() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() command('let g:foo = 0') command('autocmd FileType help let g:foo = g:foo + 1') command('help help') diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local tt = require('test.functional.terminal.testutil') -local clear = t.clear -local feed_command = t.feed_command + +local clear = n.clear +local feed_command = n.feed_command local feed_data = tt.feed_data if t.skip(t.is_os('win')) then diff --git a/test/functional/autocmd/modechanged_spec.lua b/test/functional/autocmd/modechanged_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local feed, command = t.feed, t.command -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local feed, command = n.feed, n.command +local exec_lua = n.exec_lua describe('ModeChanged', function() before_each(function() diff --git a/test/functional/autocmd/recording_spec.lua b/test/functional/autocmd/recording_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local source_vim = t.source +local eval = n.eval +local source_vim = n.source describe('RecordingEnter', function() before_each(clear) diff --git a/test/functional/autocmd/safestate_spec.lua b/test/functional/autocmd/safestate_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local exec = t.exec -local feed = t.feed -local api = t.api +local exec = n.exec +local feed = n.feed +local api = n.api before_each(clear) diff --git a/test/functional/autocmd/searchwrapped_spec.lua b/test/functional/autocmd/searchwrapped_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command -local api = t.api +local clear = n.clear +local command = n.command +local api = n.api local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed describe('autocmd SearchWrapped', function() before_each(function() diff --git a/test/functional/autocmd/show_spec.lua b/test/functional/autocmd/show_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local dedent = t.dedent local eq = t.eq -local fn = t.fn -local eval = t.eval -local exec = t.exec -local feed = t.feed +local fn = n.fn +local eval = n.eval +local exec = n.exec +local feed = n.feed describe(':autocmd', function() before_each(function() diff --git a/test/functional/autocmd/signal_spec.lua b/test/functional/autocmd/signal_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local fn = t.fn -local next_msg = t.next_msg +local fn = n.fn +local next_msg = n.next_msg local is_os = t.is_os local skip = t.skip diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eq = t.clear, t.eq -local api = t.api -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq = n.clear, t.eq +local api = n.api +local command = n.command describe('TabClosed', function() before_each(clear) diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval +local eval = n.eval describe('autocmd TabNew', function() before_each(clear) diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local dedent = t.dedent -local eval = t.eval +local eval = n.eval local eq = t.eq -local feed = t.feed -local api = t.api -local exec_capture = t.exec_capture +local feed = n.feed +local api = n.api +local exec_capture = n.exec_capture describe('TabNewEntered', function() describe('au TabNewEntered', function() diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua @@ -1,15 +1,16 @@ -local uv = vim.uv -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local tt = require('test.functional.terminal.testutil') +local uv = vim.uv -local clear, command, testprg = t.clear, t.command, t.testprg -local eval, eq, neq, retry = t.eval, t.eq, t.neq, t.retry +local clear, command, testprg = n.clear, n.command, n.testprg +local eval, eq, neq, retry = n.eval, t.eq, t.neq, t.retry local matches = t.matches local ok = t.ok -local feed = t.feed -local api = t.api +local feed = n.feed +local api = n.api local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local skip = t.skip local is_os = t.is_os diff --git a/test/functional/autocmd/textchanged_spec.lua b/test/functional/autocmd/textchanged_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec = t.exec -local command = t.command -local feed = t.feed +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec = n.exec +local command = n.command +local feed = n.feed local eq = t.eq local neq = t.neq -local eval = t.eval -local poke_eventloop = t.poke_eventloop +local eval = n.eval +local poke_eventloop = n.poke_eventloop local write_file = t.write_file -- oldtest: Test_ChangedP() diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local feed, command, expect = t.feed, t.command, t.expect -local api, fn, neq = t.api, t.fn, t.neq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local feed, command, expect = n.feed, n.command, n.expect +local api, fn, neq = n.api, n.fn, t.neq describe('TextYankPost', function() before_each(function() diff --git a/test/functional/autocmd/win_scrolled_resized_spec.lua b/test/functional/autocmd/win_scrolled_resized_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local exec = t.exec -local command = t.command -local feed = t.feed -local api = t.api -local assert_alive = t.assert_alive +local eval = n.eval +local exec = n.exec +local command = n.command +local feed = n.feed +local api = n.api +local assert_alive = n.assert_alive before_each(clear) diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() -local clear, eq, eval, next_msg, ok, source = t.clear, t.eq, t.eval, t.next_msg, t.ok, t.source -local command, fn, api = t.command, t.fn, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, eval, next_msg, ok, source = n.clear, t.eq, n.eval, n.next_msg, t.ok, n.source +local command, fn, api = n.command, n.fn, n.api local matches = t.matches local sleep = vim.uv.sleep -local spawn, nvim_argv = t.spawn, t.nvim_argv -local get_session, set_session = t.get_session, t.set_session -local nvim_prog = t.nvim_prog +local spawn, nvim_argv = n.spawn, n.nvim_argv +local get_session, set_session = n.get_session, n.set_session +local nvim_prog = n.nvim_prog local is_os = t.is_os local retry = t.retry -local expect_twostreams = t.expect_twostreams -local assert_alive = t.assert_alive +local expect_twostreams = n.expect_twostreams +local assert_alive = n.assert_alive local pcall_err = t.pcall_err local skip = t.skip diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua @@ -1,24 +1,25 @@ -local t = require('test.functional.testutil')() - -local assert_alive = t.assert_alive -local command = t.command -local feed_command = t.feed_command -local feed = t.feed -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local command = n.command +local feed_command = n.feed_command +local feed = n.feed +local eval = n.eval local eq = t.eq -local run = t.run -local fn = t.fn -local nvim_prog = t.nvim_prog +local run = n.run +local fn = n.fn +local nvim_prog = n.nvim_prog local pcall_err = t.pcall_err -local exec_capture = t.exec_capture -local poke_eventloop = t.poke_eventloop +local exec_capture = n.exec_capture +local poke_eventloop = n.poke_eventloop describe('v:exiting', function() local cid before_each(function() - t.clear() - cid = t.api.nvim_get_chan_info(0).id + n.clear() + cid = n.api.nvim_get_chan_info(0).id end) it('defaults to v:null', function() @@ -74,7 +75,7 @@ describe(':cquit', function() end before_each(function() - t.clear() + n.clear() end) it('exits with non-zero after :cquit', function() diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua @@ -1,37 +1,38 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') local uv = vim.uv -local t = require('test.functional.testutil')() local assert_log = t.assert_log local assert_nolog = t.assert_nolog -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq local neq = t.neq local ok = t.ok -local feed = t.feed -local fn = t.fn -local nvim_prog = t.nvim_prog -local request = t.request +local feed = n.feed +local fn = n.fn +local nvim_prog = n.nvim_prog +local request = n.request local retry = t.retry -local rmdir = t.rmdir +local rmdir = n.rmdir local matches = t.matches -local api = t.api +local api = n.api local mkdir = t.mkdir local sleep = vim.uv.sleep local read_file = t.read_file local trim = vim.trim -local currentdir = t.fn.getcwd -local assert_alive = t.assert_alive -local check_close = t.check_close -local expect_exit = t.expect_exit +local currentdir = n.fn.getcwd +local assert_alive = n.assert_alive +local check_close = n.check_close +local expect_exit = n.expect_exit local write_file = t.write_file -local Screen = require('test.functional.ui.screen') -local feed_command = t.feed_command +local feed_command = n.feed_command local skip = t.skip local is_os = t.is_os local is_ci = t.is_ci -local spawn = t.spawn -local set_session = t.set_session +local spawn = n.spawn +local set_session = n.set_session describe('fileio', function() before_each(function() end) @@ -228,7 +229,7 @@ describe('fileio', function() local initial_content = 'foo' local backup_dir = 'Xtest_backupdir' - local sep = t.get_pathsep() + local sep = n.get_pathsep() local link_file_name = 'Xtest_startup_file2' local backup_file_name = backup_dir .. sep .. link_file_name .. '~' diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua @@ -1,38 +1,39 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') local tt = require('test.functional.terminal.testutil') -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local exc_exec = t.exc_exec -local feed_command = t.feed_command -local feed = t.feed -local insert = t.insert +local eval = n.eval +local exc_exec = n.exc_exec +local feed_command = n.feed_command +local feed = n.feed +local insert = n.insert local neq = t.neq -local next_msg = t.next_msg -local testprg = t.testprg +local next_msg = n.next_msg +local testprg = n.testprg local ok = t.ok -local source = t.source +local source = n.source local write_file = t.write_file local mkdir = t.mkdir -local rmdir = t.rmdir -local assert_alive = t.assert_alive -local command = t.command -local fn = t.fn -local os_kill = t.os_kill +local rmdir = n.rmdir +local assert_alive = n.assert_alive +local command = n.command +local fn = n.fn +local os_kill = n.os_kill local retry = t.retry -local api = t.api +local api = n.api local NIL = vim.NIL -local poke_eventloop = t.poke_eventloop -local get_pathsep = t.get_pathsep -local pathroot = t.pathroot -local exec_lua = t.exec_lua -local nvim_set = t.nvim_set -local expect_twostreams = t.expect_twostreams -local expect_msg_seq = t.expect_msg_seq +local poke_eventloop = n.poke_eventloop +local get_pathsep = n.get_pathsep +local pathroot = n.pathroot +local exec_lua = n.exec_lua +local nvim_set = n.nvim_set +local expect_twostreams = n.expect_twostreams +local expect_msg_seq = n.expect_msg_seq local pcall_err = t.pcall_err local matches = t.matches -local Screen = require('test.functional.ui.screen') local skip = t.skip local is_os = t.is_os @@ -732,7 +733,7 @@ describe('jobs', function() describe('jobwait()', function() before_each(function() if is_os('win') then - t.set_shell_powershell() + n.set_shell_powershell() end end) @@ -1239,7 +1240,7 @@ describe('pty process teardown', function() skip(fn.executable('sleep') == 0, 'missing "sleep" command') -- Use a nested nvim (in :term) to test without --headless. fn.termopen({ - t.nvim_prog, + n.nvim_prog, '-u', 'NONE', '-i', diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local assert_log = t.assert_log -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local exec_lua = t.exec_lua -local expect_exit = t.expect_exit -local request = t.request +local exec_lua = n.exec_lua +local expect_exit = n.expect_exit +local request = n.request describe('log', function() local testlog = 'Xtest_logging' diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua @@ -1,14 +1,15 @@ -local uv = vim.uv -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local uv = vim.uv local eq = t.eq local matches = t.matches -local feed = t.feed -local eval = t.eval -local clear = t.clear -local fn = t.fn -local nvim_prog_abs = t.nvim_prog_abs +local feed = n.feed +local eval = n.eval +local clear = n.clear +local fn = n.fn +local nvim_prog_abs = n.nvim_prog_abs local write_file = t.write_file local is_os = t.is_os local skip = t.skip diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed -local fn = t.fn -local insert = t.insert +local eval = n.eval +local feed = n.feed +local fn = n.fn +local insert = n.insert local is_os = t.is_os local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local write_file = t.write_file local function join_path(...) diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua @@ -1,18 +1,19 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local exec_capture = t.exec_capture -local exec_lua = t.exec_lua -local expect = t.expect -local fn = t.fn -local insert = t.insert -local nvim_prog = t.nvim_prog -local new_argv = t.new_argv +local exec_capture = n.exec_capture +local exec_lua = n.exec_lua +local expect = n.expect +local fn = n.fn +local insert = n.insert +local nvim_prog = n.nvim_prog +local new_argv = n.new_argv local neq = t.neq -local set_session = t.set_session -local spawn = t.spawn +local set_session = n.set_session +local spawn = n.spawn local tmpname = t.tmpname local write_file = t.write_file diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local api = t.api -local exc_exec = t.exc_exec -local fn = t.fn -local rmdir = t.rmdir +local clear = n.clear +local api = n.api +local exc_exec = n.exc_exec +local fn = n.fn +local rmdir = n.rmdir local write_file = t.write_file local mkdir = t.mkdir diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua @@ -1,38 +1,39 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local assert_log = t.assert_log -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local ok = t.ok local eq = t.eq local matches = t.matches -local eval = t.eval -local exec = t.exec -local exec_capture = t.exec_capture -local exec_lua = t.exec_lua -local feed = t.feed -local fn = t.fn +local eval = n.eval +local exec = n.exec +local exec_capture = n.exec_capture +local exec_lua = n.exec_lua +local feed = n.feed +local fn = n.fn local pesc = vim.pesc local mkdir = t.mkdir -local mkdir_p = t.mkdir_p -local nvim_prog = t.nvim_prog -local nvim_set = t.nvim_set +local mkdir_p = n.mkdir_p +local nvim_prog = n.nvim_prog +local nvim_set = n.nvim_set local read_file = t.read_file local retry = t.retry -local rmdir = t.rmdir +local rmdir = n.rmdir local sleep = vim.uv.sleep local startswith = vim.startswith local write_file = t.write_file -local api = t.api -local alter_slashes = t.alter_slashes +local api = n.api +local alter_slashes = n.alter_slashes local is_os = t.is_os local dedent = t.dedent local tbl_map = vim.tbl_map local tbl_filter = vim.tbl_filter local endswith = vim.endswith -local check_close = t.check_close +local check_close = n.check_close local testlog = 'Xtest-startupspec-log' @@ -994,7 +995,7 @@ describe('sysinit', function() local xdgdir = 'Xxdg' local vimdir = 'Xvim' local xhome = 'Xhome' - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() before_each(function() rmdir(xdgdir) @@ -1055,7 +1056,7 @@ end) describe('user config init', function() local xhome = 'Xhome' - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() local xconfig = xhome .. pathsep .. 'Xconfig' local xdata = xhome .. pathsep .. 'Xdata' local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep) @@ -1218,7 +1219,7 @@ end) describe('runtime:', function() local xhome = 'Xhome' - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() local xconfig = xhome .. pathsep .. 'Xconfig' local xdata = xhome .. pathsep .. 'Xdata' local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata } @@ -1360,7 +1361,7 @@ end) describe('user session', function() local xhome = 'Xhome' - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() local session_file = table.concat({ xhome, 'session.lua' }, pathsep) before_each(function() diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local eq, clear, eval, feed, api, retry = t.eq, t.clear, t.eval, t.feed, t.api, t.retry +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear, eval, feed, api, retry = t.eq, n.clear, n.eval, n.feed, n.api, t.retry describe('K', function() local test_file = 'K_spec_out' @@ -12,19 +14,19 @@ describe('K', function() end) it("invokes colon-prefixed 'keywordprg' as Vim command", function() - t.source([[ + n.source([[ let @a='fnord' set keywordprg=:put]]) -- K on the text "a" resolves to `:put a`. feed('ia<ESC>K') - t.expect([[ + n.expect([[ a fnord]]) end) it("invokes non-prefixed 'keywordprg' as shell command", function() - t.source([[ + n.source([[ let @a='fnord' set keywordprg=echo\ fnord>>]]) @@ -42,7 +44,7 @@ describe('K', function() end) it("<esc> kills the buffer for a running 'keywordprg' command", function() - t.source('set keywordprg=less') + n.source('set keywordprg=less') eval('writefile(["hello", "world"], "' .. test_file .. '")') feed('i' .. test_file .. '<esc>K') eq('t', eval('mode()')) diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local clear, feed = t.clear, t.feed -local eval, eq, neq = t.eval, t.eq, t.neq -local feed_command, source, expect = t.feed_command, t.source, t.expect -local fn = t.fn -local command = t.command -local api = t.api -local poke_eventloop = t.poke_eventloop + +local assert_alive = n.assert_alive +local clear, feed = n.clear, n.feed +local eval, eq, neq = n.eval, t.eq, t.neq +local feed_command, source, expect = n.feed_command, n.source, n.expect +local fn = n.fn +local command = n.command +local api = n.api +local poke_eventloop = n.poke_eventloop describe('completion', function() local screen diff --git a/test/functional/editor/count_spec.lua b/test/functional/editor/count_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local feed = t.feed -local clear = t.clear -local command = t.command +local eval = n.eval +local feed = n.feed +local clear = n.clear +local command = n.command describe('v:count/v:count1', function() before_each(function() diff --git a/test/functional/editor/ctrl_c_spec.lua b/test/functional/editor/ctrl_c_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, source = t.clear, t.feed, t.source -local command = t.command -local poke_eventloop = t.poke_eventloop + +local clear, feed, source = n.clear, n.feed, n.source +local command = n.command +local poke_eventloop = n.poke_eventloop local sleep = vim.uv.sleep describe('CTRL-C (mapped)', function() diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() - -local clear = t.clear -local insert = t.insert -local exec = t.exec -local feed = t.feed -local expect = t.expect -local command = t.command -local fn = t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local insert = n.insert +local exec = n.exec +local feed = n.feed +local expect = n.expect +local command = n.command +local fn = n.fn local eq = t.eq local neq = t.neq @@ -376,7 +377,7 @@ a]], end) it('splits folds according to >N and <N with foldexpr', function() - t.source([[ + n.source([[ function TestFoldExpr(lnum) let thisline = getline(a:lnum) if thisline == 'a' diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local dedent = t.dedent local eq = t.eq -local fn = t.fn -local feed = t.feed -local exec_capture = t.exec_capture +local fn = n.fn +local feed = n.feed +local exec_capture = n.exec_capture local write_file = t.write_file -local api = t.api +local api = n.api describe('jumplist', function() local fname1 = 'Xtest-functional-normal-jump' diff --git a/test/functional/editor/lang_spec.lua b/test/functional/editor/lang_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear, insert, eq = t.clear, t.insert, t.eq -local command, expect = t.command, t.expect -local feed, eval = t.feed, t.eval -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, insert, eq = n.clear, n.insert, t.eq +local command, expect = n.command, n.expect +local feed, eval = n.feed, n.eval +local exc_exec = n.exc_exec describe('gu and gU', function() before_each(clear) diff --git a/test/functional/editor/langmap_spec.lua b/test/functional/editor/langmap_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq, neq, call = t.eq, t.neq, t.call -local eval, feed, clear = t.eval, t.feed, t.clear -local command, insert, expect = t.command, t.insert, t.expect -local feed_command = t.feed_command -local curwin = t.api.nvim_get_current_win +local eq, neq, call = t.eq, t.neq, n.call +local eval, feed, clear = n.eval, n.feed, n.clear +local command, insert, expect = n.command, n.insert, n.expect +local feed_command = n.feed_command +local curwin = n.api.nvim_get_current_win describe("'langmap'", function() before_each(function() @@ -133,7 +134,7 @@ describe("'langmap'", function() hello]]) end) it('command-line CTRL-R', function() - t.source([[ + n.source([[ let i_value = 0 let j_value = 0 call setreg('i', 'i_value') @@ -171,7 +172,7 @@ describe("'langmap'", function() end) it('prompt for number', function() command('set langmap=12,21') - t.source([[ + n.source([[ let gotten_one = 0 function Map() let answer = inputlist(['a', '1.', '2.', '3.']) @@ -214,7 +215,7 @@ describe("'langmap'", function() end feed('qa' .. command_string .. 'q') expect(expect_string) - eq(expect_macro or t.fn.nvim_replace_termcodes(command_string, true, true, true), eval('@a')) + eq(expect_macro or n.fn.nvim_replace_termcodes(command_string, true, true, true), eval('@a')) if setup_function then setup_function() end diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local feed = t.feed -local clear = t.clear -local expect = t.expect -local command = t.command -local fn = t.fn -local api = t.api -local insert = t.insert +local eval = n.eval +local feed = n.feed +local clear = n.clear +local expect = n.expect +local command = n.command +local fn = n.fn +local api = n.api +local insert = n.insert describe('macros with default mappings', function() before_each(function() diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local api = t.api -local clear = t.clear -local command = t.command -local fn = t.fn + +local api = n.api +local clear = n.clear +local command = n.command +local fn = n.fn local eq = t.eq -local feed = t.feed +local feed = n.feed local write_file = t.write_file local pcall_err = t.pcall_err local cursor = function() - return t.api.nvim_win_get_cursor(0) + return n.api.nvim_win_get_cursor(0) end describe('named marks', function() @@ -39,59 +41,59 @@ describe('named marks', function() it('errors when set out of range with :mark', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, '1000mark x') + local err = pcall_err(n.exec_capture, '1000mark x') eq('nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x', err) end) it('errors when set out of range with :k', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, '1000kx') + local err = pcall_err(n.exec_capture, '1000kx') eq('nvim_exec2(): Vim(k):E16: Invalid range: 1000kx', err) end) it('errors on unknown mark name with :mark', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, 'mark #') + local err = pcall_err(n.exec_capture, 'mark #') eq('nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote', err) end) it("errors on unknown mark name with '", function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, "normal! '#") + local err = pcall_err(n.exec_capture, "normal! '#") eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err) end) it('errors on unknown mark name with `', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, 'normal! `#') + local err = pcall_err(n.exec_capture, 'normal! `#') eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err) end) it("errors when moving to a mark that is not set with '", function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, "normal! 'z") + local err = pcall_err(n.exec_capture, "normal! 'z") eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) - err = pcall_err(t.exec_capture, "normal! '.") + err = pcall_err(n.exec_capture, "normal! '.") eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) end) it('errors when moving to a mark that is not set with `', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, 'normal! `z') + local err = pcall_err(n.exec_capture, 'normal! `z') eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) - err = pcall_err(t.exec_capture, 'normal! `>') + err = pcall_err(n.exec_capture, 'normal! `>') eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) end) it("errors when moving to a global mark that is not set with '", function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, "normal! 'Z") + local err = pcall_err(n.exec_capture, "normal! 'Z") eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) end) it('errors when moving to a global mark that is not set with `', function() command('edit ' .. file1) - local err = pcall_err(t.exec_capture, 'normal! `Z') + local err = pcall_err(n.exec_capture, 'normal! `Z') eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) end) @@ -166,7 +168,7 @@ describe('named marks', function() feed('mA') command('next') command('bw! ' .. file1) - local err = pcall_err(t.exec_capture, "normal! 'A") + local err = pcall_err(n.exec_capture, "normal! 'A") eq('nvim_exec2(): Vim(normal):E92: Buffer 1 not found', err) os.remove(file1) end) diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local command = t.command -local exec_lua = t.exec_lua -local eval = t.eval -local expect = t.expect -local fn = t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command = n.command +local exec_lua = n.exec_lua +local eval = n.eval +local expect = n.expect +local fn = n.fn local eq = t.eq describe('meta-keys #8226 #13042', function() diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua @@ -1,11 +1,13 @@ -- Cmdline-mode tests. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, insert, fn, eq, feed = t.clear, t.insert, t.fn, t.eq, t.feed -local eval = t.eval -local command = t.command -local api = t.api + +local clear, insert, fn, eq, feed = n.clear, n.insert, n.fn, t.eq, n.feed +local eval = n.eval +local command = n.command +local api = n.api describe('cmdline', function() before_each(clear) diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua @@ -1,14 +1,16 @@ -- Insert-mode tests. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local expect = t.expect -local command = t.command + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect = n.expect +local command = n.command local eq = t.eq -local eval = t.eval -local curbuf_contents = t.curbuf_contents -local api = t.api +local eval = n.eval +local curbuf_contents = n.curbuf_contents +local api = n.api describe('insert-mode', function() before_each(function() @@ -223,10 +225,10 @@ describe('insert-mode', function() end local function test_cols(expected_cols) - local cols = { { t.fn.col('.'), t.fn.virtcol('.') } } + local cols = { { n.fn.col('.'), n.fn.virtcol('.') } } for _ = 2, #expected_cols do feed('<BS>') - table.insert(cols, { t.fn.col('.'), t.fn.virtcol('.') }) + table.insert(cols, { n.fn.col('.'), n.fn.virtcol('.') }) end eq(expected_cols, cols) end diff --git a/test/functional/editor/mode_normal_spec.lua b/test/functional/editor/mode_normal_spec.lua @@ -1,11 +1,13 @@ -- Normal mode tests. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed -local fn = t.fn -local command = t.command + +local clear = n.clear +local feed = n.feed +local fn = n.fn +local command = n.command local eq = t.eq describe('Normal mode', function() @@ -25,7 +27,7 @@ describe('Normal mode', function() local screen = Screen.new(60, 17) screen:attach() fn.termopen( - { t.nvim_prog, '--clean', '--cmd', 'startinsert' }, + { n.nvim_prog, '--clean', '--cmd', 'startinsert' }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } } ) screen:expect({ diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua @@ -1,17 +1,18 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local clear = t.clear -local insert = t.insert -local feed = t.feed -local expect = t.expect +local clear = n.clear +local insert = n.insert +local feed = n.feed +local expect = n.expect local eq = t.eq local map = vim.tbl_map local filter = vim.tbl_filter -local feed_command = t.feed_command -local command = t.command -local curbuf_contents = t.curbuf_contents -local fn = t.fn +local feed_command = n.feed_command +local command = n.command +local curbuf_contents = n.curbuf_contents +local fn = n.fn local dedent = t.dedent local function reset() diff --git a/test/functional/editor/search_spec.lua b/test/functional/editor/search_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq local neq = t.neq -local feed = t.feed -local eval = t.eval -local exec = t.exec -local fn = t.fn -local api = t.api -local curwin = t.api.nvim_get_current_win -local assert_alive = t.assert_alive +local feed = n.feed +local eval = n.eval +local exec = n.exec +local fn = n.fn +local api = n.api +local curwin = n.api.nvim_get_current_win +local assert_alive = n.assert_alive describe('tabpage', function() before_each(clear) diff --git a/test/functional/editor/undo_spec.lua b/test/functional/editor/undo_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command -local eval = t.eval -local expect = t.expect +local clear = n.clear +local command = n.command +local eval = n.eval +local expect = n.expect local eq = t.eq -local feed = t.feed -local feed_command = t.feed_command -local insert = t.insert -local fn = t.fn -local exec = t.exec -local exec_lua = t.exec_lua +local feed = n.feed +local feed_command = n.feed_command +local insert = n.insert +local fn = n.fn +local exec = n.exec +local exec_lua = n.exec_lua local function lastmessage() local messages = fn.split(fn.execute('messages'), '\n') @@ -44,7 +45,7 @@ describe('u CTRL-R g- g+', function() local function undo_and_redo(hist_pos, undo, redo, expect_str) command('enew!') create_history(hist_pos) - local cur_contents = t.curbuf_contents() + local cur_contents = n.curbuf_contents() feed(undo) expect(expect_str) feed(redo) diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') local eq = t.eq local dedent = t.dedent -local exec = t.exec -local feed = t.feed -local clear = t.clear -local fn = t.fn -local command = t.command -local api = t.api -local Screen = require('test.functional.ui.screen') +local exec = n.exec +local feed = n.feed +local clear = n.clear +local fn = n.fn +local command = n.command +local api = n.api local cmdtest = function(cmd, prep, ret1) describe(':' .. cmd, function() diff --git a/test/functional/ex_cmds/arg_spec.lua b/test/functional/ex_cmds/arg_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local eq, command, fn = t.eq, t.command, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, command, fn = t.eq, n.command, n.fn local ok = t.ok local matches = t.matches -local clear = t.clear +local clear = n.clear describe(':argument', function() before_each(function() @@ -11,19 +13,19 @@ describe(':argument', function() it('does not restart :terminal buffer', function() command('terminal') - t.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) command('argadd') - t.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) local bufname_before = fn.bufname('%') local bufnr_before = fn.bufnr('%') matches('^term://', bufname_before) -- sanity command('argument 1') - t.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) local bufname_after = fn.bufname('%') local bufnr_after = fn.bufnr('%') - eq('[' .. bufname_before .. ']', t.eval('trim(execute("args"))')) + eq('[' .. bufname_before .. ']', n.eval('trim(execute("args"))')) ok(fn.line('$') > 1) eq(bufname_before, bufname_after) eq(bufnr_before, bufnr_after) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua @@ -1,13 +1,14 @@ -- Specs for :cd, :tcd, :lcd and getcwd() -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local call = t.call -local clear = t.clear -local command = t.command -local exc_exec = t.exc_exec -local pathsep = t.get_pathsep() +local call = n.call +local clear = n.clear +local command = n.command +local exc_exec = n.exc_exec +local pathsep = n.get_pathsep() local skip = t.skip local is_os = t.is_os local mkdir = t.mkdir @@ -289,14 +290,14 @@ describe('getcwd()', function() end) after_each(function() - t.rmdir(directories.global) + n.rmdir(directories.global) end) it('returns empty string if working directory does not exist', function() skip(is_os('win')) command('cd ' .. directories.global) command("call delete('../" .. directories.global .. "', 'd')") - eq('', t.eval('getcwd()')) + eq('', n.eval('getcwd()')) end) it("works with 'autochdir' after local directory was set (#9892)", function() diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local feed = t.feed +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') + +local clear = n.clear +local feed = n.feed local eq = t.eq -local expect = t.expect -local eval = t.eval -local fn = t.fn -local insert = t.insert +local expect = n.expect +local eval = n.eval +local fn = n.fn +local insert = n.insert local write_file = t.write_file -local exc_exec = t.exc_exec -local command = t.command -local Screen = require('test.functional.ui.screen') +local exc_exec = n.exc_exec +local command = n.command describe('mappings with <Cmd>', function() local screen diff --git a/test/functional/ex_cmds/debug_spec.lua b/test/functional/ex_cmds/debug_spec.lua @@ -1,7 +1,8 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed -local clear = t.clear + +local feed = n.feed +local clear = n.clear describe(':debug', function() local screen diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local clear, source = t.clear, t.source -local api = t.api -local insert = t.insert -local eq, next_msg = t.eq, t.next_msg -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local command = t.command -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear, source = n.clear, n.source +local api = n.api +local insert = n.insert +local eq, next_msg = t.eq, n.next_msg +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local command = n.command +local eval = n.eval describe('Vimscript dictionary notifications', function() local channel diff --git a/test/functional/ex_cmds/digraphs_spec.lua b/test/functional/ex_cmds/digraphs_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command -local feed = t.feed +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear = n.clear +local command = n.command +local feed = n.feed + describe(':digraphs', function() local screen before_each(function() diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() -local command = t.command +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, feed_command = t.clear, t.feed, t.feed_command -local exec = t.exec + +local command = n.command +local clear, feed, feed_command = n.clear, n.feed, n.feed_command +local exec = n.exec describe(':drop', function() local screen diff --git a/test/functional/ex_cmds/echo_spec.lua b/test/functional/ex_cmds/echo_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local NIL = vim.NIL -local eval = t.eval -local clear = t.clear -local api = t.api -local fn = t.fn -local source = t.source +local eval = n.eval +local clear = n.clear +local api = n.api +local fn = n.fn +local source = n.source local dedent = t.dedent -local command = t.command -local exc_exec = t.exc_exec -local exec_capture = t.exec_capture +local command = n.command +local exc_exec = n.exc_exec +local exec_capture = n.exec_capture local matches = t.matches describe(':echo :echon :echomsg :echoerr', function() @@ -349,8 +350,8 @@ describe(':echo :echon :echomsg :echoerr', function() end) describe('used to represent special values', function() - local function chr(n) - return ('%c'):format(n) + local function chr(_n) + return ('%c'):format(_n) end local function ctrl(c) return ('%c'):format(c:upper():byte() - 0x40) diff --git a/test/functional/ex_cmds/edit_spec.lua b/test/functional/ex_cmds/edit_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local eq, command, fn = t.eq, t.command, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, command, fn = t.eq, n.command, n.fn local ok = t.ok local matches = t.matches -local clear = t.clear -local feed = t.feed +local clear = n.clear +local feed = n.feed describe(':edit', function() before_each(function() diff --git a/test/functional/ex_cmds/encoding_spec.lua b/test/functional/ex_cmds/encoding_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, feed_command, feed = t.clear, t.feed_command, t.feed -local eq, neq, eval = t.eq, t.neq, t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, feed = n.clear, n.feed_command, n.feed +local eq, neq, eval = t.eq, t.neq, n.eval describe('&encoding', function() before_each(function() diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command local eq = t.eq -local clear = t.clear -local fn = t.fn +local clear = n.clear +local fn = n.fn local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive describe('Ex cmds', function() before_each(function() diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local fn = t.fn -local rmdir = t.rmdir +local fn = n.fn +local rmdir = n.rmdir local mkdir = t.mkdir describe(':file', function() diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local clear, feed_command, feed, ok, eval = t.clear, t.feed_command, t.feed, t.ok, t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, feed, ok, eval = n.clear, n.feed_command, n.feed, t.ok, n.eval describe(':grep', function() before_each(clear) diff --git a/test/functional/ex_cmds/help_spec.lua b/test/functional/ex_cmds/help_spec.lua @@ -1,19 +1,20 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local fn = t.fn -local api = t.api +local fn = n.fn +local api = n.api local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local write_file = t.write_file describe(':help', function() before_each(clear) it('window closed makes cursor return to a valid win/buf #9773', function() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() command('help help') eq(1001, fn.win_getid()) command('quit') diff --git a/test/functional/ex_cmds/highlight_spec.lua b/test/functional/ex_cmds/highlight_spec.lua @@ -1,11 +1,13 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local eq, command = t.eq, t.command -local clear = t.clear -local eval, exc_exec = t.eval, t.exc_exec -local exec = t.exec -local fn = t.fn -local api = t.api + +local eq, command = t.eq, n.command +local clear = n.clear +local eval, exc_exec = n.eval, n.exc_exec +local exec = n.exec +local fn = n.fn +local api = n.api describe(':highlight', function() local screen diff --git a/test/functional/ex_cmds/ls_spec.lua b/test/functional/ex_cmds/ls_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed -local api = t.api -local testprg = t.testprg +local eval = n.eval +local feed = n.feed +local api = n.api +local testprg = n.testprg local retry = t.retry describe(':ls', function() diff --git a/test/functional/ex_cmds/make_spec.lua b/test/functional/ex_cmds/make_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local eval = t.eval -local has_powershell = t.has_powershell +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eval = n.eval +local has_powershell = n.has_powershell local matches = t.matches -local api = t.api -local testprg = t.testprg +local api = n.api +local testprg = n.testprg describe(':make', function() clear() @@ -18,7 +20,7 @@ describe(':make', function() return end before_each(function() - t.set_shell_powershell() + n.set_shell_powershell() end) it('captures stderr & non zero exit code #14349', function() diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local exec = t.exec -local exec_capture = t.exec_capture -local feed = t.feed -local api = t.api -local clear = t.clear -local command = t.command -local expect = t.expect -local insert = t.insert -local eval = t.eval +local exec = n.exec +local exec_capture = n.exec_capture +local feed = n.feed +local api = n.api +local clear = n.clear +local command = n.command +local expect = n.expect +local insert = n.insert +local eval = n.eval describe(':*map', function() before_each(clear) diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear, command = t.clear, t.command -local expect, feed = t.expect, t.feed -local eq, eval = t.eq, t.eval -local fn = t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command = n.clear, n.command +local expect, feed = n.expect, n.feed +local eq, eval = t.eq, n.eval +local fn = n.fn describe(':emenu', function() before_each(function() diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local get_pathsep = t.get_pathsep +local clear = n.clear +local command = n.command +local get_pathsep = n.get_pathsep local eq = t.eq local neq = t.neq -local fn = t.fn +local fn = n.fn local matches = t.matches local pesc = vim.pesc -local rmdir = t.rmdir +local rmdir = n.rmdir local sleep = vim.uv.sleep -local api = t.api +local api = n.api local skip = t.skip local is_os = t.is_os local mkdir = t.mkdir diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command -local get_pathsep = t.get_pathsep +local clear = n.clear +local command = n.command +local get_pathsep = n.get_pathsep local eq = t.eq -local fn = t.fn -local rmdir = t.rmdir +local fn = n.fn +local rmdir = n.rmdir local mkdir = t.mkdir local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec' diff --git a/test/functional/ex_cmds/normal_spec.lua b/test/functional/ex_cmds/normal_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command -local fn = t.fn -local feed = t.feed -local expect = t.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local fn = n.fn +local feed = n.feed +local expect = n.expect local eq = t.eq -local eval = t.eval +local eval = n.eval before_each(clear) diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua @@ -1,13 +1,14 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command -local expect_exit = t.expect_exit -local api, eq, feed_command = t.api, t.eq, t.feed_command -local feed, poke_eventloop = t.feed, t.poke_eventloop +local clear = n.clear +local command = n.command +local expect_exit = n.expect_exit +local api, eq, feed_command = n.api, t.eq, n.feed_command +local feed, poke_eventloop = n.feed, n.poke_eventloop local ok = t.ok -local eval = t.eval +local eval = n.eval local shada_file = 'Xtest.shada' @@ -109,7 +110,7 @@ describe(':browse oldfiles', function() -- Ensure v:oldfiles isn't busted. Since things happen so fast, -- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood). -- Let's verify the contents and the length of v:oldfiles before moving on. - oldfiles = t.api.nvim_get_vvar('oldfiles') + oldfiles = n.api.nvim_get_vvar('oldfiles') eq(2, #oldfiles) ok(filename == oldfiles[1] or filename == oldfiles[2]) ok(filename2 == oldfiles[1] or filename2 == oldfiles[2]) diff --git a/test/functional/ex_cmds/print_commands_spec.lua b/test/functional/ex_cmds/print_commands_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local clear, eq, command, fn = t.clear, t.eq, t.command, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, command, fn = n.clear, t.eq, n.command, n.fn describe(':z^', function() before_each(clear) diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua @@ -1,12 +1,13 @@ -require('os') +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local uv = vim.uv +require('os') -local t = require('test.functional.testutil')() -local eval = t.eval -local command = t.command +local eval = n.eval +local command = n.command local eq, neq = t.eq, t.neq local tempfile = t.tmpname() -local source = t.source +local source = n.source local matches = t.matches local read_file = t.read_file @@ -25,10 +26,10 @@ local function assert_file_exists_not(filepath) end describe(':profile', function() - before_each(t.clear) + before_each(n.clear) after_each(function() - t.expect_exit(command, 'qall!') + n.expect_exit(command, 'qall!') if uv.fs_stat(tempfile).uid ~= nil then os.remove(tempfile) end diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed +local feed = n.feed local eq = t.eq -local clear = t.clear -local fn = t.fn -local command = t.command -local exc_exec = t.exc_exec +local clear = n.clear +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec local write_file = t.write_file -local api = t.api -local source = t.source +local api = n.api +local source = n.source local file_base = 'Xtest-functional-ex_cmds-quickfix_commands' diff --git a/test/functional/ex_cmds/quit_spec.lua b/test/functional/ex_cmds/quit_spec.lua @@ -1,5 +1,6 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local n = require('test.functional.testnvim')() + +local clear = n.clear describe(':qa', function() before_each(function() diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local neq = t.neq -local command = t.command -local exec_capture = t.exec_capture +local command = n.command +local exec_capture = n.exec_capture local write_file = t.write_file -local api = t.api -local clear = t.clear +local api = n.api +local clear = n.clear local dedent = t.dedent -local exc_exec = t.exc_exec -local missing_provider = t.missing_provider +local exc_exec = n.exc_exec +local missing_provider = n.missing_provider local tmpfile = 'X_ex_cmds_script' diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eq, assert_alive = t.clear, t.eq, t.assert_alive -local command = t.command -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, assert_alive = n.clear, t.eq, n.assert_alive +local command = n.command +local api = n.api describe('sign', function() before_each(clear) diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua @@ -1,22 +1,24 @@ -local t = require('test.functional.testutil')() -local command = t.command -local insert = t.insert +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local insert = n.insert local eq = t.eq -local clear = t.clear -local api = t.api -local feed = t.feed -local feed_command = t.feed_command +local clear = n.clear +local api = n.api +local feed = n.feed +local feed_command = n.feed_command local write_file = t.write_file local tmpname = t.tmpname -local exec = t.exec -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local eval = t.eval -local exec_capture = t.exec_capture +local exec = n.exec +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local eval = n.eval +local exec_capture = n.exec_capture local neq = t.neq local matches = t.matches local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local is_os = t.is_os describe(':source', function() diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -1,27 +1,29 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() + local uv = vim.uv -local eq, eval, expect, exec = t.eq, t.eval, t.expect, t.exec -local assert_alive = t.assert_alive -local clear = t.clear -local command = t.command -local feed = t.feed -local fn = t.fn -local nvim_prog = t.nvim_prog +local eq, eval, expect, exec = t.eq, n.eval, n.expect, n.exec +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command +local feed = n.feed +local fn = n.fn +local nvim_prog = n.nvim_prog local ok = t.ok -local rmdir = t.rmdir -local new_argv = t.new_argv -local new_pipename = t.new_pipename +local rmdir = n.rmdir +local new_argv = n.new_argv +local new_pipename = n.new_pipename local pesc = vim.pesc -local os_kill = t.os_kill -local set_session = t.set_session -local spawn = t.spawn -local async_meths = t.async_meths -local expect_msg_seq = t.expect_msg_seq +local os_kill = n.os_kill +local set_session = n.set_session +local spawn = n.spawn +local async_meths = n.async_meths +local expect_msg_seq = n.expect_msg_seq local pcall_err = t.pcall_err local mkdir = t.mkdir -local poke_eventloop = t.poke_eventloop -local api = t.api +local poke_eventloop = n.poke_eventloop +local api = n.api local retry = t.retry local write_file = t.write_file @@ -118,7 +120,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) screen0:expect({ any = pesc('[No Name]') }) -- Wait for the child process to start. - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) set_session(child_session) local swappath1 = setup_swapname() set_session(nvim0) diff --git a/test/functional/ex_cmds/syntax_spec.lua b/test/functional/ex_cmds/syntax_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local exc_exec = t.exc_exec +local clear = n.clear +local exc_exec = n.exc_exec describe(':syntax', function() before_each(clear) diff --git a/test/functional/ex_cmds/trust_spec.lua b/test/functional/ex_cmds/trust_spec.lua @@ -1,23 +1,24 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local command = t.command -local exec_capture = t.exec_capture +local clear = n.clear +local command = n.command +local exec_capture = n.exec_capture local matches = t.matches -local pathsep = t.get_pathsep() +local pathsep = n.get_pathsep() local is_os = t.is_os -local fn = t.fn +local fn = n.fn describe(':trust', function() local xstate = 'Xstate' setup(function() - t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) + n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) end) teardown(function() - t.rmdir(xstate) + n.rmdir(xstate) end) before_each(function() diff --git a/test/functional/ex_cmds/undojoin_spec.lua b/test/functional/ex_cmds/undojoin_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local insert = t.insert -local feed = t.feed -local expect = t.expect -local feed_command = t.feed_command -local exc_exec = t.exc_exec +local clear = n.clear +local insert = n.insert +local feed = n.feed +local expect = n.expect +local feed_command = n.feed_command +local exc_exec = n.exc_exec describe(':undojoin command', function() before_each(function() diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec = t.exec -local exec_capture = t.exec_capture +local exec = n.exec +local exec_capture = n.exec_capture local write_file = t.write_file -local call_viml_function = t.api.nvim_call_function +local call_viml_function = n.api.nvim_call_function local function last_set_tests(cmd) local script_location, script_file @@ -15,7 +16,7 @@ local function last_set_tests(cmd) script_file = 'test_verbose.lua' local current_dir = call_viml_function('getcwd', {}) current_dir = call_viml_function('fnamemodify', { current_dir, ':~' }) - script_location = table.concat { current_dir, t.get_pathsep(), script_file } + script_location = table.concat { current_dir, n.get_pathsep(), script_file } write_file( script_file, diff --git a/test/functional/ex_cmds/wincmd_spec.lua b/test/functional/ex_cmds/wincmd_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local fn = t.fn -local command = t.command +local fn = n.fn +local command = n.command it(':wincmd accepts a count', function() clear() diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq, eval, clear, write_file, source, insert = - t.eq, t.eval, t.clear, t.write_file, t.source, t.insert + t.eq, n.eval, n.clear, t.write_file, n.source, n.insert local pcall_err = t.pcall_err -local command = t.command -local feed_command = t.feed_command -local fn = t.fn -local api = t.api +local command = n.command +local feed_command = n.feed_command +local fn = n.fn +local api = n.api local skip = t.skip local is_os = t.is_os local is_ci = t.is_ci diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua @@ -1,8 +1,13 @@ -- Specs for :wundo and underlying functions -local t = require('test.functional.testutil')() -local command, clear, eval, spawn, nvim_prog, set_session = - t.command, t.clear, t.eval, t.spawn, t.nvim_prog, t.set_session +local n = require('test.functional.testnvim')() + +local command = n.command +local clear = n.clear +local eval = n.eval +local spawn = n.spawn +local nvim_prog = n.nvim_prog +local set_session = n.set_session describe(':wundo', function() before_each(clear) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command, eq, neq, write_file = t.command, t.eq, t.neq, t.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, eq, neq, write_file = n.command, t.eq, t.neq, t.write_file local read_file = t.read_file local is_os = t.is_os diff --git a/test/functional/example_spec.lua b/test/functional/example_spec.lua @@ -1,12 +1,13 @@ -- To run this test: -- TEST_FILE=test/functional/example_spec.lua make functionaltest -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local feed = t.feed +local feed = n.feed describe('example', function() local screen diff --git a/test/functional/legacy/002_filename_recognition_spec.lua b/test/functional/legacy/002_filename_recognition_spec.lua @@ -1,9 +1,10 @@ -- Test if URLs are recognized as filenames by commands such as "gf". Here -- we'll use `expand("<cfile>")` since "gf" would need to open the file. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('filename recognition', function() setup(clear) diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua @@ -1,9 +1,10 @@ -- Test for autocommand that changes current buffer on BufEnter event. -- Check if modelines are interpreted for the correct buffer. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('BufEnter with modelines', function() setup(clear) diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua @@ -1,10 +1,11 @@ -- Test for autocommand that deletes the current buffer on BufLeave event. -- Also test deleting the last buffer, should give a new, empty buffer. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local command, expect = t.command, t.expect -local poke_eventloop = t.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('test5', function() setup(clear) diff --git a/test/functional/legacy/007_ball_buffer_list_spec.lua b/test/functional/legacy/007_ball_buffer_list_spec.lua @@ -1,8 +1,9 @@ -- Test for autocommand that changes the buffer list, when doing ":ball". -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe(':ball', function() setup(clear) diff --git a/test/functional/legacy/008_autocommands_spec.lua b/test/functional/legacy/008_autocommands_spec.lua @@ -1,12 +1,14 @@ -- Test for BufWritePre autocommand that deletes or unloads the buffer. -- Test for BufUnload autocommand that unloads all other buffers. -local t = require('test.functional.testutil')() -local source = t.source -local clear, command, expect, eq, eval = t.clear, t.command, t.expect, t.eq, t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, command, expect, eq, eval = n.clear, n.command, n.expect, t.eq, n.eval local write_file, dedent = t.write_file, t.dedent local read_file = t.read_file -local expect_exit = t.expect_exit +local expect_exit = n.expect_exit describe('autocommands that delete and unload buffers:', function() local test_file = 'Xtest-008_autocommands.out' diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua @@ -12,10 +12,12 @@ -- Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.gz" -- being modified outside of Vim (noticed on Solaris). -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local clear, feed_command, expect, eq, neq, dedent, write_file, feed = - t.clear, t.feed_command, t.expect, t.eq, t.neq, t.dedent, t.write_file, t.feed -local command = t.command + n.clear, n.feed_command, n.expect, t.eq, t.neq, t.dedent, t.write_file, n.feed +local command = n.command local read_file = t.read_file local is_os = t.is_os diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua @@ -3,18 +3,19 @@ -- - "./dir", in directory relative to file -- - "dir", in directory relative to current dir -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local neq = t.neq -local poke_eventloop = t.poke_eventloop -local fn = t.fn -local api = t.api -local clear = t.clear -local insert = t.insert -local command = t.command +local poke_eventloop = n.poke_eventloop +local fn = n.fn +local api = n.api +local clear = n.clear +local insert = n.insert +local command = n.command local write_file = t.write_file -local expect_exit = t.expect_exit +local expect_exit = n.expect_exit local mkdir = t.mkdir local function ls_dir_sorted(dirname) @@ -44,8 +45,8 @@ describe("'directory' option", function() end) teardown(function() expect_exit(command, 'qall!') - t.rmdir('Xtest.je') - t.rmdir('Xtest2') + n.rmdir('Xtest.je') + n.rmdir('Xtest2') os.remove('Xtest1') end) diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua @@ -2,9 +2,10 @@ -- Also test formatting a paragraph. -- Also test undo after ":%s" and formatting. -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('alignment', function() setup(clear) diff --git a/test/functional/legacy/018_unset_smart_indenting_spec.lua b/test/functional/legacy/018_unset_smart_indenting_spec.lua @@ -1,12 +1,12 @@ -- Tests for not doing smart indenting when it isn't set. -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local feed = t.feed -local clear = t.clear -local insert = t.insert -local expect = t.expect -local feed_command = t.feed_command +local feed = n.feed +local clear = n.clear +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command describe('unset smart indenting', function() before_each(clear) diff --git a/test/functional/legacy/019_smarttab_expandtab_spec.lua b/test/functional/legacy/019_smarttab_expandtab_spec.lua @@ -1,9 +1,10 @@ -- Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set. -- Also test that dv_ works correctly -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and "dv_"]], function() setup(clear) diff --git a/test/functional/legacy/020_blockwise_visual_spec.lua b/test/functional/legacy/020_blockwise_visual_spec.lua @@ -2,9 +2,10 @@ -- First test for undo working properly when executing commands from a register. -- Also test this in an empty buffer. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('blockwise visual', function() setup(clear) diff --git a/test/functional/legacy/021_control_wi_spec.lua b/test/functional/legacy/021_control_wi_spec.lua @@ -1,8 +1,9 @@ -- Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('CTRL-W CTRL-I', function() setup(clear) diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua @@ -1,9 +1,10 @@ -- Tests for complicated + argument to :edit command -local t = require('test.functional.testutil')() -local clear, insert = t.clear, t.insert -local command, expect = t.command, t.expect -local poke_eventloop = t.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, insert = n.clear, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe(':edit', function() setup(clear) diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua @@ -1,9 +1,11 @@ -- Test for jumping to a tag with 'hidden' set, with symbolic link in path of tag. -- This only works for Unix, because of the symbolic link. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('jump to a tag with hidden set', function() setup(clear) diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua @@ -1,11 +1,11 @@ -- Test for :execute, :while and :if -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local expect = t.expect -local source = t.source -local command = t.command +local clear = n.clear +local expect = n.expect +local source = n.source +local command = n.command describe(':execute, :while and :if', function() setup(clear) diff --git a/test/functional/legacy/028_source_ctrl_v_spec.lua b/test/functional/legacy/028_source_ctrl_v_spec.lua @@ -1,8 +1,9 @@ -- Test for sourcing a file with CTRL-V's at the end of the line -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('CTRL-V at the end of the line', function() setup(clear) diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua @@ -1,12 +1,12 @@ -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local feed = t.feed -local clear = t.clear -local insert = t.insert -local expect = t.expect -local feed_command = t.feed_command +local feed = n.feed +local clear = n.clear +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command describe('joining lines', function() before_each(clear) diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua @@ -1,9 +1,11 @@ -- Test for a lot of variations of the 'fileformats' option -local t = require('test.functional.testutil')() -local feed, clear, command = t.feed, t.clear, t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local feed, clear, command = n.feed, n.clear, n.command local eq, write_file = t.eq, t.write_file -local poke_eventloop = t.poke_eventloop +local poke_eventloop = n.poke_eventloop describe('fileformats option', function() setup(function() @@ -254,7 +256,7 @@ describe('fileformats option', function() command('set nobinary ff&') -- Assert buffer contents. This has to be done manually as - -- t.expect() calls t.dedent() which messes up the white space + -- n.expect() calls t.dedent() which messes up the white space -- and carriage returns. eq( 'unix\n'.. @@ -387,6 +389,6 @@ describe('fileformats option', function() '10\n'.. 'unix\n'.. 'unix', - t.curbuf_contents()) + n.curbuf_contents()) end) end) diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua @@ -9,15 +9,15 @@ -- :buf -- :edit -local t = require('test.functional.testutil')() - -local feed = t.feed -local clear = t.clear -local source = t.source -local insert = t.insert -local expect = t.expect -local feed_command = t.feed_command -local expect_exit = t.expect_exit +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear = n.clear +local source = n.source +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command +local expect_exit = n.expect_exit describe('Commands that close windows and/or buffers', function() local function cleanup() diff --git a/test/functional/legacy/033_lisp_indent_spec.lua b/test/functional/legacy/033_lisp_indent_spec.lua @@ -1,10 +1,11 @@ -- Test for 'lisp' -- If the lisp feature is not enabled, this will fail! -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local command, expect = t.command, t.expect -local poke_eventloop = t.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('lisp indent', function() setup(clear) diff --git a/test/functional/legacy/034_user_function_spec.lua b/test/functional/legacy/034_user_function_spec.lua @@ -3,9 +3,10 @@ -- Also test that a builtin function cannot be replaced. -- Also test for regression when calling arbitrary expression. -local t = require('test.functional.testutil')() -local feed, insert, source = t.feed, t.insert, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe( 'user functions, expr-mappings, overwrite protected builtin functions and regression on calling expressions', diff --git a/test/functional/legacy/035_increment_and_decrement_spec.lua b/test/functional/legacy/035_increment_and_decrement_spec.lua @@ -1,9 +1,10 @@ -- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal, -- and octal numbers. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('increment and decrement commands', function() setup(clear) diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua @@ -1,8 +1,10 @@ -- Test character classes in regexp using regexpengine 0, 1, 2. -local t = require('test.functional.testutil')() -local clear, command, expect = t.clear, t.command, t.expect -local source, write_file = t.source, t.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect +local source, write_file = n.source, t.write_file local function sixlines(text) local result = '' @@ -15,7 +17,7 @@ end local function diff(text, nodedent) local fname = t.tmpname() command('w! ' .. fname) - t.poke_eventloop() + n.poke_eventloop() local data = io.open(fname):read('*all') if nodedent then t.eq(text, data) diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua @@ -1,8 +1,9 @@ -- Test Virtual replace mode. -local t = require('test.functional.testutil')() -local feed = t.feed -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('Virtual replace mode', function() setup(clear) diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua @@ -1,11 +1,13 @@ -- Test Visual block mode commands -- And test "U" in Visual mode, also on German sharp S. -local t = require('test.functional.testutil')() -local nvim, eq = t.api, t.eq -local insert, feed = t.insert, t.feed -local clear, expect = t.clear, t.expect -local feed_command = t.feed_command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api, eq = n.api, t.eq +local insert, feed = n.insert, n.feed +local clear, expect = n.clear, n.expect +local feed_command = n.feed_command describe('Visual block mode', function() before_each(function() @@ -204,7 +206,7 @@ describe('Visual block mode', function() feed('G2l') feed('2k<C-v>$gj<ESC>') feed_command([[let cpos=getpos("'>")]]) - local cpos = nvim.nvim_get_var('cpos') + local cpos = api.nvim_get_var('cpos') local expected = { col = 4, off = 0, diff --git a/test/functional/legacy/043_magic_settings_spec.lua b/test/functional/legacy/043_magic_settings_spec.lua @@ -1,8 +1,9 @@ -- Tests for regexp with various magic settings. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('regexp with magic settings', function() setup(clear) diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -3,9 +3,10 @@ -- -- This test contains both "test44" and "test99" from the old test suite. -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- Runs the test protocol with the given 'regexpengine' setting. In the old test -- suite the test protocol was duplicated in test44 and test99, the only diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for multi-line regexps with ":s" -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local expect = t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect = n.expect describe('multi-line regexp', function() setup(clear) diff --git a/test/functional/legacy/054_buffer_local_autocommands_spec.lua b/test/functional/legacy/054_buffer_local_autocommands_spec.lua @@ -1,10 +1,10 @@ -- Some tests for buffer-local autocommands -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local expect = t.expect -local command = t.command +local clear = n.clear +local expect = n.expect +local command = n.command local fname = 'Xtest-functional-legacy-054' diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -1,8 +1,9 @@ -- Tests for List and Dictionary types. -local t = require('test.functional.testutil')() -local feed, source = t.feed, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('list and dictionary types', function() before_each(clear) diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for script-local function. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local expect = t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect = n.expect describe('source function', function() setup(clear) diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua @@ -1,10 +1,11 @@ -- Tests for :sort command. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local insert, command, clear, expect, eq, poke_eventloop = - t.insert, t.command, t.clear, t.expect, t.eq, t.poke_eventloop -local exc_exec = t.exc_exec + n.insert, n.command, n.clear, n.expect, t.eq, n.poke_eventloop +local exc_exec = n.exc_exec describe(':sort', function() local text = [[ diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua @@ -1,8 +1,10 @@ -- Tests for the exists() and has() functions. -local t = require('test.functional.testutil')() -local source = t.source -local clear, expect = t.clear, t.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, expect = n.clear, n.expect local write_file = t.write_file describe('exists() and has() functions', function() diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,14 +1,15 @@ -- Tests for undo tree and :earlier and :later. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local feed_command = t.feed_command +local feed_command = n.feed_command local write_file = t.write_file -local command = t.command -local source = t.source -local expect = t.expect -local clear = t.clear -local feed = t.feed -local eval = t.eval +local command = n.command +local source = n.source +local expect = n.expect +local clear = n.clear +local feed = n.feed +local eval = n.eval local eq = t.eq local function expect_empty_buffer() diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -1,10 +1,10 @@ -- Tests for adjusting window and contents -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command = t.clear, t.command -local insert = t.insert +local clear, command = n.clear, n.command +local insert = n.insert describe('063: Test for ":match", "matchadd()" and related functions', function() setup(clear) diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua @@ -1,8 +1,9 @@ -- Test for floating point and logical operators. -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('floating point and logical operators', function() setup(clear) diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for visual block shift and tab characters. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('visual block shift and tab characters', function() setup(clear) diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua @@ -1,9 +1,10 @@ -- Test that groups and patterns are tested correctly when calling exists() for -- autocommands. -local t = require('test.functional.testutil')() -local clear = t.clear -local command, expect = t.command, t.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('augroup when calling exists()', function() setup(clear) diff --git a/test/functional/legacy/068_text_formatting_spec.lua b/test/functional/legacy/068_text_formatting_spec.lua @@ -1,10 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local feed = t.feed -local clear = t.clear -local insert = t.insert -local feed_command = t.feed_command -local expect = t.expect +local feed = n.feed +local clear = n.clear +local insert = n.insert +local feed_command = n.feed_command +local expect = n.expect describe('text formatting', function() setup(clear) diff --git a/test/functional/legacy/069_multibyte_formatting_spec.lua b/test/functional/legacy/069_multibyte_formatting_spec.lua @@ -3,9 +3,11 @@ -- And test "ra" on multibyte characters. -- Also test byteidx() and byteidxcomp() -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local feed, insert, eq, eval, clear, feed_command, expect = - t.feed, t.insert, t.eq, t.eval, t.clear, t.feed_command, t.expect + n.feed, n.insert, t.eq, n.eval, n.clear, n.feed_command, n.expect describe('multibyte text', function() before_each(clear) diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua @@ -2,9 +2,10 @@ -- Since this script is sourced we need to explicitly break changes up in -- undo-able pieces. Do that by setting 'undolevels'. -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('72', function() setup(clear) diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -1,8 +1,10 @@ -- Tests for storing global variables in the .shada file -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local clear, command, eq, neq, eval, poke_eventloop = - t.clear, t.command, t.eq, t.neq, t.eval, t.poke_eventloop + n.clear, n.command, t.eq, t.neq, n.eval, n.poke_eventloop describe('storing global variables in ShaDa files', function() local tempname = 'Xtest-functional-legacy-074' diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua @@ -3,8 +3,9 @@ -- restored. We need about 10000 lines of 100 characters to get two levels of -- pointer blocks. -local t = require('test.functional.testutil')() -local clear, expect, source = t.clear, t.expect, t.source +local n = require('test.functional.testnvim')() + +local clear, expect, source = n.clear, n.expect, n.source describe('78', function() setup(clear) diff --git a/test/functional/legacy/081_coptions_movement_spec.lua b/test/functional/legacy/081_coptions_movement_spec.lua @@ -1,8 +1,9 @@ -- Test for t movement command and 'cpo-;' setting -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('coptions', function() setup(clear) diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua @@ -1,9 +1,10 @@ -- Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c) -- Also test "g~ap". -local t = require('test.functional.testutil')() -local feed, source = t.feed, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('case-insensitive string comparison in UTF-8', function() setup(clear) diff --git a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua @@ -1,12 +1,14 @@ -- Tests for tag search with !_TAG_FILE_ENCODING. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local insert, source, clear, expect, write_file = - t.insert, t.source, t.clear, t.expect, t.write_file + n.insert, n.source, n.clear, n.expect, t.write_file local function has_iconv() clear() -- ensures session - return 1 == t.eval('has("iconv")') + return 1 == n.eval('has("iconv")') end describe('tag search with !_TAG_FILE_ENCODING', function() diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua @@ -1,8 +1,9 @@ -- Tests for sha256() function. -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('sha256()', function() setup(clear) diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua @@ -1,8 +1,9 @@ -- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar(). -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('context variables', function() setup(clear) diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua @@ -3,9 +3,10 @@ -- -- Same as legacy test 93 but using UTF-8 file encoding. -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('store cursor position in session file in UTF-8', function() setup(clear) diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -3,9 +3,10 @@ -- -- Same as legacy test 92 but using Latin-1 file encoding. -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('store cursor position in session file in Latin-1', function() setup(clear) diff --git a/test/functional/legacy/094_visual_mode_operators_spec.lua b/test/functional/legacy/094_visual_mode_operators_spec.lua @@ -4,9 +4,10 @@ -- followed by an operator and those executed via Operator-pending mode. Also -- part of the test are mappings, counts, and repetition with the . command. -local t = require('test.functional.testutil')() -local feed, insert, source = t.feed, t.insert, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- Vim script user functions needed for some of the test cases. local function source_user_functions() diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua @@ -3,9 +3,10 @@ -- A pattern that gives the expected result produces OK, so that we know it was -- actually tried. -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('regex with multi-byte', function() setup(clear) diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua @@ -6,9 +6,10 @@ -- C. make sure that the location list window is not reused instead of the window -- it belongs to. -local t = require('test.functional.testutil')() -local source = t.source -local clear, command, expect = t.clear, t.command, t.expect +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, command, expect = n.clear, n.command, n.expect describe('location list', function() local test_file = 'Xtest-096_location_list.out' diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua @@ -2,9 +2,11 @@ -- Test whether glob()/globpath() return correct results with certain escaped -- characters. -local t = require('test.functional.testutil')() -local clear = t.clear -local command, expect = t.command, t.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('glob() and globpath()', function() setup(clear) diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua @@ -1,8 +1,9 @@ -- Test for v:hlsearch -local t = require('test.functional.testutil')() -local clear, feed = t.clear, t.feed -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed = n.clear, n.feed +local feed_command, expect = n.feed_command, n.expect describe('v:hlsearch', function() setup(clear) diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua @@ -1,8 +1,9 @@ -- Test if fnameescape is correct for special chars like! -local t = require('test.functional.testutil')() -local clear = t.clear -local command, expect = t.command, t.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('fnameescape', function() setup(clear) diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua @@ -1,8 +1,9 @@ -- Test for visual mode not being reset causing E315 error. -local t = require('test.functional.testutil')() -local feed, source = t.feed, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, expect = n.clear, n.expect describe('E315 error', function() setup(clear) diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua @@ -1,8 +1,9 @@ -- Tests for errorformat. -local t = require('test.functional.testutil')() -local clear = t.clear -local command, expect = t.command, t.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('errorformat', function() setup(clear) diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -1,12 +1,12 @@ -- Tests for adjusting window and contents -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local poke_eventloop = t.poke_eventloop -local clear = t.clear -local insert = t.insert -local command = t.command +local poke_eventloop = n.poke_eventloop +local clear = n.clear +local insert = n.insert +local command = n.command describe('107', function() setup(clear) diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -1,9 +1,10 @@ -- Tests for backtrace debug commands. -local t = require('test.functional.testutil')() -local command = t.command -local feed, clear = t.feed, t.clear -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local command = n.command +local feed, clear = n.feed, n.clear +local feed_command, expect = n.feed_command, n.expect describe('108', function() before_each(clear) diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua @@ -1,10 +1,12 @@ -- Test argument list commands -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command, eq = t.clear, t.command, t.eq -local expect_exit = t.expect_exit -local feed = t.feed + +local clear, command, eq = n.clear, n.command, t.eq +local expect_exit = n.expect_exit +local feed = n.feed local pcall_err = t.pcall_err describe('argument list commands', function() diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua @@ -1,16 +1,18 @@ -local t = require('test.functional.testutil')() -local nvim, call = t.api, t.call -local clear, eq = t.clear, t.eq -local source, command = t.source, t.command -local exc_exec = t.exc_exec -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api, call = n.api, n.call +local clear, eq = n.clear, t.eq +local source, command = n.source, n.command +local exc_exec = n.exc_exec +local eval = n.eval local function expected_errors(errors) - eq(errors, nvim.nvim_get_vvar('errors')) + eq(errors, api.nvim_get_vvar('errors')) end local function expected_empty() - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end describe('assert function:', function() diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eq, matches = t.clear, t.eq, t.matches -local eval, command, call, api = t.eval, t.command, t.call, t.api -local source, exec_capture = t.source, t.exec_capture +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, matches = n.clear, t.eq, t.matches +local eval, command, call, api = n.eval, n.command, n.call, n.api +local source, exec_capture = n.source, n.exec_capture local mkdir = t.mkdir local function expected_empty() @@ -18,7 +20,7 @@ describe('autochdir behavior', function() end) after_each(function() - t.rmdir(dir) + n.rmdir(dir) end) -- Tests vim/vim#777 without test_autochdir(). diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() -local nvim = t.api -local clear, eq, neq, eval = t.clear, t.eq, t.neq, t.eval -local api = t.api -local curbuf = t.api.nvim_get_current_buf -local curwin = t.api.nvim_get_current_win -local exec_capture = t.exec_capture -local source, command = t.source, t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, neq, eval = n.clear, t.eq, t.neq, n.eval +local api = n.api +local curbuf = n.api.nvim_get_current_buf +local curwin = n.api.nvim_get_current_win +local exec_capture = n.exec_capture +local source, command = n.source, n.command local function declare_hook_function() source([[ @@ -39,7 +40,7 @@ local function init_var() end local function get_result() - local ret = nvim.nvim_get_var('ret') + local ret = api.nvim_get_var('ret') init_var() return ret end @@ -697,24 +698,24 @@ describe('au OptionSet', function() it('should trigger if a boolean option be set globally', function() set_hook('autochdir') - nvim.nvim_set_option_value('autochdir', true, { scope = 'global' }) - eq(true, nvim.nvim_get_option_value('autochdir', { scope = 'global' })) + api.nvim_set_option_value('autochdir', true, { scope = 'global' }) + eq(true, api.nvim_get_option_value('autochdir', { scope = 'global' })) expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' }) end) it('should trigger if a number option be set globally', function() set_hook('cmdheight') - nvim.nvim_set_option_value('cmdheight', 5, { scope = 'global' }) - eq(5, nvim.nvim_get_option_value('cmdheight', { scope = 'global' })) + api.nvim_set_option_value('cmdheight', 5, { scope = 'global' }) + eq(5, api.nvim_get_option_value('cmdheight', { scope = 'global' })) expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' }) end) it('should trigger if a string option be set globally', function() set_hook('ambiwidth') - nvim.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' }) - eq('double', nvim.nvim_get_option_value('ambiwidth', { scope = 'global' })) + api.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' }) + eq('double', api.nvim_get_option_value('ambiwidth', { scope = 'global' })) expected_combination({ 'ambiwidth', 'single', diff --git a/test/functional/legacy/autocmd_spec.lua b/test/functional/legacy/autocmd_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local write_file = t.write_file -local command = t.command -local feed = t.feed -local api = t.api +local command = n.command +local feed = n.feed +local api = n.api local eq = t.eq before_each(clear) diff --git a/test/functional/legacy/autoformat_join_spec.lua b/test/functional/legacy/autoformat_join_spec.lua @@ -1,9 +1,10 @@ -- Tests for setting the '[,'] marks when joining lines. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local command, expect = t.command, t.expect -local poke_eventloop = t.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('autoformat join', function() setup(clear) diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/changelist_spec.lua b/test/functional/legacy/changelist_spec.lua @@ -1,9 +1,10 @@ -- Test changelist position after splitting window -- Set 'undolevels' to make changelist for sourced file -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('changelist', function() setup(clear) diff --git a/test/functional/legacy/charsearch_spec.lua b/test/functional/legacy/charsearch_spec.lua @@ -1,8 +1,9 @@ -- Test for character searches -local t = require('test.functional.testutil')() -local feed, insert = t.feed, t.insert -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('charsearch', function() setup(clear) diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua @@ -1,13 +1,14 @@ -- Tests for :[count]close! and :[count]hide -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local poke_eventloop = t.poke_eventloop -local eval = t.eval -local feed = t.feed -local clear = t.clear -local command = t.command +local poke_eventloop = n.poke_eventloop +local eval = n.eval +local feed = n.feed +local clear = n.clear +local command = n.command describe('close_count', function() setup(clear) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local feed = t.feed -local feed_command = t.feed_command -local exec = t.exec -local api = t.api + +local clear = n.clear +local command = n.command +local feed = n.feed +local feed_command = n.feed_command +local exec = n.exec +local api = n.api local pesc = vim.pesc describe('cmdline', function() diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua @@ -1,8 +1,9 @@ -- Test for user command counts -local t = require('test.functional.testutil')() -local clear, source, expect = t.clear, t.source, t.expect -local feed_command = t.feed_command +local n = require('test.functional.testnvim')() + +local clear, source, expect = n.clear, n.source, n.expect +local feed_command = n.feed_command -- luacheck: ignore 613 (Trailing whitespace in a string) describe('command_count', function() diff --git a/test/functional/legacy/comparators_spec.lua b/test/functional/legacy/comparators_spec.lua @@ -1,8 +1,10 @@ -- " Test for expression comparators. -local t = require('test.functional.testutil')() -local clear, eq = t.clear, t.eq -local eval, command = t.eval, t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq = n.clear, t.eq +local eval, command = n.eval, n.command describe('comparators', function() before_each(clear) diff --git a/test/functional/legacy/conceal_spec.lua b/test/functional/legacy/conceal_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed -local api = t.api + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed +local api = n.api local expect_pos = function(row, col) - return t.eq({ row, col }, t.eval('[screenrow(), screencol()]')) + return t.eq({ row, col }, n.eval('[screenrow(), screencol()]')) end describe('Conceal', function() diff --git a/test/functional/legacy/cpoptions_spec.lua b/test/functional/legacy/cpoptions_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local feed = t.feed + +local clear = n.clear +local command = n.command +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/crash_spec.lua b/test/functional/legacy/crash_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local clear = t.clear -local command = t.command -local feed = t.feed +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/debugger_spec.lua b/test/functional/legacy/debugger_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local feed = t.feed + +local clear = n.clear +local command = n.command +local feed = n.feed local write_file = t.write_file before_each(clear) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, source = t.clear, t.source -local eq, eval, command = t.eq, t.eval, t.command -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, source = n.clear, n.source +local eq, eval, command = t.eq, n.eval, n.command +local exc_exec = n.exc_exec describe('Test for delete()', function() before_each(clear) diff --git a/test/functional/legacy/digraph_spec.lua b/test/functional/legacy/digraph_spec.lua @@ -1,7 +1,8 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed + +local clear = n.clear +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua @@ -1,10 +1,10 @@ -local t = require('test.functional.testutil')() - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local command = t.command + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local command = n.command describe('display', function() before_each(clear) diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local expect = t.expect -local feed = t.feed + +local clear = n.clear +local command = n.command +local expect = n.expect +local feed = n.feed local sleep = vim.uv.sleep before_each(clear) diff --git a/test/functional/legacy/erasebackword_spec.lua b/test/functional/legacy/erasebackword_spec.lua @@ -1,7 +1,8 @@ -- Test for CTRL-W in Insert mode -local t = require('test.functional.testutil')() -local clear, feed, expect = t.clear, t.feed, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, expect = n.clear, n.feed, n.expect describe('CTRL-W in Insert mode', function() setup(clear) diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua @@ -1,12 +1,14 @@ -- Test for various eval features. -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local feed, insert, source = t.feed, t.insert, t.source -local clear, command, expect = t.clear, t.command, t.expect -local eq, eval, write_file = t.eq, t.eval, t.write_file -local poke_eventloop = t.poke_eventloop -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local feed, insert, source = n.feed, n.insert, n.source +local clear, command, expect = n.clear, n.command, n.expect +local eq, eval, write_file = t.eq, n.eval, t.write_file +local poke_eventloop = n.poke_eventloop +local exc_exec = n.exc_exec local dedent = t.dedent describe('eval', function() diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed -local api = t.api -local poke_eventloop = t.poke_eventloop +local eval = n.eval +local feed = n.feed +local api = n.api +local poke_eventloop = n.poke_eventloop before_each(clear) diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local exec_lua = t.exec_lua -local expect_exit = t.expect_exit -local feed = t.feed -local fn = t.fn -local api = t.api + +local clear = n.clear +local command = n.command +local exec = n.exec +local exec_lua = n.exec_lua +local expect_exit = n.expect_exit +local feed = n.feed +local fn = n.fn +local api = n.api local read_file = t.read_file -local source = t.source +local source = n.source local eq = t.eq local write_file = t.write_file local is_os = t.is_os diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua @@ -1,8 +1,9 @@ -- Tests for 'fixeol' -local t = require('test.functional.testutil')() -local feed = t.feed -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('fixeol', function() local function rmtestfiles() diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua @@ -1,11 +1,13 @@ -- Test filename modifiers. -local t = require('test.functional.testutil')() -local clear, source = t.clear, t.source -local call, eq, nvim = t.call, t.eq, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, source = n.clear, n.source +local call, eq, api = n.call, t.eq, n.api local function expected_empty() - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end describe('filename modifiers', function() diff --git a/test/functional/legacy/fold_spec.lua b/test/functional/legacy/fold_spec.lua @@ -1,16 +1,17 @@ -- Tests for folding. + +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local feed, insert, feed_command, expect_any = t.feed, t.insert, t.feed_command, t.expect_any -local command = t.command -local exec = t.exec +local feed, insert, feed_command, expect_any = n.feed, n.insert, n.feed_command, n.expect_any +local command = n.command +local exec = n.exec describe('folding', function() local screen before_each(function() - t.clear() + n.clear() screen = Screen.new(45, 8) screen:attach() @@ -60,7 +61,7 @@ describe('folding', function() feed('kYpj') feed_command('call append("$", foldlevel("."))') - t.poke_eventloop() + n.poke_eventloop() screen:expect([[ dd {{{ | ee {{{ }}} | @@ -86,7 +87,7 @@ describe('folding', function() feed_command('call append("$", foldlevel(2))') feed('zR') - t.poke_eventloop() + n.poke_eventloop() screen:expect([[ aa | bb | diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local neq = t.neq -local eval = t.eval -local clear = t.clear -local source = t.source -local exc_exec = t.exc_exec +local eval = n.eval +local clear = n.clear +local source = n.source +local exc_exec = n.exc_exec describe('sort', function() before_each(clear) diff --git a/test/functional/legacy/getcwd_spec.lua b/test/functional/legacy/getcwd_spec.lua @@ -1,14 +1,16 @@ -- Tests for getcwd(), haslocaldir(), and :lcd -local t = require('test.functional.testutil')() -local eq, eval, source = t.eq, t.eval, t.source -local call, clear, command = t.call, t.clear, t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, eval, source = t.eq, n.eval, n.source +local call, clear, command = n.call, n.clear, n.command describe('getcwd', function() before_each(clear) after_each(function() - t.rmdir('Xtopdir') + n.rmdir('Xtopdir') end) it('is working', function() diff --git a/test/functional/legacy/gf_spec.lua b/test/functional/legacy/gf_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local eq, eval = t.eq, t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eq, eval = t.eq, n.eval describe('glob2regpat()', function() before_each(clear) diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local poke_eventloop = t.poke_eventloop + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local poke_eventloop = n.poke_eventloop before_each(clear) diff --git a/test/functional/legacy/highlight_spec.lua b/test/functional/legacy/highlight_spec.lua @@ -1,12 +1,14 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local clear, feed = t.clear, t.feed -local expect = t.expect + +local clear, feed = n.clear, n.feed +local expect = n.expect local eq = t.eq -local poke_eventloop = t.poke_eventloop -local exc_exec = t.exc_exec -local feed_command = t.feed_command -local exec = t.exec +local poke_eventloop = n.poke_eventloop +local exc_exec = n.exc_exec +local feed_command = n.feed_command +local exec = n.exec before_each(clear) diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua @@ -1,9 +1,11 @@ -- Tests for using Ctrl-A/Ctrl-X on visual selections -local t = require('test.functional.testutil')() -local source, command = t.source, t.command -local call, clear = t.call, t.clear -local eq, nvim = t.eq, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source, command = n.source, n.command +local call, clear = n.call, n.clear +local eq, api = t.eq, n.api describe('Ctrl-A/Ctrl-X on visual selections', function() before_each(function() @@ -743,18 +745,18 @@ describe('Ctrl-A/Ctrl-X on visual selections', function() it('works on Test ' .. id, function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_visual_increment_' .. id) - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end it('does not drop leading zeroes', function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_normal_increment_01') - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) it('maintains correct column after CTRL-A', function() call('Test_normal_increment_02') - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/insertcount_spec.lua b/test/functional/legacy/insertcount_spec.lua @@ -1,8 +1,9 @@ -- Tests for repeating insert and replace. -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect = t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('insertcount', function() setup(clear) diff --git a/test/functional/legacy/join_spec.lua b/test/functional/legacy/join_spec.lua @@ -1,8 +1,10 @@ -- Test for joining lines -local t = require('test.functional.testutil')() -local clear, eq = t.clear, t.eq -local eval, command = t.eval, t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq = n.clear, t.eq +local eval, command = n.eval, n.command describe('joining lines', function() before_each(clear) diff --git a/test/functional/legacy/lispwords_spec.lua b/test/functional/legacy/lispwords_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local eval = t.eval -local command = t.command -local source = t.source +local eval = n.eval +local command = n.command +local source = n.source describe('lispwords', function() before_each(clear) diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua @@ -1,9 +1,10 @@ -- Tests for 'listchars' display with 'list' and :list. -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert, exec = t.feed, t.insert, t.exec -local clear, feed_command, expect = t.clear, t.feed_command, t.expect + +local feed, insert, exec = n.feed, n.insert, n.exec +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- luacheck: ignore 621 (Indentation) describe("'listchars'", function() diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua @@ -1,9 +1,10 @@ -- Test for linebreak and list option (non-utf8) -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert, source = t.feed, t.insert, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('listlbr', function() before_each(clear) diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua @@ -1,11 +1,12 @@ -- Test for linebreak and list option in utf-8 mode -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local source = t.source -local feed = t.feed -local exec = t.exec -local clear, expect = t.clear, t.expect + +local source = n.source +local feed = n.feed +local exec = n.exec +local clear, expect = n.clear, n.expect describe('linebreak', function() before_each(clear) diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua @@ -1,11 +1,13 @@ -- Test for mappings and abbreviations -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local expect, poke_eventloop = t.expect, t.poke_eventloop -local command, eq, eval, api = t.command, t.eq, t.eval, t.api -local exec = t.exec + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect, poke_eventloop = n.expect, n.poke_eventloop +local command, eq, eval, api = n.command, t.eq, n.eval, n.api +local exec = n.exec local sleep = vim.uv.sleep describe('mapping', function() diff --git a/test/functional/legacy/marks_spec.lua b/test/functional/legacy/marks_spec.lua @@ -1,6 +1,7 @@ -local t = require('test.functional.testutil')() -local feed, insert, source = t.feed, t.insert, t.source -local clear, feed_command, expect = t.clear, t.feed_command, t.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('marks', function() before_each(function() diff --git a/test/functional/legacy/match_spec.lua b/test/functional/legacy/match_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/matchparen_spec.lua b/test/functional/legacy/matchparen_spec.lua @@ -1,9 +1,9 @@ -local t = require('test.functional.testutil')() - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed describe('matchparen', function() before_each(clear) diff --git a/test/functional/legacy/memory_usage_spec.lua b/test/functional/legacy/memory_usage_spec.lua @@ -1,17 +1,19 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eval = n.eval local eq = t.eq -local feed_command = t.feed_command +local feed_command = n.feed_command local retry = t.retry local ok = t.ok -local source = t.source -local poke_eventloop = t.poke_eventloop -local load_adjust = t.load_adjust +local source = n.source +local poke_eventloop = n.poke_eventloop +local load_adjust = n.load_adjust local write_file = t.write_file local is_os = t.is_os local is_ci = t.is_ci -local is_asan = t.is_asan +local is_asan = n.is_asan clear() if is_asan() then diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed -local api = t.api -local nvim_dir = t.nvim_dir -local assert_alive = t.assert_alive + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed +local api = n.api +local nvim_dir = n.nvim_dir +local assert_alive = n.assert_alive before_each(clear) diff --git a/test/functional/legacy/mksession_spec.lua b/test/functional/legacy/mksession_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command -local fn = t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local fn = n.fn local eq = t.eq describe('mksession', function() diff --git a/test/functional/legacy/move_spec.lua b/test/functional/legacy/move_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed -local fn = t.fn + +local clear = n.clear +local feed = n.feed +local fn = n.fn before_each(clear) diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua @@ -1,8 +1,9 @@ -- Tests for nested function. -local t = require('test.functional.testutil')() -local clear, insert = t.clear, t.insert -local command, expect, source = t.command, t.expect, t.source +local n = require('test.functional.testnvim')() + +local clear, insert = n.clear, n.insert +local command, expect, source = n.command, n.expect, n.source describe('test_nested_function', function() setup(clear) diff --git a/test/functional/legacy/normal_spec.lua b/test/functional/legacy/normal_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local api = t.api + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local api = n.api local eq = t.eq -local fn = t.fn +local fn = n.fn describe('normal', function() local screen diff --git a/test/functional/legacy/number_spec.lua b/test/functional/legacy/number_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed describe("'number' and 'relativenumber'", function() before_each(clear) diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua @@ -1,11 +1,13 @@ -- See also: test/old/testdir/test_options.vim -local t = require('test.functional.testutil')() -local command, clear = t.command, t.clear -local source, expect = t.source, t.expect -local exc_exec = t.exc_exec -local matches = t.matches +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local command, clear = n.command, n.clear +local source, expect = n.source, n.expect +local exc_exec = n.exc_exec +local matches = t.matches + describe('options', function() setup(clear) diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed -local source = t.source -local clear = t.clear -local command = t.command -local expect = t.expect -local poke_eventloop = t.poke_eventloop -local api = t.api + +local feed = n.feed +local source = n.source +local clear = n.clear +local command = n.command +local expect = n.expect +local poke_eventloop = n.poke_eventloop +local api = n.api local eq = t.eq local neq = t.neq diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec_lua = t.exec_lua -local api = t.api -local source = t.source + +local clear = n.clear +local exec_lua = n.exec_lua +local api = n.api +local source = n.source local eq = t.eq local function sizeoflong() diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua @@ -1,8 +1,9 @@ -- Tests for quickfix window's title -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, expect = t.clear, t.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('qf_title', function() setup(clear) diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local assert_alive = t.assert_alive + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local assert_alive = n.assert_alive before_each(clear) diff --git a/test/functional/legacy/search_mbyte_spec.lua b/test/functional/legacy/search_mbyte_spec.lua @@ -1,10 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local poke_eventloop = t.poke_eventloop -local clear = t.clear -local insert = t.insert -local expect = t.expect -local command = t.command +local poke_eventloop = n.poke_eventloop +local clear = n.clear +local insert = n.insert +local expect = n.expect +local command = n.command describe('search_mbyte', function() before_each(clear) diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed -local fn = t.fn -local poke_eventloop = t.poke_eventloop -local exec = t.exec +local eval = n.eval +local feed = n.feed +local fn = n.fn +local poke_eventloop = n.poke_eventloop +local exec = n.exec describe('search cmdline', function() local screen diff --git a/test/functional/legacy/search_stat_spec.lua b/test/functional/legacy/search_stat_spec.lua @@ -1,6 +1,7 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, exec, command = t.clear, t.feed, t.exec, t.command + +local clear, feed, exec, command = n.clear, n.feed, n.exec, n.command describe('search stat', function() local screen diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua @@ -1,7 +1,8 @@ -- Tests for signs -local t = require('test.functional.testutil')() -local clear, command, expect = t.clear, t.command, t.expect +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect describe('signs', function() setup(clear) diff --git a/test/functional/legacy/source_spec.lua b/test/functional/legacy/source_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed + +local clear = n.clear +local feed = n.feed local write_file = t.write_file before_each(clear) diff --git a/test/functional/legacy/statusline_spec.lua b/test/functional/legacy/statusline_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/substitute_spec.lua b/test/functional/legacy/substitute_spec.lua @@ -2,12 +2,14 @@ -- Test for submatch() on substitute(). -- Test for *:s%* on :substitute. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert = t.feed, t.insert -local exec = t.exec -local clear, feed_command, expect = t.clear, t.feed_command, t.expect -local eq, eval = t.eq, t.eval + +local feed, insert = n.feed, n.insert +local exec = n.exec +local clear, feed_command, expect = n.clear, n.feed_command, n.expect +local eq, eval = t.eq, n.eval describe('substitute()', function() before_each(clear) diff --git a/test/functional/legacy/syn_attr_spec.lua b/test/functional/legacy/syn_attr_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval +local eval = n.eval -- oldtest: Test_missing_attr() describe('synIDattr()', function() diff --git a/test/functional/legacy/tabline_spec.lua b/test/functional/legacy/tabline_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/tagcase_spec.lua b/test/functional/legacy/tagcase_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local eval = t.eval -local exc_exec = t.exc_exec -local expect = t.expect -local insert = t.insert -local source = t.source +local eval = n.eval +local exc_exec = n.exc_exec +local expect = n.expect +local insert = n.insert +local source = n.source local write_file = t.write_file describe("'tagcase' option", function() diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() -local call = t.call -local clear = t.clear -local command = t.command -local expect = t.expect -local source = t.source +local n = require('test.functional.testnvim')() + +local call = n.call +local clear = n.clear +local command = n.command +local expect = n.expect +local source = n.source describe('Text object', function() before_each(function() diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local source, clear = t.source, t.clear -local eq, nvim = t.eq, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source, clear = n.source, n.clear +local eq, api = t.eq, n.api describe('undolevel', function() setup(clear) @@ -57,6 +59,6 @@ describe('undolevel', function() call Test_global_local_undolevels() ]]) - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua @@ -1,11 +1,13 @@ -- Tests for Unicode manipulations -local t = require('test.functional.testutil')() -local clear, feed, insert = t.clear, t.feed, t.insert -local command, expect = t.command, t.expect -local eq, eval = t.eq, t.eval -local source = t.source -local poke_eventloop = t.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local eq, eval = t.eq, n.eval +local source = n.source +local poke_eventloop = n.poke_eventloop describe('utf8', function() before_each(clear) diff --git a/test/functional/legacy/vimscript_spec.lua b/test/functional/legacy/vimscript_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local api = t.api + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local api = n.api before_each(clear) diff --git a/test/functional/legacy/visual_spec.lua b/test/functional/legacy/visual_spec.lua @@ -1,9 +1,9 @@ -local t = require('test.functional.testutil')() - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed -local exec = t.exec + +local clear = n.clear +local feed = n.feed +local exec = n.exec before_each(clear) diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local exec_lua = t.exec_lua -local command = t.command -local feed = t.feed + +local clear = n.clear +local exec = n.exec +local exec_lua = n.exec_lua +local command = n.command +local feed = n.feed -- oldtest: Test_window_cmd_ls0_split_scrolling() it('scrolling with laststatus=0 and :botright split', function() diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua @@ -1,10 +1,12 @@ -- Test for wordcount() function -local t = require('test.functional.testutil')() -local feed, insert, source = t.feed, t.insert, t.source -local clear, command = t.clear, t.command -local eq, eval = t.eq, t.eval -local poke_eventloop = t.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, command = n.clear, n.command +local eq, eval = t.eq, n.eval +local poke_eventloop = n.poke_eventloop describe('wordcount', function() before_each(clear) diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua @@ -1,7 +1,8 @@ -- Tests for writefile() -local t = require('test.functional.testutil')() -local clear, command, expect = t.clear, t.command, t.expect +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect describe('writefile', function() setup(clear) diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua @@ -1,14 +1,15 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local exc_exec = t.exc_exec +local exc_exec = n.exc_exec local remove_trace = t.remove_trace -local fn = t.fn -local clear = t.clear -local eval = t.eval +local fn = n.fn +local clear = n.clear +local eval = n.eval local NIL = vim.NIL local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/lua/base64_spec.lua b/test/functional/lua/base64_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local pcall_err = t.pcall_err local matches = t.matches diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua @@ -1,15 +1,16 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local command = t.command -local api = t.api -local fn = t.fn -local clear = t.clear +local command = n.command +local api = n.api +local fn = n.fn +local clear = n.clear local eq = t.eq local fail = t.fail -local exec_lua = t.exec_lua -local feed = t.feed +local exec_lua = n.exec_lua +local feed = n.feed local expect_events = t.expect_events local write_file = t.write_file local dedent = t.dedent @@ -292,11 +293,11 @@ describe('lua buffer event callbacks: on_lines', function() exec_lua(code) command('q!') - t.assert_alive() + n.assert_alive() exec_lua(code) command('bd!') - t.assert_alive() + n.assert_alive() end) it('#12718 lnume', function() @@ -965,7 +966,7 @@ describe('lua: nvim_buf_attach on_bytes', function() command('e! Xtest-undofile') command('set undodir=. | set undofile') - local ns = t.request('nvim_create_namespace', 'ns1') + local ns = n.request('nvim_create_namespace', 'ns1') api.nvim_buf_set_extmark(0, ns, 0, 0, {}) eq({ '12345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true)) diff --git a/test/functional/lua/command_line_completion_spec.lua b/test/functional/lua/command_line_completion_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local get_completions = function(input, env) return exec_lua('return {vim._expand_pat(...)}', input, env) diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua @@ -1,21 +1,22 @@ -- Test suite for checking :lua* commands -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq local NIL = vim.NIL -local eval = t.eval -local feed = t.feed -local clear = t.clear +local eval = n.eval +local feed = n.feed +local clear = n.clear local matches = t.matches -local api = t.api -local exec_lua = t.exec_lua -local exec_capture = t.exec_capture -local fn = t.fn -local source = t.source +local api = n.api +local exec_lua = n.exec_lua +local exec_capture = n.exec_capture +local fn = n.fn +local source = n.source local dedent = t.dedent -local command = t.command -local exc_exec = t.exc_exec +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err local write_file = t.write_file local remove_trace = t.remove_trace diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local api = t.api -local clear = t.clear +local api = n.api +local clear = n.clear local eq = t.eq -local exec_capture = t.exec_capture -local exec_lua = t.exec_lua -local feed = t.feed +local exec_capture = n.exec_capture +local exec_lua = n.exec_lua +local feed = n.feed -- Reference text -- aa diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local NIL = vim.NIL -local command = t.command -local clear = t.clear -local exec_lua = t.exec_lua +local command = n.command +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local matches = t.matches -local api = t.api +local api = n.api local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn describe('vim.diagnostic', function() before_each(function() @@ -1891,12 +1892,12 @@ describe('vim.diagnostic', function() it('respects legacy signs placed with :sign define or sign_define #26618', function() -- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12 - eq(0, t.fn.has('nvim-0.12')) + eq(0, n.fn.has('nvim-0.12')) - t.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg') - t.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg') - t.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined') - t.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined') + n.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg') + n.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg') + n.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined') + n.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined') local result = exec_lua [[ vim.diagnostic.config({ diff --git a/test/functional/lua/ffi_spec.lua b/test/functional/lua/ffi_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local exec_lua = t.exec_lua -local clear = t.clear +local exec_lua = n.exec_lua +local clear = n.clear before_each(clear) diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exec_lua = n.exec_lua local eq = t.eq -local api = t.api -local clear = t.clear -local pathroot = t.pathroot -local command = t.command +local api = n.api +local clear = n.clear +local pathroot = n.pathroot +local command = n.command local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local write_file = t.write_file local uv = vim.uv diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq -local mkdir_p = t.mkdir_p -local rmdir = t.rmdir -local nvim_dir = t.nvim_dir +local mkdir_p = n.mkdir_p +local rmdir = n.rmdir +local nvim_dir = n.nvim_dir local test_build_dir = t.paths.test_build_dir local test_source_path = t.paths.test_source_path -local nvim_prog = t.nvim_prog +local nvim_prog = n.nvim_prog local is_os = t.is_os local mkdir = t.mkdir diff --git a/test/functional/lua/glob_spec.lua b/test/functional/lua/glob_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua describe('glob', function() - before_each(t.clear) - after_each(t.clear) + before_each(n.clear) + after_each(n.clear) local match = function(...) return exec_lua( diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exec_lua = n.exec_lua local eq = t.eq local neq = t.neq -local eval = t.eval -local command = t.command -local clear = t.clear -local api = t.api +local eval = n.eval +local command = n.command +local clear = n.clear +local api = n.api describe('vim.highlight.on_yank', function() before_each(function() @@ -19,7 +21,7 @@ describe('vim.highlight.on_yank', function() vim.cmd('bwipeout!') ]]) vim.uv.sleep(10) - t.feed('<cr>') -- avoid hang if error message exists + n.feed('<cr>') -- avoid hang if error message exists eq('', eval('v:errmsg')) end) diff --git a/test/functional/lua/inspector_spec.lua b/test/functional/lua/inspector_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exec_lua = n.exec_lua local eq = t.eq -local eval = t.eval -local clear = t.clear +local eval = n.eval +local clear = n.clear describe('vim.inspect_pos', function() before_each(function() diff --git a/test/functional/lua/iter_spec.lua b/test/functional/lua/iter_spec.lua @@ -1,4 +1,5 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') + local eq = t.eq local matches = t.matches local pcall_err = t.pcall_err diff --git a/test/functional/lua/json_spec.lua b/test/functional/lua/json_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/lua/loader_spec.lua b/test/functional/lua/loader_spec.lua @@ -1,9 +1,10 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local exec_lua = t.exec_lua -local command = t.command -local clear = t.clear +local exec_lua = n.exec_lua +local command = n.command +local clear = n.clear local eq = t.eq describe('vim.loader', function() diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua @@ -1,15 +1,17 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local fn = t.fn -local api = t.api -local clear = t.clear + +local fn = n.fn +local api = n.api +local clear = n.clear local sleep = vim.uv.sleep -local feed = t.feed +local feed = n.feed local eq = t.eq -local eval = t.eval +local eval = n.eval local matches = t.matches -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local retry = t.retry before_each(clear) diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua @@ -1,17 +1,18 @@ -- Test suite for testing luaeval() function -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local pcall_err = t.pcall_err -local exc_exec = t.exc_exec +local exc_exec = n.exc_exec local remove_trace = t.remove_trace -local exec_lua = t.exec_lua -local command = t.command -local api = t.api -local fn = t.fn -local clear = t.clear -local eval = t.eval -local feed = t.feed +local exec_lua = n.exec_lua +local command = n.command +local api = n.api +local fn = n.fn +local clear = n.clear +local eval = n.eval +local feed = n.feed local NIL = vim.NIL local eq = t.eq diff --git a/test/functional/lua/mpack_spec.lua b/test/functional/lua/mpack_spec.lua @@ -1,9 +1,10 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua describe('lua vim.mpack', function() before_each(clear) diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua @@ -1,17 +1,18 @@ -- Test for Vim overrides of lua built-ins -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq local NIL = vim.NIL -local feed = t.feed -local clear = t.clear -local fn = t.fn -local api = t.api -local command = t.command +local feed = n.feed +local clear = n.clear +local fn = n.fn +local api = n.api +local command = n.command local write_file = t.write_file -local exec_capture = t.exec_capture -local exec_lua = t.exec_lua +local exec_capture = n.exec_capture +local exec_lua = n.exec_lua local pcall_err = t.pcall_err local is_os = t.is_os diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local exec = t.exec -local fn = t.fn -local mkdir_p = t.mkdir_p -local rmdir = t.rmdir +local eval = n.eval +local exec = n.exec +local fn = n.fn +local mkdir_p = n.mkdir_p +local rmdir = n.rmdir local write_file = t.write_file describe('runtime:', function() local plug_dir = 'Test_Plugin' - local sep = t.get_pathsep() + local sep = n.get_pathsep() local init = 'dummy_init.lua' setup(function() diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local clear = t.clear -local command = t.command -local pathsep = t.get_pathsep() +local clear = n.clear +local command = n.command +local pathsep = n.get_pathsep() local is_os = t.is_os -local api = t.api -local exec_lua = t.exec_lua -local feed_command = t.feed_command -local feed = t.feed -local fn = t.fn +local api = n.api +local exec_lua = n.exec_lua +local feed_command = n.feed_command +local feed = n.feed +local fn = n.fn local stdpath = fn.stdpath local pcall_err = t.pcall_err local matches = t.matches @@ -22,7 +23,7 @@ describe('vim.secure', function() setup(function() clear { env = { XDG_STATE_HOME = xstate } } - t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) + n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) t.write_file( 'Xfile', [[ @@ -33,7 +34,7 @@ describe('vim.secure', function() teardown(function() os.remove('Xfile') - t.rmdir(xstate) + n.rmdir(xstate) end) it('works', function() @@ -181,11 +182,11 @@ describe('vim.secure', function() setup(function() clear { env = { XDG_STATE_HOME = xstate } } - t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) + n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) end) teardown(function() - t.rmdir(xstate) + n.rmdir(xstate) end) before_each(function() diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local buf_lines = t.buf_lines -local clear = t.clear +local buf_lines = n.buf_lines +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua -local feed = t.feed -local api = t.api -local fn = t.fn +local exec_lua = n.exec_lua +local feed = n.feed +local api = n.api +local fn = n.fn local matches = t.matches local pcall_err = t.pcall_err -local poke_eventloop = t.poke_eventloop +local poke_eventloop = n.poke_eventloop local retry = t.retry describe('vim.snippet', function() diff --git a/test/functional/lua/spell_spec.lua b/test/functional/lua/spell_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local function system_sync(cmd, opts) diff --git a/test/functional/lua/text_spec.lua b/test/functional/lua/text_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq describe('vim.text', function() diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local clear = t.clear -local feed = t.feed + +local assert_alive = n.assert_alive +local clear = n.clear +local feed = n.feed local eq = t.eq -local exec_lua = t.exec_lua -local next_msg = t.next_msg +local exec_lua = n.exec_lua +local next_msg = n.next_msg local NIL = vim.NIL local pcall_err = t.pcall_err diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') + local eq = t.eq -local exec_lua = t.exec_lua -local clear = t.clear -local feed = t.feed -local fn = t.fn +local exec_lua = n.exec_lua +local clear = n.clear +local feed = n.feed +local fn = n.fn local assert_log = t.assert_log -local check_close = t.check_close +local check_close = n.check_close local testlog = 'Xtest_lua_ui_event_log' @@ -112,7 +114,7 @@ describe('vim.ui_attach', function() it('does not crash on exit', function() fn.system({ - t.nvim_prog, + n.nvim_prog, '-u', 'NONE', '-i', @@ -124,7 +126,7 @@ describe('vim.ui_attach', function() '--cmd', 'quitall!', }) - eq(0, t.eval('v:shell_error')) + eq(0, n.eval('v:shell_error')) end) it('can receive accurate message kinds even if they are history', function() diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq local ok = t.ok -local exec_lua = t.exec_lua -local clear = t.clear -local feed = t.feed -local eval = t.eval +local exec_lua = n.exec_lua +local clear = n.clear +local feed = n.feed +local eval = n.eval local is_ci = t.is_ci local is_os = t.is_os -local poke_eventloop = t.poke_eventloop +local poke_eventloop = n.poke_eventloop describe('vim.ui', function() before_each(function() diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local is_os = t.is_os local skip = t.skip diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq local ok = t.ok -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local matches = t.matches local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn local function v(ver) return vim.version._version(ver) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua @@ -1,32 +1,33 @@ -- Test suite for testing interactions with API bindings -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local nvim_prog = t.nvim_prog -local fn = t.fn -local api = t.api -local command = t.command +local nvim_prog = n.nvim_prog +local fn = n.fn +local api = n.api +local command = n.command local dedent = t.dedent -local insert = t.insert -local clear = t.clear +local insert = n.insert +local clear = n.clear local eq = t.eq local ok = t.ok local pesc = vim.pesc -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed local pcall_err = t.pcall_err -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local matches = t.matches -local exec = t.exec +local exec = n.exec local NIL = vim.NIL local retry = t.retry -local next_msg = t.next_msg +local next_msg = n.next_msg local remove_trace = t.remove_trace -local mkdir_p = t.mkdir_p -local rmdir = t.rmdir +local mkdir_p = n.mkdir_p +local rmdir = n.rmdir local write_file = t.write_file -local poke_eventloop = t.poke_eventloop -local assert_alive = t.assert_alive +local poke_eventloop = n.poke_eventloop +local assert_alive = n.assert_alive describe('lua stdlib', function() before_each(clear) @@ -1574,7 +1575,7 @@ describe('lua stdlib', function() eq(NIL, exec_lua([[return vim.g.Unknown_script_func]])) -- Check if autoload works properly - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() local xconfig = 'Xhome' .. pathsep .. 'Xconfig' local xdata = 'Xhome' .. pathsep .. 'Xdata' local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep) @@ -4076,7 +4077,7 @@ describe('vim.keymap', function() feed('asdf\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap asdf')) + eq('\nNo mapping found', n.exec_capture('nmap asdf')) end) it('works with buffer-local mappings', function() @@ -4100,7 +4101,7 @@ describe('vim.keymap', function() feed('asdf\n') eq(1, exec_lua [[return GlobalCount]]) - eq('\nNo mapping found', t.exec_capture('nmap asdf')) + eq('\nNo mapping found', n.exec_capture('nmap asdf')) end) it('does not mutate the opts parameter', function() diff --git a/test/functional/lua/watch_spec.lua b/test/functional/lua/watch_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local exec_lua = t.exec_lua -local clear = t.clear +local exec_lua = n.exec_lua +local clear = n.clear local is_ci = t.is_ci local is_os = t.is_os local skip = t.skip @@ -24,7 +26,7 @@ describe('vim._watch', function() if watchfunc == 'fswatch' then skip(is_os('win'), 'not supported on windows') skip(is_os('mac'), 'flaky test on mac') - skip(not is_ci() and t.fn.executable('fswatch') == 0, 'fswatch not installed and not on CI') + skip(not is_ci() and n.fn.executable('fswatch') == 0, 'fswatch not installed and not on CI') end if watchfunc == 'watch' then diff --git a/test/functional/lua/xdiff_spec.lua b/test/functional/lua/xdiff_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local fn = t.fn -local command = t.command +local fn = n.fn +local command = n.command local mkdir = t.mkdir describe("'autochdir'", function() @@ -38,7 +40,7 @@ describe("'autochdir'", function() eq(dir_a, fn.getcwd()) fn.getwinvar(2, 'foo') eq(dir_a, fn.getcwd()) - t.rmdir(dir_a) - t.rmdir(dir_b) + n.rmdir(dir_a) + n.rmdir(dir_b) end) end) diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command = t.clear, t.command + +local clear, command = n.clear, n.command local pcall_err = t.pcall_err -local eval = t.eval +local eval = n.eval local eq = t.eq -local insert = t.insert -local feed = t.feed -local api = t.api +local insert = n.insert +local feed = n.feed +local api = n.api describe("'fillchars'", function() local screen diff --git a/test/functional/options/cursorbind_spec.lua b/test/functional/options/cursorbind_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua @@ -1,26 +1,26 @@ -local t = require('test.functional.testutil')() - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local assert_log = t.assert_log -local api = t.api -local command = t.command -local clear = t.clear -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local eval = t.eval +local api = n.api +local command = n.command +local clear = n.clear +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local eval = n.eval local eq = t.eq local ok = t.ok -local fn = t.fn -local insert = t.insert +local fn = n.fn +local insert = n.insert local neq = t.neq local mkdir = t.mkdir -local rmdir = t.rmdir -local alter_slashes = t.alter_slashes +local rmdir = n.rmdir +local alter_slashes = n.alter_slashes local tbl_contains = vim.tbl_contains -local expect_exit = t.expect_exit -local check_close = t.check_close +local expect_exit = n.expect_exit +local check_close = n.check_close local is_os = t.is_os local testlog = 'Xtest-defaults-log' @@ -1248,7 +1248,7 @@ end) describe('autocommands', function() it('closes terminal with default shell on success', function() clear() - api.nvim_set_option_value('shell', t.testprg('shell-test'), {}) + api.nvim_set_option_value('shell', n.testprg('shell-test'), {}) command('set shellcmdflag=EXIT shellredir= shellpipe= shellquote= shellxquote=') -- Should not block other events diff --git a/test/functional/options/keymap_spec.lua b/test/functional/options/keymap_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear, feed, eq = t.clear, t.feed, t.eq -local expect, command, eval = t.expect, t.command, t.eval -local insert, call = t.insert, t.call -local exec_capture, dedent = t.exec_capture, t.dedent +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, eq = n.clear, n.feed, t.eq +local expect, command, eval = n.expect, n.command, n.eval +local insert, call = n.insert, n.call +local exec_capture, dedent = n.exec_capture, t.dedent -- First test it's implemented using the :lmap and :lnoremap commands, then -- check those mappings behave as expected. diff --git a/test/functional/options/modified_spec.lua b/test/functional/options/modified_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local api = t.api +local api = n.api describe("'modified'", function() before_each(function() diff --git a/test/functional/options/mousescroll_spec.lua b/test/functional/options/mousescroll_spec.lua @@ -1,21 +1,23 @@ -local t = require('test.functional.testutil')() -local command = t.command -local clear = t.clear -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local clear = n.clear +local eval = n.eval local eq = t.eq -local exc_exec = t.exc_exec -local feed = t.feed +local exc_exec = n.exc_exec +local feed = n.feed local scroll = function(direction) - return t.request('nvim_input_mouse', 'wheel', direction, '', 0, 2, 2) + return n.request('nvim_input_mouse', 'wheel', direction, '', 0, 2, 2) end local screenrow = function() - return t.call('screenrow') + return n.call('screenrow') end local screencol = function() - return t.call('screencol') + return n.call('screencol') end describe("'mousescroll'", function() diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua @@ -1,7 +1,9 @@ -- Tests for :setlocal and :setglobal -local t = require('test.functional.testutil')() -local clear, feed_command, eval, eq, api = t.clear, t.feed_command, t.eval, t.eq, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, eval, eq, api = n.clear, n.feed_command, n.eval, t.eq, n.api local function should_fail(opt, value, errmsg) feed_command('setglobal ' .. opt .. '=' .. value) diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed describe("'shortmess'", function() local screen diff --git a/test/functional/options/tabstop_spec.lua b/test/functional/options/tabstop_spec.lua @@ -1,8 +1,8 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local assert_alive = t.assert_alive -local clear = t.clear -local feed = t.feed +local assert_alive = n.assert_alive +local clear = n.clear +local feed = n.feed describe("'tabstop' option", function() before_each(function() diff --git a/test/functional/options/winfixbuf_spec.lua b/test/functional/options/winfixbuf_spec.lua @@ -1,6 +1,7 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua describe("Nvim API calls with 'winfixbuf'", function() before_each(function() diff --git a/test/functional/plugin/ccomplete_spec.lua b/test/functional/plugin/ccomplete_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed local write_file = t.write_file describe('ccomplete#Complete', function() diff --git a/test/functional/plugin/cfilter_spec.lua b/test/functional/plugin/cfilter_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local fn = t.fn +local fn = n.fn describe('cfilter.lua', function() before_each(function() diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local pathsep = t.get_pathsep() -local fn = t.fn -local api = t.api -local exec_lua = t.exec_lua +local pathsep = n.get_pathsep() +local fn = n.fn +local api = n.api +local exec_lua = n.exec_lua local testdir = 'Xtest-editorconfig' @@ -20,7 +22,7 @@ local function test_case(name, expected) end setup(function() - t.mkdir_p(testdir) + n.mkdir_p(testdir) t.write_file( testdir .. pathsep .. '.editorconfig', [[ @@ -96,7 +98,7 @@ setup(function() end) teardown(function() - t.rmdir(testdir) + n.rmdir(testdir) end) describe('editorconfig', function() diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local curbuf_contents = t.curbuf_contents -local command = t.command +local clear = n.clear +local curbuf_contents = n.curbuf_contents +local command = n.command local eq, neq, matches = t.eq, t.neq, t.matches -local getcompletion = t.fn.getcompletion -local exec_lua = t.exec_lua -local assert_alive = t.assert_alive -local insert = t.insert -local source = t.source -local fn = t.fn -local api = t.api +local getcompletion = n.fn.getcompletion +local insert = n.insert +local exec_lua = n.exec_lua +local source = n.source +local assert_alive = n.assert_alive +local fn = n.fn +local api = n.api describe(':checkhealth', function() it('detects invalid $VIMRUNTIME', function() @@ -67,7 +68,7 @@ describe('health.vim', function() describe(':checkhealth', function() it('functions report_*() render correctly', function() command('checkhealth full_render') - t.expect([[ + n.expect([[ ============================================================================== test_plug.full_render: require("test_plug.full_render.health").check() @@ -90,7 +91,7 @@ describe('health.vim', function() it('concatenates multiple reports', function() command('checkhealth success1 success2 test_plug') - t.expect([[ + n.expect([[ ============================================================================== test_plug: require("test_plug.health").check() @@ -120,7 +121,7 @@ describe('health.vim', function() it('lua plugins submodules', function() command('checkhealth test_plug.submodule') - t.expect([[ + n.expect([[ ============================================================================== test_plug.submodule: require("test_plug.submodule.health").check() @@ -135,7 +136,7 @@ describe('health.vim', function() it('... including empty reports', function() command('checkhealth test_plug.submodule_empty') - t.expect([[ + n.expect([[ ============================================================================== test_plug.submodule_empty: require("test_plug.submodule_empty.health").check() @@ -176,7 +177,7 @@ describe('health.vim', function() it('gracefully handles invalid healthcheck', function() command('checkhealth non_existent_healthcheck') -- luacheck: ignore 613 - t.expect([[ + n.expect([[ ============================================================================== non_existent_healthcheck: @@ -188,7 +189,7 @@ describe('health.vim', function() it('does not use vim.health as a healtcheck', function() -- vim.health is not a healthcheck command('checkhealth vim') - t.expect([[ + n.expect([[ ERROR: No healthchecks found.]]) end) end) diff --git a/test/functional/plugin/lsp/codelens_spec.lua b/test/functional/plugin/lsp/codelens_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local eq = t.eq describe('vim.lsp.codelens', function() before_each(function() - t.clear() + n.clear() exec_lua('require("vim.lsp")') end) - after_each(t.clear) + after_each(n.clear) it('on_codelens_stores_and_displays_lenses', function() local fake_uri = 'file:///fake/uri' diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua @@ -1,7 +1,9 @@ ---@diagnostic disable: no-unknown -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua --- Convert completion results. --- @@ -41,7 +43,7 @@ local function complete(line, candidates, lnum) end describe('vim.lsp._completion', function() - before_each(t.clear) + before_each(n.clear) -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion it('prefers textEdit over label as word', function() diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local t_lsp = require('test.functional.plugin.lsp.testutil') -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua local eq = t.eq local neq = t.neq diff --git a/test/functional/plugin/lsp/handler_spec.lua b/test/functional/plugin/lsp/handler_spec.lua @@ -1,7 +1,8 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local pcall_err = t.pcall_err local matches = t.matches diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -1,11 +1,12 @@ -- Test suite for testing interactions with the incremental sync algorithms powering the LSP client -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local api = t.api -local clear = t.clear +local api = n.api +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua -local feed = t.feed +local exec_lua = n.exec_lua +local feed = n.feed before_each(function() clear() diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() -local t_lsp = require('test.functional.plugin.lsp.testutil') +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local t_lsp = require('test.functional.plugin.lsp.testutil') local eq = t.eq local dedent = t.dedent -local exec_lua = t.exec_lua -local insert = t.insert -local api = t.api +local exec_lua = n.exec_lua +local insert = n.insert +local api = n.api local clear_notrace = t_lsp.clear_notrace local create_server_definition = t_lsp.create_server_definition diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() -local t_lsp = require('test.functional.plugin.lsp.testutil') +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local t_lsp = require('test.functional.plugin.lsp.testutil') -local command = t.command +local command = n.command local dedent = t.dedent local eq = t.eq -local exec_lua = t.exec_lua -local feed = t.feed -local feed_command = t.feed_command -local insert = t.insert +local exec_lua = n.exec_lua +local feed = n.feed +local feed_command = n.feed_command +local insert = n.insert local matches = t.matches -local api = t.api +local api = n.api local clear_notrace = t_lsp.clear_notrace local create_server_definition = t_lsp.create_server_definition diff --git a/test/functional/plugin/lsp/snippet_spec.lua b/test/functional/plugin/lsp/snippet_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local snippet = require('vim.lsp._snippet_grammar') local type = snippet.NodeType local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua describe('vim.lsp._snippet_grammar', function() - before_each(t.clear) - after_each(t.clear) + before_each(n.clear) + after_each(n.clear) local parse = function(...) local res = exec_lua('return require("vim.lsp._snippet_grammar").parse(...)', ...) diff --git a/test/functional/plugin/lsp/testutil.lua b/test/functional/plugin/lsp/testutil.lua @@ -1,10 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua -local run = t.run -local stop = t.stop -local api = t.api +local clear = n.clear +local exec_lua = n.exec_lua +local run = n.run +local stop = n.stop +local api = n.api local NIL = vim.NIL local M = {} diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed +local feed = n.feed local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua describe('vim.lsp.util', function() - before_each(t.clear) + before_each(n.clear) describe('stylize_markdown', function() local stylize_markdown = function(content, opts) @@ -142,7 +143,7 @@ describe('vim.lsp.util', function() local screen before_each(function() - t.clear() + n.clear() screen = Screen.new(80, 80) screen:attach() feed('79i<CR><Esc>') -- fill screen with empty lines diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua @@ -1,26 +1,28 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local t_lsp = require('test.functional.plugin.lsp.testutil') local assert_log = t.assert_log -local buf_lines = t.buf_lines -local clear = t.clear -local command = t.command +local buf_lines = n.buf_lines +local clear = n.clear +local command = n.command local dedent = t.dedent -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local eq = t.eq -local eval = t.eval +local eval = n.eval local matches = t.matches local pcall_err = t.pcall_err local pesc = vim.pesc -local insert = t.insert -local fn = t.fn +local insert = n.insert +local fn = n.fn local retry = t.retry -local stop = t.stop +local stop = n.stop local NIL = vim.NIL local read_file = t.read_file local write_file = t.write_file local is_ci = t.is_ci -local api = t.api +local api = n.api local is_os = t.is_os local skip = t.skip local mkdir = t.mkdir @@ -1481,7 +1483,7 @@ describe('LSP', function() end, on_handler = function(err, result, ctx) if ctx.method == 'start' then - t.command('normal! 1Go') + n.command('normal! 1Go') client.notify('finish') end eq(table.remove(expected_handlers), { err, result, ctx }, 'expected handler') @@ -2368,7 +2370,7 @@ describe('LSP', function() end) describe('lsp.util.rename', function() - local pathsep = t.get_pathsep() + local pathsep = n.get_pathsep() it('Can rename an existing file', function() local old = tmpname() @@ -2404,7 +2406,7 @@ describe('LSP', function() os.remove(old_dir) os.remove(new_dir) - t.mkdir_p(old_dir) + n.mkdir_p(old_dir) local file = 'file.txt' write_file(old_dir .. pathsep .. file, 'Test content') @@ -2440,7 +2442,7 @@ describe('LSP', function() local new = tmpname() os.remove(old) os.remove(new) - t.mkdir_p(old) + n.mkdir_p(old) local result = exec_lua( [[ diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local command, feed = t.command, t.feed -local clear = t.clear -local exec_lua = t.exec_lua -local fn = t.fn -local nvim_prog = t.nvim_prog + +local command, feed = n.command, n.feed +local clear = n.clear +local exec_lua = n.exec_lua +local fn = n.fn +local nvim_prog = n.nvim_prog local matches = t.matches local write_file = t.write_file local tmpname = t.tmpname diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local api = t.api -local feed = t.feed +local clear = n.clear +local command = n.command +local api = n.api +local feed = n.feed local eq = t.eq describe('matchparen', function() diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local api = n.api local eq = t.eq -local nvim_eval = t.eval -local nvim_command = t.command -local exc_exec = t.exc_exec +local nvim_eval = n.eval +local nvim_command = n.command +local exc_exec = n.exc_exec local ok = t.ok local NIL = vim.NIL diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear +local t_shada = require('test.functional.shada.testutil') + +local clear = n.clear local eq, api, nvim_eval, nvim_command, exc_exec, fn, nvim_feed = - t.eq, t.api, t.eval, t.command, t.exc_exec, t.fn, t.feed + t.eq, n.api, n.eval, n.command, n.exc_exec, n.fn, n.feed local neq = t.neq local read_file = t.read_file -local t_shada = require('test.functional.shada.testutil') local get_shada_rw = t_shada.get_shada_rw local function reset(shada_file) diff --git a/test/functional/plugin/tohtml_spec.lua b/test/functional/plugin/tohtml_spec.lua @@ -1,13 +1,14 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local clear = t.clear -local exec = t.exec -local exec_lua = t.exec_lua +local clear = n.clear +local exec = n.exec +local exec_lua = n.exec_lua local eq = t.eq -local fn = t.fn -local api = t.api -local insert = t.insert +local fn = n.fn +local api = n.api +local insert = n.insert local function html_syntax_match() local styles = diff --git a/test/functional/plugin/tutor_spec.lua b/test/functional/plugin/tutor_spec.lua @@ -1,8 +1,10 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command -local feed = t.feed + +local clear = n.clear +local command = n.command +local feed = n.feed local is_os = t.is_os describe(':Tutor', function() diff --git a/test/functional/plugin/vim_syntax_spec.lua b/test/functional/plugin/vim_syntax_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local api = t.api + +local clear = n.clear +local exec = n.exec +local api = n.api describe('Vimscript syntax highlighting', function() local screen --- @type test.functional.ui.screen before_each(function() clear() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() exec([[ setfiletype vim syntax on diff --git a/test/functional/preload.lua b/test/functional/preload.lua @@ -1,11 +1,10 @@ -- Modules loaded here will NOT be cleared and reloaded by Busted. -- Busted started doing this to help provide more isolation. See issue #62 -- for more information about this. -local t = require('test.functional.testutil')() +local t = require('test.testutil') require('test.functional.ui.screen') -local is_os = t.is_os -if is_os('win') then +if t.is_os('win') then local ffi = require('ffi') ffi.cdef [[ typedef int errno_t; diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua @@ -1,11 +1,13 @@ -- Test clipboard provider support -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local feed_command, expect, eq, eval, source = t.feed_command, t.expect, t.eq, t.eval, t.source -local command = t.command -local api = t.api + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect, eq, eval, source = n.feed_command, n.expect, t.eq, n.eval, n.source +local command = n.command +local api = n.api local function basic_register_test(noblock) insert('some words') diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local eval, command = t.eval, t.command -local eq, run, stop = t.eq, t.run, t.stop -local clear = t.clear -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eval, command = n.eval, n.command +local eq, run, stop = t.eq, n.run, n.stop +local clear = n.clear +local api = n.api local function get_prefix(sync) if sync then @@ -28,7 +30,7 @@ local function runx(sync, handler, on_setup) local function setup_cb(...) on_setup(...) -- need to stop on setup callback because there's two session:request - -- calls in `request/testutil.lua`. The second call will always return + -- calls in `request/testnvim.lua`. The second call will always return -- after pending notification/request callbacks are processed stop() end @@ -324,7 +326,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init) end) it('with range', function() - t.insert([[ + n.insert([[ foo bar baz diff --git a/test/functional/provider/nodejs_spec.lua b/test/functional/provider/nodejs_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() -local eq, clear = t.eq, t.clear -local missing_provider = t.missing_provider -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear = t.eq, n.clear +local missing_provider = n.missing_provider +local command = n.command local write_file = t.write_file -local eval = t.eval +local eval = n.eval local retry = t.retry do diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local eq, clear = t.eq, t.clear -local missing_provider = t.missing_provider -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear = t.eq, n.clear +local missing_provider = n.missing_provider +local command = n.command local write_file = t.write_file -local eval = t.eval +local eval = n.eval local retry = t.retry -local api = t.api -local insert = t.insert -local expect = t.expect -local feed = t.feed +local api = n.api +local insert = n.insert +local expect = n.expect +local feed = n.feed do clear() diff --git a/test/functional/provider/provider_spec.lua b/test/functional/provider/provider_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eval = t.clear, t.eval -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval = n.clear, n.eval +local command = n.command local eq = t.eq local pcall_err = t.pcall_err diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local eval, command, feed = t.eval, t.command, t.feed -local eq, clear, insert = t.eq, t.clear, t.insert -local expect, write_file = t.expect, t.write_file -local feed_command = t.feed_command -local source = t.source -local missing_provider = t.missing_provider +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local eval, command, feed = n.eval, n.command, n.feed +local eq, clear, insert = t.eq, n.clear, n.insert +local expect, write_file = n.expect, t.write_file +local feed_command = n.feed_command +local source = n.source +local missing_provider = n.missing_provider local matches = t.matches local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn local dedent = t.dedent do @@ -153,7 +155,7 @@ describe('python3 provider', function() end) it('RPC call to expand("<afile>") during BufDelete #5245 #5617', function() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() source([=[ python3 << EOF import vim diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local assert_alive = t.assert_alive -local clear = t.clear -local command = t.command +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command local eq = t.eq -local exc_exec = t.exc_exec -local expect = t.expect -local feed = t.feed -local feed_command = t.feed_command -local fn = t.fn -local insert = t.insert -local api = t.api -local missing_provider = t.missing_provider +local exc_exec = n.exc_exec +local expect = n.expect +local feed = n.feed +local feed_command = n.feed_command +local fn = n.fn +local insert = n.insert +local api = n.api +local missing_provider = n.missing_provider local matches = t.matches local write_file = t.write_file local pcall_err = t.pcall_err @@ -103,7 +104,7 @@ end) describe('ruby provider', function() it('RPC call to expand("<afile>") during BufDelete #5245 #5617', function() - t.add_builddir_to_rtp() + n.add_builddir_to_rtp() command([=[autocmd BufDelete * ruby VIM::evaluate('expand("<afile>")')]=]) feed_command('help help') assert_alive() diff --git a/test/functional/script/luacats_grammar_spec.lua b/test/functional/script/luacats_grammar_spec.lua @@ -1,4 +1,5 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') + local eq = t.eq local grammar = require('scripts/luacats_grammar') diff --git a/test/functional/script/luacats_parser_spec.lua b/test/functional/script/luacats_parser_spec.lua @@ -1,4 +1,5 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') + local eq = t.eq local parser = require('scripts/luacats_parser') diff --git a/test/functional/script/text_utils_spec.lua b/test/functional/script/text_utils_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local exec_lua = t.exec_lua +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exec_lua = n.exec_lua local eq = t.eq local function md_to_vimdoc(text, start_indent, indent, text_width) @@ -28,7 +30,7 @@ end describe('md_to_vimdoc', function() before_each(function() - t.clear() + n.clear() end) test('can render para after fenced code', { diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua @@ -1,9 +1,11 @@ -- shada buffer list saving/reading support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq, api = t.command, t.fn, t.eq, t.api -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, eq, api = n.command, n.fn, t.eq, n.api +local expect_exit = n.expect_exit + local reset, clear = t_shada.reset, t_shada.clear describe('shada support code', function() diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua @@ -1,9 +1,10 @@ -- ShaDa compatibility support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq -local exc_exec = t.exc_exec - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, eq = n.command, n.fn, t.eq +local exc_exec = n.exc_exec local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw local read_shada_file = t_shada.read_shada_file diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua @@ -1,8 +1,9 @@ -- ShaDa errors handling support -local t = require('test.functional.testutil')() -local nvim_command, eq, exc_exec = t.command, t.eq, t.exc_exec - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, eq, exc_exec = n.command, t.eq, n.exc_exec local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw local wshada, sdrcmd, shada_fname, clean = get_shada_rw('Xtest-functional-shada-errors.shada') diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua @@ -1,10 +1,12 @@ -- ShaDa history saving/reading support -local t = require('test.functional.testutil')() -local nvim_command, fn, api, nvim_feed, eq = t.command, t.fn, t.api, t.feed, t.eq -local assert_alive = t.assert_alive -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, api, nvim_feed, eq = n.command, n.fn, n.api, n.feed, t.eq +local assert_alive = n.assert_alive +local expect_exit = n.expect_exit + local reset, clear = t_shada.reset, t_shada.clear describe('ShaDa support code', function() diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua @@ -1,11 +1,13 @@ -- ShaDa marks saving/reading support -local t = require('test.functional.testutil')() -local api, nvim_command, fn, eq = t.api, t.command, t.fn, t.eq -local feed = t.feed -local exc_exec, exec_capture = t.exc_exec, t.exec_capture -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local api, nvim_command, fn, eq = n.api, n.command, n.fn, t.eq +local feed = n.feed +local exc_exec, exec_capture = n.exc_exec, n.exec_capture +local expect_exit = n.expect_exit + local reset, clear = t_shada.reset, t_shada.clear local nvim_current_line = function() @@ -216,7 +218,7 @@ describe('ShaDa support code', function() -- -c temporary sets lnum to zero to make `+/pat` work, so calling setpcmark() -- during -c used to add item with zero lnum to jump list. it('does not create incorrect file for non-existent buffers when writing from -c', function() - local argv = t.new_argv { + local argv = n.new_argv { args_rm = { '-i', '--embed', -- no --embed @@ -235,7 +237,7 @@ describe('ShaDa support code', function() end) it('does not create incorrect file for non-existent buffers opened from -c', function() - local argv = t.new_argv { + local argv = n.new_argv { args_rm = { '-i', '--embed', -- no --embed diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua @@ -1,10 +1,12 @@ -- ShaDa merging data support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq -local exc_exec, exec_capture = t.exc_exec, t.exec_capture -local api = t.api - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, eq = n.command, n.fn, t.eq +local exc_exec, exec_capture = n.exc_exec, n.exec_capture +local api = n.api + local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw local read_shada_file = t_shada.read_shada_file diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua @@ -1,10 +1,11 @@ -- ShaDa registers saving/reading support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, eq = n.command, n.fn, t.eq local reset, clear = t_shada.reset, t_shada.clear -local expect_exit = t.expect_exit +local expect_exit = n.expect_exit local setreg = function(name, contents, typ) if type(contents) == 'string' then diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua @@ -1,15 +1,16 @@ -- Other ShaDa tests -local t = require('test.functional.testutil')() -local api, nvim_command, fn, eq = t.api, t.command, t.fn, t.eq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local t_shada = require('test.functional.shada.testutil') +local uv = vim.uv +local paths = t.paths + +local api, nvim_command, fn, eq = n.api, n.command, n.fn, t.eq local write_file, spawn, set_session, nvim_prog, exc_exec = - t.write_file, t.spawn, t.set_session, t.nvim_prog, t.exc_exec + t.write_file, n.spawn, n.set_session, n.nvim_prog, n.exc_exec local is_os = t.is_os local skip = t.skip -local uv = vim.uv -local paths = t.paths - -local t_shada = require('test.functional.shada.testutil') local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw local read_shada_file = t_shada.read_shada_file diff --git a/test/functional/shada/testutil.lua b/test/functional/shada/testutil.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api = n.api local write_file = t.write_file local concat_tables = t.concat_tables @@ -24,7 +26,7 @@ local function reset(o) elseif o.args then args = concat_tables(args, o.args) end - t.clear { + n.clear { args_rm = args_rm, args = args, } @@ -32,7 +34,7 @@ local function reset(o) end local clear = function() - t.expect_exit(t.command, 'qall!') + n.expect_exit(n.command, 'qall!') os.remove(tmpname) end diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua @@ -1,9 +1,10 @@ -- ShaDa variables saving/reading support -local t = require('test.functional.testutil')() -local api, fn, nvim_command, eq, eval = t.api, t.fn, t.command, t.eq, t.eval -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local api, fn, nvim_command, eq, eval = n.api, n.fn, n.command, t.eq, n.eval +local expect_exit = n.expect_exit local reset, clear = t_shada.reset, t_shada.clear describe('ShaDa support code', function() diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local tt = require('test.functional.terminal.testutil') -local clear, eq, api = t.clear, t.eq, t.api -local feed = t.feed +local clear, eq, api = n.clear, t.eq, n.api +local feed = n.feed local feed_data = tt.feed_data local enter_altscreen = tt.enter_altscreen local exit_altscreen = tt.exit_altscreen diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua @@ -1,4 +1,6 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local tt = require('test.functional.terminal.testutil') local ok = t.ok @@ -11,7 +13,7 @@ describe('api', function() local socket_name = './Xtest_functional_api.sock' before_each(function() - t.clear() + n.clear() os.remove(socket_name) screen = tt.setup_child_nvim({ '-u', @@ -21,7 +23,7 @@ describe('api', function() '--cmd', 'colorscheme vim', '--cmd', - t.nvim_set .. ' notermguicolors', + n.nvim_set .. ' notermguicolors', }) end) after_each(function() @@ -49,8 +51,8 @@ describe('api', function() {3:-- TERMINAL --} | ]]) - local socket_session1 = t.connect(socket_name) - local socket_session2 = t.connect(socket_name) + local socket_session1 = n.connect(socket_name) + local socket_session2 = n.connect(socket_name) tt.feed_data('i[tui] insert-mode') -- Wait for stdin to be processed. diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua @@ -1,23 +1,25 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local tt = require('test.functional.terminal.testutil') -local assert_alive = t.assert_alive -local feed, clear = t.feed, t.clear -local poke_eventloop = t.poke_eventloop -local nvim_prog = t.nvim_prog -local eval, feed_command, source = t.eval, t.feed_command, t.source + +local assert_alive = n.assert_alive +local feed, clear = n.feed, n.clear +local poke_eventloop = n.poke_eventloop +local nvim_prog = n.nvim_prog +local eval, feed_command, source = n.eval, n.feed_command, n.source local pcall_err = t.pcall_err local eq, neq = t.eq, t.neq -local api = t.api +local api = n.api local retry = t.retry -local testprg = t.testprg +local testprg = n.testprg local write_file = t.write_file -local command = t.command -local exc_exec = t.exc_exec +local command = n.command +local exc_exec = n.exc_exec local matches = t.matches -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local sleep = vim.uv.sleep -local fn = t.fn +local fn = n.fn local is_os = t.is_os local skip = t.skip @@ -266,7 +268,7 @@ describe(':terminal buffer', function() it('does not segfault when pasting empty register #13955', function() feed('<c-\\><c-n>') feed_command('put a') -- register a is empty - t.assert_alive() + n.assert_alive() end) it([[can use temporary normal mode <c-\><c-o>]], function() diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua @@ -1,17 +1,19 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear + +local clear = n.clear local eq = t.eq -local eval = t.eval -local command = t.command +local eval = n.eval +local command = n.command local pcall_err = t.pcall_err -local feed = t.feed -local poke_eventloop = t.poke_eventloop +local feed = n.feed +local poke_eventloop = n.poke_eventloop local is_os = t.is_os -local api = t.api -local async_meths = t.async_meths -local testprg = t.testprg -local assert_alive = t.assert_alive +local api = n.api +local async_meths = n.async_meths +local testprg = n.testprg +local assert_alive = n.assert_alive describe('terminal channel is closed and later released if', function() local screen diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local tt = require('test.functional.terminal.testutil') -local feed, clear = t.feed, t.clear -local testprg, command = t.testprg, t.command -local eq, eval = t.eq, t.eval + +local feed, clear = n.feed, n.clear +local testprg, command = n.testprg, n.command +local eq, eval = t.eq, n.eval local matches = t.matches -local poke_eventloop = t.poke_eventloop +local poke_eventloop = n.poke_eventloop local hide_cursor = tt.hide_cursor local show_cursor = tt.show_cursor local is_os = t.is_os @@ -66,7 +68,7 @@ describe(':terminal cursor', function() :set number | ]]) feed('i') - t.poke_eventloop() + n.poke_eventloop() screen:expect([[ {7: 1 }tty ready | {7: 2 }rows: 6, cols: 46 | diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local screen = require('test.functional.ui.screen') -local testprg = t.testprg -local command = t.command -local fn = t.fn -local api = t.api -local clear = t.clear +local testprg = n.testprg +local command = n.command +local fn = n.fn +local api = n.api +local clear = n.clear local eq = t.eq local matches = t.matches local pesc = vim.pesc diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local clear, poke_eventloop = t.clear, t.poke_eventloop -local testprg, source, eq = t.testprg, t.source, t.eq -local feed = t.feed -local feed_command, eval = t.feed_command, t.eval -local fn = t.fn -local api = t.api + +local assert_alive = n.assert_alive +local clear, poke_eventloop = n.clear, n.poke_eventloop +local testprg, source, eq = n.testprg, n.source, t.eq +local feed = n.feed +local feed_command, eval = n.feed_command, n.eval +local fn = n.fn +local api = n.api local retry = t.retry local ok = t.ok -local command = t.command +local command = n.command local skip = t.skip local is_os = t.is_os local is_ci = t.is_ci diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local tt = require('test.functional.terminal.testutil') -local feed, clear = t.feed, t.clear -local api = t.api -local testprg, command = t.testprg, t.command -local nvim_prog_abs = t.nvim_prog_abs -local fn = t.fn -local nvim_set = t.nvim_set + +local feed, clear = n.feed, n.clear +local api = n.api +local testprg, command = n.testprg, n.command +local nvim_prog_abs = n.nvim_prog_abs +local fn = n.fn +local nvim_set = n.nvim_set local is_os = t.is_os local skip = t.skip diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local tt = require('test.functional.terminal.testutil') -local clear, eq, eval = t.clear, t.eq, t.eval -local feed, api, command = t.feed, t.api, t.command +local clear, eq, eval = n.clear, t.eq, n.eval +local feed, api, command = n.feed, n.api, n.command local feed_data = tt.feed_data local is_os = t.is_os local skip = t.skip diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua @@ -1,17 +1,19 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() local tt = require('test.functional.terminal.testutil') -local clear, eq = t.clear, t.eq -local feed, testprg = t.feed, t.testprg -local eval = t.eval -local command = t.command -local poke_eventloop = t.poke_eventloop + +local clear, eq = n.clear, t.eq +local feed, testprg = n.feed, n.testprg +local eval = n.eval +local command = n.command +local poke_eventloop = n.poke_eventloop local retry = t.retry -local api = t.api +local api = n.api local feed_data = tt.feed_data local pcall_err = t.pcall_err -local exec_lua = t.exec_lua -local assert_alive = t.assert_alive +local exec_lua = n.exec_lua +local assert_alive = n.assert_alive local skip = t.skip local is_os = t.is_os diff --git a/test/functional/terminal/testutil.lua b/test/functional/terminal/testutil.lua @@ -1,12 +1,13 @@ -- To test tui/input.c, this module spawns `nvim` inside :terminal and sends -- bytes via jobsend(). Note: the functional/testutil.lua test-session methods -- operate on the _host_ session, _not_ the child session. -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local testprg = t.testprg -local exec_lua = t.exec_lua -local api = t.api -local nvim_prog = t.nvim_prog + +local testprg = n.testprg +local exec_lua = n.exec_lua +local api = n.api +local nvim_prog = n.nvim_prog local function feed_data(data) if type(data) == 'table' then diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua @@ -4,31 +4,33 @@ -- "bracketed paste" terminal feature: -- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode -local t = require('test.functional.testutil')() -local tt = require('test.functional.terminal.testutil') +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local tt = require('test.functional.terminal.testutil') + local eq = t.eq local feed_data = tt.feed_data -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local dedent = t.dedent -local exec = t.exec -local exec_lua = t.exec_lua -local testprg = t.testprg +local exec = n.exec +local exec_lua = n.exec_lua +local testprg = n.testprg local retry = t.retry -local nvim_prog = t.nvim_prog -local nvim_set = t.nvim_set +local nvim_prog = n.nvim_prog +local nvim_set = n.nvim_set local ok = t.ok local read_file = t.read_file -local fn = t.fn -local api = t.api +local fn = n.fn +local api = n.api local is_ci = t.is_ci local is_os = t.is_os -local new_pipename = t.new_pipename -local spawn_argv = t.spawn_argv -local set_session = t.set_session +local new_pipename = n.new_pipename +local spawn_argv = n.spawn_argv +local set_session = n.set_session local write_file = t.write_file -local eval = t.eval +local eval = n.eval local assert_log = t.assert_log local testlog = 'Xtest-tui-log' @@ -64,7 +66,7 @@ describe('TUI', function() | {3:-- TERMINAL --} | ]]) - child_session = t.connect(child_server) + child_session = n.connect(child_server) child_exec_lua = tt.make_lua_executor(child_session) end) @@ -2248,7 +2250,7 @@ describe('TUI FocusGained/FocusLost', function() | {3:-- TERMINAL --} | ]]) - child_session = t.connect(child_server) + child_session = n.connect(child_server) child_session:request( 'nvim_exec2', [[ @@ -2891,7 +2893,7 @@ describe('TUI', function() screen:expect({ any = '%[No Name%]' }) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) retry(nil, 1000, function() eq({ Tc = true, @@ -2937,7 +2939,7 @@ describe('TUI', function() screen:expect({ any = '%[No Name%]' }) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) retry(nil, 1000, function() eq('Ms', eval("get(g:, 'xtgettcap', '')")) eq({ true, 'OSC 52' }, { child_session:request('nvim_eval', 'g:clipboard.name') }) @@ -2965,7 +2967,7 @@ describe('TUI bg color', function() 'set noswapfile', }) screen:expect({ any = '%[No Name%]' }) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) retry(nil, nil, function() eq({ true, 'dark' }, { child_session:request('nvim_eval', '&background') }) end) @@ -2988,7 +2990,7 @@ describe('TUI bg color', function() 'set noswapfile', }) screen:expect({ any = '%[No Name%]' }) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) retry(nil, nil, function() eq({ true, 'light' }, { child_session:request('nvim_eval', '&background') }) end) diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local tt = require('test.functional.terminal.testutil') local feed_data = tt.feed_data -local feed, clear = t.feed, t.clear -local poke_eventloop = t.poke_eventloop -local command = t.command +local feed, clear = n.feed, n.clear +local poke_eventloop = n.poke_eventloop +local command = n.command local retry = t.retry local eq = t.eq -local eval = t.eval +local eval = n.eval local skip = t.skip local is_os = t.is_os diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local tt = require('test.functional.terminal.testutil') -local assert_alive = t.assert_alive -local clear = t.clear -local feed = t.feed -local feed_command = t.feed_command -local command = t.command +local assert_alive = n.assert_alive +local clear = n.clear +local feed = n.feed +local feed_command = n.feed_command +local command = n.command local eq = t.eq -local eval = t.eval -local api = t.api +local eval = n.eval +local api = n.api local sleep = vim.uv.sleep local retry = t.retry local is_os = t.is_os diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua @@ -0,0 +1,1013 @@ +local uv = vim.uv +local t = require('test.testutil') + +local Session = require('test.client.session') +local uv_stream = require('test.client.uv_stream') +local SocketStream = uv_stream.SocketStream +local ChildProcessStream = uv_stream.ChildProcessStream + +local check_cores = t.check_cores +local check_logs = t.check_logs +local dedent = t.dedent +local eq = t.eq +local is_os = t.is_os +local ok = t.ok +local sleep = uv.sleep + +--- This module uses functions from the context of the test session, i.e. in the context of the +--- nvim being tests. +local M = {} + +local runtime_set = 'set runtimepath^=./build/lib/nvim/' +M.nvim_prog = (os.getenv('NVIM_PRG') or t.paths.test_build_dir .. '/bin/nvim') +-- Default settings for the test session. +M.nvim_set = ( + 'set shortmess+=IS background=light termguicolors noswapfile noautoindent startofline' + .. ' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' + .. ' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid' +) +M.nvim_argv = { + M.nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + -- XXX: find treesitter parsers. + '--cmd', + runtime_set, + '--cmd', + M.nvim_set, + -- Remove default user commands and mappings. + '--cmd', + 'comclear | mapclear | mapclear!', + -- Make screentest work after changing to the new default color scheme + -- Source 'vim' color scheme without side effects + -- TODO: rewrite tests + '--cmd', + 'lua dofile("runtime/colors/vim.lua")', + '--cmd', + 'unlet g:colors_name', + '--embed', +} + +-- Directory containing nvim. +M.nvim_dir = M.nvim_prog:gsub('[/\\][^/\\]+$', '') +if M.nvim_dir == M.nvim_prog then + M.nvim_dir = '.' +end + +local prepend_argv --- @type string[]? + +if os.getenv('VALGRIND') then + local log_file = os.getenv('VALGRIND_LOG') or 'valgrind-%p.log' + prepend_argv = { + 'valgrind', + '-q', + '--tool=memcheck', + '--leak-check=yes', + '--track-origins=yes', + '--show-possibly-lost=no', + '--suppressions=src/.valgrind.supp', + '--log-file=' .. log_file, + } + if os.getenv('GDB') then + table.insert(prepend_argv, '--vgdb=yes') + table.insert(prepend_argv, '--vgdb-error=0') + end +elseif os.getenv('GDB') then + local gdbserver_port = os.getenv('GDBSERVER_PORT') or '7777' + prepend_argv = { 'gdbserver', 'localhost:' .. gdbserver_port } +end + +if prepend_argv then + local new_nvim_argv = {} --- @type string[] + local len = #prepend_argv + for i = 1, len do + new_nvim_argv[i] = prepend_argv[i] + end + for i = 1, #M.nvim_argv do + new_nvim_argv[i + len] = M.nvim_argv[i] + end + M.nvim_argv = new_nvim_argv + M.prepend_argv = prepend_argv +end + +local session --- @type test.Session? +local loop_running --- @type boolean? +local last_error --- @type string? +local method_error --- @type string? + +if not is_os('win') then + local sigpipe_handler = assert(uv.new_signal()) + uv.signal_start(sigpipe_handler, 'sigpipe', function() + print('warning: got SIGPIPE signal. Likely related to a crash in nvim') + end) +end + +function M.get_session() + return session +end + +function M.set_session(s) + session = s +end + +--- @param method string +--- @param ... any +--- @return any +function M.request(method, ...) + assert(session) + local status, rv = session:request(method, ...) + if not status then + if loop_running then + --- @type string + last_error = rv[2] + session:stop() + else + error(rv[2]) + end + end + return rv +end + +--- @param method string +--- @param ... any +--- @return any +function M.request_lua(method, ...) + return M.exec_lua([[return vim.api[...](select(2, ...))]], method, ...) +end + +--- @param timeout? integer +--- @return string? +function M.next_msg(timeout) + assert(session) + return session:next_message(timeout or 10000) +end + +function M.expect_twostreams(msgs1, msgs2) + local pos1, pos2 = 1, 1 + while pos1 <= #msgs1 or pos2 <= #msgs2 do + local msg = M.next_msg() + if pos1 <= #msgs1 and pcall(eq, msgs1[pos1], msg) then + pos1 = pos1 + 1 + elseif pos2 <= #msgs2 then + eq(msgs2[pos2], msg) + pos2 = pos2 + 1 + else + -- already failed, but show the right error message + eq(msgs1[pos1], msg) + end + end +end + +-- Expects a sequence of next_msg() results. If multiple sequences are +-- passed they are tried until one succeeds, in order of shortest to longest. +-- +-- Can be called with positional args (list of sequences only): +-- expect_msg_seq(seq1, seq2, ...) +-- or keyword args: +-- expect_msg_seq{ignore={...}, seqs={seq1, seq2, ...}} +-- +-- ignore: List of ignored event names. +-- seqs: List of one or more potential event sequences. +function M.expect_msg_seq(...) + if select('#', ...) < 1 then + error('need at least 1 argument') + end + local arg1 = select(1, ...) + if (arg1['seqs'] and select('#', ...) > 1) or type(arg1) ~= 'table' then + error('invalid args') + end + local ignore = arg1['ignore'] and arg1['ignore'] or {} + --- @type string[] + local seqs = arg1['seqs'] and arg1['seqs'] or { ... } + if type(ignore) ~= 'table' then + error("'ignore' arg must be a list of strings") + end + table.sort(seqs, function(a, b) -- Sort ascending, by (shallow) length. + return #a < #b + end) + + local actual_seq = {} + local nr_ignored = 0 + local final_error = '' + local function cat_err(err1, err2) + if err1 == nil then + return err2 + end + return string.format('%s\n%s\n%s', err1, string.rep('=', 78), err2) + end + local msg_timeout = M.load_adjust(10000) -- Big timeout for ASAN/valgrind. + for anum = 1, #seqs do + local expected_seq = seqs[anum] + -- Collect enough messages to compare the next expected sequence. + while #actual_seq < #expected_seq do + local msg = M.next_msg(msg_timeout) + local msg_type = msg and msg[2] or nil + if msg == nil then + error( + cat_err( + final_error, + string.format( + 'got %d messages (ignored %d), expected %d', + #actual_seq, + nr_ignored, + #expected_seq + ) + ) + ) + elseif vim.tbl_contains(ignore, msg_type) then + nr_ignored = nr_ignored + 1 + else + table.insert(actual_seq, msg) + end + end + local status, result = pcall(eq, expected_seq, actual_seq) + if status then + return result + end + local message = result + if type(result) == 'table' then + -- 'eq' returns several things + --- @type string + message = result.message + end + final_error = cat_err(final_error, message) + end + error(final_error) +end + +local function call_and_stop_on_error(lsession, ...) + local status, result = Session.safe_pcall(...) -- luacheck: ignore + if not status then + lsession:stop() + last_error = result + return '' + end + return result +end + +function M.set_method_error(err) + method_error = err +end + +--- @param lsession test.Session +--- @param request_cb function? +--- @param notification_cb function? +--- @param setup_cb function? +--- @param timeout integer +--- @return {[1]: integer, [2]: string} +function M.run_session(lsession, request_cb, notification_cb, setup_cb, timeout) + local on_request --- @type function? + local on_notification --- @type function? + local on_setup --- @type function? + + if request_cb then + function on_request(method, args) + method_error = nil + local result = call_and_stop_on_error(lsession, request_cb, method, args) + if method_error ~= nil then + return method_error, true + end + return result + end + end + + if notification_cb then + function on_notification(method, args) + call_and_stop_on_error(lsession, notification_cb, method, args) + end + end + + if setup_cb then + function on_setup() + call_and_stop_on_error(lsession, setup_cb) + end + end + + loop_running = true + lsession:run(on_request, on_notification, on_setup, timeout) + loop_running = false + if last_error then + local err = last_error + last_error = nil + error(err) + end + + return lsession.eof_err +end + +function M.run(request_cb, notification_cb, setup_cb, timeout) + assert(session) + return M.run_session(session, request_cb, notification_cb, setup_cb, timeout) +end + +function M.stop() + assert(session):stop() +end + +function M.nvim_prog_abs() + -- system(['build/bin/nvim']) does not work for whatever reason. It must + -- be executable searched in $PATH or something starting with / or ./. + if M.nvim_prog:match('[/\\]') then + return M.request('nvim_call_function', 'fnamemodify', { M.nvim_prog, ':p' }) + else + return M.nvim_prog + end +end + +-- Use for commands which expect nvim to quit. +-- The first argument can also be a timeout. +function M.expect_exit(fn_or_timeout, ...) + local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.' + if type(fn_or_timeout) == 'function' then + eq(eof_err_msg, t.pcall_err(fn_or_timeout, ...)) + else + eq( + eof_err_msg, + t.pcall_err(function(timeout, fn, ...) + fn(...) + assert(session) + while session:next_message(timeout) do + end + if session.eof_err then + error(session.eof_err[2]) + end + end, fn_or_timeout, ...) + ) + end +end + +--- Executes a Vimscript function via Lua. +--- Fails on Vimscript error, but does not update v:errmsg. +--- @param name string +--- @param ... any +--- @return any +function M.call_lua(name, ...) + return M.exec_lua([[return vim.call(...)]], name, ...) +end + +--- Sends user input to Nvim. +--- Does not fail on Vimscript error, but v:errmsg will be updated. +--- @param input string +local function nvim_feed(input) + while #input > 0 do + local written = M.request('nvim_input', input) + if written == nil then + M.assert_alive() + error('crash? (nvim_input returned nil)') + end + input = input:sub(written + 1) + end +end + +--- @param ... string +function M.feed(...) + for _, v in ipairs({ ... }) do + nvim_feed(dedent(v)) + end +end + +---@param ... string[]? +---@return string[] +function M.merge_args(...) + local i = 1 + local argv = {} --- @type string[] + for anum = 1, select('#', ...) do + --- @type string[]? + local args = select(anum, ...) + if args then + for _, arg in ipairs(args) do + argv[i] = arg + i = i + 1 + end + end + end + return argv +end + +--- Removes Nvim startup args from `args` matching items in `args_rm`. +--- +--- - Special case: "-u", "-i", "--cmd" are treated specially: their "values" are also removed. +--- - Special case: "runtimepath" will remove only { '--cmd', 'set runtimepath^=…', } +--- +--- Example: +--- args={'--headless', '-u', 'NONE'} +--- args_rm={'--cmd', '-u'} +--- Result: +--- {'--headless'} +--- +--- All matching cases are removed. +--- +--- Example: +--- args={'--cmd', 'foo', '-N', '--cmd', 'bar'} +--- args_rm={'--cmd', '-u'} +--- Result: +--- {'-N'} +--- @param args string[] +--- @param args_rm string[] +--- @return string[] +local function remove_args(args, args_rm) + local new_args = {} --- @type string[] + local skip_following = { '-u', '-i', '-c', '--cmd', '-s', '--listen' } + if not args_rm or #args_rm == 0 then + return { unpack(args) } + end + for _, v in ipairs(args_rm) do + assert(type(v) == 'string') + end + local last = '' + for _, arg in ipairs(args) do + if vim.tbl_contains(skip_following, last) then + last = '' + elseif vim.tbl_contains(args_rm, arg) then + last = arg + elseif arg == runtime_set and vim.tbl_contains(args_rm, 'runtimepath') then + table.remove(new_args) -- Remove the preceding "--cmd". + last = '' + else + table.insert(new_args, arg) + end + end + return new_args +end + +function M.check_close() + if not session then + return + end + local start_time = uv.now() + session:close() + uv.update_time() -- Update cached value of luv.now() (libuv: uv_now()). + local end_time = uv.now() + local delta = end_time - start_time + if delta > 500 then + print( + 'nvim took ' + .. delta + .. ' milliseconds to exit after last test\n' + .. 'This indicates a likely problem with the test even if it passed!\n' + ) + io.stdout:flush() + end + session = nil +end + +--- @param argv string[] +--- @param merge boolean? +--- @param env string[]? +--- @param keep boolean +--- @param io_extra uv.uv_pipe_t? used for stdin_fd, see :help ui-option +--- @return test.Session +function M.spawn(argv, merge, env, keep, io_extra) + if not keep then + M.check_close() + end + + local child_stream = + ChildProcessStream.spawn(merge and M.merge_args(prepend_argv, argv) or argv, env, io_extra) + return Session.new(child_stream) +end + +-- Creates a new Session connected by domain socket (named pipe) or TCP. +function M.connect(file_or_address) + local addr, port = string.match(file_or_address, '(.*):(%d+)') + local stream = (addr and port) and SocketStream.connect(addr, port) + or SocketStream.open(file_or_address) + return Session.new(stream) +end + +-- Starts (and returns) a new global Nvim session. +-- +-- Parameters are interpreted as startup args, OR a map with these keys: +-- args: List: Args appended to the default `nvim_argv` set. +-- args_rm: List: Args removed from the default set. All cases are +-- removed, e.g. args_rm={'--cmd'} removes all cases of "--cmd" +-- (and its value) from the default set. +-- env: Map: Defines the environment of the new session. +-- +-- Example: +-- clear('-e') +-- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}} +function M.clear(...) + M.set_session(M.spawn_argv(false, ...)) + return M.get_session() +end + +--- same params as clear, but does returns the session instead +--- of replacing the default session +--- @return test.Session +function M.spawn_argv(keep, ...) + local argv, env, io_extra = M.new_argv(...) + return M.spawn(argv, nil, env, keep, io_extra) +end + +--- @class test.new_argv.Opts +--- @field args? string[] +--- @field args_rm? string[] +--- @field env? table<string,string> +--- @field io_extra? uv.uv_pipe_t + +--- Builds an argument list for use in clear(). +--- +--- @see clear() for parameters. +--- @param ... string +--- @return string[] +--- @return string[]? +--- @return uv.uv_pipe_t? +function M.new_argv(...) + local args = { unpack(M.nvim_argv) } + table.insert(args, '--headless') + if _G._nvim_test_id then + -- Set the server name to the test-id for logging. #8519 + table.insert(args, '--listen') + table.insert(args, _G._nvim_test_id) + end + local new_args --- @type string[] + local io_extra --- @type uv.uv_pipe_t? + local env --- @type string[]? + --- @type test.new_argv.Opts|string + local opts = select(1, ...) + if type(opts) ~= 'table' then + new_args = { ... } + else + args = remove_args(args, opts.args_rm) + if opts.env then + local env_opt = {} --- @type table<string,string> + for k, v in pairs(opts.env) do + assert(type(k) == 'string') + assert(type(v) == 'string') + env_opt[k] = v + end + for _, k in ipairs({ + 'HOME', + 'ASAN_OPTIONS', + 'TSAN_OPTIONS', + 'MSAN_OPTIONS', + 'LD_LIBRARY_PATH', + 'PATH', + 'NVIM_LOG_FILE', + 'NVIM_RPLUGIN_MANIFEST', + 'GCOV_ERROR_FILE', + 'XDG_DATA_DIRS', + 'TMPDIR', + 'VIMRUNTIME', + }) do + -- Set these from the environment unless the caller defined them. + if not env_opt[k] then + env_opt[k] = os.getenv(k) + end + end + env = {} + for k, v in pairs(env_opt) do + env[#env + 1] = k .. '=' .. v + end + end + new_args = opts.args or {} + io_extra = opts.io_extra + end + for _, arg in ipairs(new_args) do + table.insert(args, arg) + end + return args, env, io_extra +end + +--- @param ... string +function M.insert(...) + nvim_feed('i') + for _, v in ipairs({ ... }) do + local escaped = v:gsub('<', '<lt>') + M.feed(escaped) + end + nvim_feed('<ESC>') +end + +--- Executes an ex-command by user input. Because nvim_input() is used, Vimscript +--- errors will not manifest as client (lua) errors. Use command() for that. +--- @param ... string +function M.feed_command(...) + for _, v in ipairs({ ... }) do + if v:sub(1, 1) ~= '/' then + -- not a search command, prefix with colon + nvim_feed(':') + end + nvim_feed(v:gsub('<', '<lt>')) + nvim_feed('<CR>') + end +end + +-- @deprecated use nvim_exec2() +function M.source(code) + M.exec(dedent(code)) +end + +function M.has_powershell() + return M.eval('executable("' .. (is_os('win') and 'powershell' or 'pwsh') .. '")') == 1 +end + +--- Sets Nvim shell to powershell. +--- +--- @param fake (boolean) If true, a fake will be used if powershell is not +--- found on the system. +--- @returns true if powershell was found on the system, else false. +function M.set_shell_powershell(fake) + local found = M.has_powershell() + if not fake then + assert(found) + end + local shell = found and (is_os('win') and 'powershell' or 'pwsh') or M.testprg('pwsh-test') + local cmd = 'Remove-Item -Force ' + .. table.concat( + is_os('win') and { 'alias:cat', 'alias:echo', 'alias:sleep', 'alias:sort', 'alias:tee' } + or { 'alias:echo' }, + ',' + ) + .. ';' + M.exec([[ + let &shell = ']] .. shell .. [[' + set shellquote= shellxquote= + let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ' + let &shellcmdflag .= '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();' + let &shellcmdflag .= '$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';' + let &shellcmdflag .= ']] .. cmd .. [[' + let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' + let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' + ]]) + return found +end + +---@param func function +---@return table<string,function> +function M.create_callindex(func) + return setmetatable({}, { + --- @param tbl table<any,function> + --- @param arg1 string + --- @return function + __index = function(tbl, arg1) + local ret = function(...) + return func(arg1, ...) + end + tbl[arg1] = ret + return ret + end, + }) +end + +--- @param method string +--- @param ... any +function M.nvim_async(method, ...) + assert(session):notify(method, ...) +end + +--- Executes a Vimscript function via RPC. +--- Fails on Vimscript error, but does not update v:errmsg. +--- @param name string +--- @param ... any +--- @return any +function M.call(name, ...) + return M.request('nvim_call_function', name, { ... }) +end + +M.async_meths = M.create_callindex(M.nvim_async) + +M.rpc = { + fn = M.create_callindex(M.call), + api = M.create_callindex(M.request), +} + +M.lua = { + fn = M.create_callindex(M.call_lua), + api = M.create_callindex(M.request_lua), +} + +M.describe_lua_and_rpc = function(describe) + return function(what, tests) + local function d(flavour) + describe(string.format('%s (%s)', what, flavour), function(...) + return tests(M[flavour].api, ...) + end) + end + + d('rpc') + d('lua') + end +end + +--- add for typing. The for loop after will overwrite this +M.api = vim.api +M.fn = vim.fn + +for name, fns in pairs(M.rpc) do + --- @diagnostic disable-next-line:no-unknown + M[name] = fns +end + +-- Executes an ex-command. Vimscript errors manifest as client (lua) errors, but +-- v:errmsg will not be updated. +M.command = M.api.nvim_command + +-- Evaluates a Vimscript expression. +-- Fails on Vimscript error, but does not update v:errmsg. +M.eval = M.api.nvim_eval + +function M.poke_eventloop() + -- Execute 'nvim_eval' (a deferred function) to + -- force at least one main_loop iteration + M.api.nvim_eval('1') +end + +function M.buf_lines(bufnr) + return M.exec_lua('return vim.api.nvim_buf_get_lines((...), 0, -1, false)', bufnr) +end + +---@see buf_lines() +function M.curbuf_contents() + M.poke_eventloop() -- Before inspecting the buffer, do whatever. + return table.concat(M.api.nvim_buf_get_lines(0, 0, -1, true), '\n') +end + +function M.expect(contents) + return eq(dedent(contents), M.curbuf_contents()) +end + +function M.expect_any(contents) + contents = dedent(contents) + return ok(nil ~= string.find(M.curbuf_contents(), contents, 1, true)) +end + +-- Checks that the Nvim session did not terminate. +function M.assert_alive() + assert(2 == M.eval('1+1'), 'crash? request failed') +end + +-- Asserts that buffer is loaded and visible in the current tabpage. +function M.assert_visible(bufnr, visible) + assert(type(visible) == 'boolean') + eq(visible, M.api.nvim_buf_is_loaded(bufnr)) + if visible then + assert( + -1 ~= M.fn.bufwinnr(bufnr), + 'expected buffer to be visible in current tabpage: ' .. tostring(bufnr) + ) + else + assert( + -1 == M.fn.bufwinnr(bufnr), + 'expected buffer NOT visible in current tabpage: ' .. tostring(bufnr) + ) + end +end + +--- @param path string +local function do_rmdir(path) + local stat = uv.fs_stat(path) + if stat == nil then + return + end + if stat.type ~= 'directory' then + error(string.format('rmdir: not a directory: %s', path)) + end + for file in vim.fs.dir(path) do + if file ~= '.' and file ~= '..' then + local abspath = path .. '/' .. file + if t.isdir(abspath) then + do_rmdir(abspath) -- recurse + else + local ret, err = os.remove(abspath) + if not ret then + if not session then + error('os.remove: ' .. err) + else + -- Try Nvim delete(): it handles `readonly` attribute on Windows, + -- and avoids Lua cross-version/platform incompatibilities. + if -1 == M.call('delete', abspath) then + local hint = (is_os('win') and ' (hint: try :%bwipeout! before rmdir())' or '') + error('delete() failed' .. hint .. ': ' .. abspath) + end + end + end + end + end + end + local ret, err = uv.fs_rmdir(path) + if not ret then + error('luv.fs_rmdir(' .. path .. '): ' .. err) + end +end + +local start_dir = uv.cwd() + +function M.rmdir(path) + local ret, _ = pcall(do_rmdir, path) + if not ret and is_os('win') then + -- Maybe "Permission denied"; try again after changing the nvim + -- process to the top-level directory. + M.command([[exe 'cd '.fnameescape(']] .. start_dir .. "')") + ret, _ = pcall(do_rmdir, path) + end + -- During teardown, the nvim process may not exit quickly enough, then rmdir() + -- will fail (on Windows). + if not ret then -- Try again. + sleep(1000) + do_rmdir(path) + end +end + +function M.exc_exec(cmd) + M.command(([[ + try + execute "%s" + catch + let g:__exception = v:exception + endtry + ]]):format(cmd:gsub('\n', '\\n'):gsub('[\\"]', '\\%0'))) + local ret = M.eval('get(g:, "__exception", 0)') + M.command('unlet! g:__exception') + return ret +end + +function M.exec(code) + M.api.nvim_exec2(code, {}) +end + +--- @param code string +--- @return string +function M.exec_capture(code) + return M.api.nvim_exec2(code, { output = true }).output +end + +--- @param code string +--- @return any +function M.exec_lua(code, ...) + return M.api.nvim_exec_lua(code, { ... }) +end + +function M.get_pathsep() + return is_os('win') and '\\' or '/' +end + +--- Gets the filesystem root dir, namely "/" or "C:/". +function M.pathroot() + local pathsep = package.config:sub(1, 1) + return is_os('win') and (M.nvim_dir:sub(1, 2) .. pathsep) or '/' +end + +--- Gets the full `…/build/bin/{name}` path of a test program produced by +--- `test/functional/fixtures/CMakeLists.txt`. +--- +--- @param name (string) Name of the test program. +function M.testprg(name) + local ext = is_os('win') and '.exe' or '' + return ('%s/%s%s'):format(M.nvim_dir, name, ext) +end + +function M.is_asan() + local version = M.eval('execute("verbose version")') + return version:match('-fsanitize=[a-z,]*address') +end + +-- Returns a valid, platform-independent Nvim listen address. +-- Useful for communicating with child instances. +function M.new_pipename() + -- HACK: Start a server temporarily, get the name, then stop it. + local pipename = M.eval('serverstart()') + M.fn.serverstop(pipename) + -- Remove the pipe so that trying to connect to it without a server listening + -- will be an error instead of a hang. + os.remove(pipename) + return pipename +end + +--- @param provider string +--- @return string|boolean? +function M.missing_provider(provider) + if provider == 'ruby' or provider == 'perl' then + --- @type string? + local e = M.exec_lua("return {require('vim.provider." .. provider .. "').detect()}")[2] + return e ~= '' and e or false + elseif provider == 'node' then + --- @type string? + local e = M.fn['provider#node#Detect']()[2] + return e ~= '' and e or false + elseif provider == 'python' then + return M.exec_lua([[return {require('vim.provider.python').detect_by_module('neovim')}]])[2] + end + assert(false, 'Unknown provider: ' .. provider) +end + +--- @param obj string|table +--- @return any +function M.alter_slashes(obj) + if not is_os('win') then + return obj + end + if type(obj) == 'string' then + local ret = obj:gsub('/', '\\') + return ret + elseif type(obj) == 'table' then + --- @cast obj table<any,any> + local ret = {} --- @type table<any,any> + for k, v in pairs(obj) do + ret[k] = M.alter_slashes(v) + end + return ret + end + assert(false, 'expected string or table of strings, got ' .. type(obj)) +end + +local load_factor = 1 +if t.is_ci() then + -- Compute load factor only once (but outside of any tests). + M.clear() + M.request('nvim_command', 'source test/old/testdir/load.vim') + load_factor = M.request('nvim_eval', 'g:test_load_factor') +end + +--- @param num number +--- @return number +function M.load_adjust(num) + return math.ceil(num * load_factor) +end + +--- @param ctx table<string,any> +--- @return table +function M.parse_context(ctx) + local parsed = {} --- @type table<string,any> + for _, item in ipairs({ 'regs', 'jumps', 'bufs', 'gvars' }) do + --- @param v any + parsed[item] = vim.tbl_filter(function(v) + return type(v) == 'table' + end, M.call('msgpackparse', ctx[item])) + end + parsed['bufs'] = parsed['bufs'][1] + --- @param v any + return vim.tbl_map(function(v) + if #v == 0 then + return nil + end + return v + end, parsed) +end + +function M.add_builddir_to_rtp() + -- Add runtime from build dir for doc/tags (used with :help). + M.command(string.format([[set rtp+=%s/runtime]], t.paths.test_build_dir)) +end + +--- Kill (reap) a process by PID. +--- @param pid string +--- @return boolean? +function M.os_kill(pid) + return os.execute( + ( + is_os('win') and 'taskkill /f /t /pid ' .. pid .. ' > nul' + or 'kill -9 ' .. pid .. ' > /dev/null' + ) + ) +end + +--- Create folder with non existing parents +--- @param path string +--- @return boolean? +function M.mkdir_p(path) + return os.execute((is_os('win') and 'mkdir ' .. path or 'mkdir -p ' .. path)) +end + +local testid = (function() + local id = 0 + return function() + id = id + 1 + return id + end +end)() + +return function() + local g = getfenv(2) + + --- @type function? + local before_each = g.before_each + --- @type function? + local after_each = g.after_each + + if before_each then + before_each(function() + local id = ('T%d'):format(testid()) + _G._nvim_test_id = id + end) + end + + if after_each then + after_each(function() + check_logs() + check_cores('build/bin/nvim') + if session then + local msg = session:next_message(0) + if msg then + if msg[1] == 'notification' and msg[2] == 'nvim_error_event' then + error(msg[3][2]) + end + end + end + end) + end + return M +end diff --git a/test/functional/testutil.lua b/test/functional/testutil.lua @@ -1,1063 +0,0 @@ -local uv = vim.uv -local t_global = require('test.testutil') - -local Session = require('test.client.session') -local uv_stream = require('test.client.uv_stream') -local SocketStream = uv_stream.SocketStream -local ChildProcessStream = uv_stream.ChildProcessStream - -local check_cores = t_global.check_cores -local check_logs = t_global.check_logs -local dedent = t_global.dedent -local eq = t_global.eq -local is_os = t_global.is_os -local ok = t_global.ok -local sleep = uv.sleep -local fail = t_global.fail - ---- @class test.functional.testutil: test.testutil -local M = vim.deepcopy(t_global) - -local runtime_set = 'set runtimepath^=./build/lib/nvim/' -M.nvim_prog = (os.getenv('NVIM_PRG') or t_global.paths.test_build_dir .. '/bin/nvim') --- Default settings for the test session. -M.nvim_set = ( - 'set shortmess+=IS background=light termguicolors noswapfile noautoindent startofline' - .. ' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' - .. ' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid' -) -M.nvim_argv = { - M.nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - -- XXX: find treesitter parsers. - '--cmd', - runtime_set, - '--cmd', - M.nvim_set, - -- Remove default user commands and mappings. - '--cmd', - 'comclear | mapclear | mapclear!', - -- Make screentest work after changing to the new default color scheme - -- Source 'vim' color scheme without side effects - -- TODO: rewrite tests - '--cmd', - 'lua dofile("runtime/colors/vim.lua")', - '--cmd', - 'unlet g:colors_name', - '--embed', -} - --- Directory containing nvim. -M.nvim_dir = M.nvim_prog:gsub('[/\\][^/\\]+$', '') -if M.nvim_dir == M.nvim_prog then - M.nvim_dir = '.' -end - -local prepend_argv --- @type string[]? - -if os.getenv('VALGRIND') then - local log_file = os.getenv('VALGRIND_LOG') or 'valgrind-%p.log' - prepend_argv = { - 'valgrind', - '-q', - '--tool=memcheck', - '--leak-check=yes', - '--track-origins=yes', - '--show-possibly-lost=no', - '--suppressions=src/.valgrind.supp', - '--log-file=' .. log_file, - } - if os.getenv('GDB') then - table.insert(prepend_argv, '--vgdb=yes') - table.insert(prepend_argv, '--vgdb-error=0') - end -elseif os.getenv('GDB') then - local gdbserver_port = os.getenv('GDBSERVER_PORT') or '7777' - prepend_argv = { 'gdbserver', 'localhost:' .. gdbserver_port } -end - -if prepend_argv then - local new_nvim_argv = {} --- @type string[] - local len = #prepend_argv - for i = 1, len do - new_nvim_argv[i] = prepend_argv[i] - end - for i = 1, #M.nvim_argv do - new_nvim_argv[i + len] = M.nvim_argv[i] - end - M.nvim_argv = new_nvim_argv - M.prepend_argv = prepend_argv -end - -local session --- @type test.Session? -local loop_running --- @type boolean? -local last_error --- @type string? -local method_error --- @type string? - -if not is_os('win') then - local sigpipe_handler = assert(uv.new_signal()) - uv.signal_start(sigpipe_handler, 'sigpipe', function() - print('warning: got SIGPIPE signal. Likely related to a crash in nvim') - end) -end - -function M.get_session() - return session -end - -function M.set_session(s) - session = s -end - ---- @param method string ---- @param ... any ---- @return any -function M.request(method, ...) - assert(session) - local status, rv = session:request(method, ...) - if not status then - if loop_running then - --- @type string - last_error = rv[2] - session:stop() - else - error(rv[2]) - end - end - return rv -end - ---- @param method string ---- @param ... any ---- @return any -function M.request_lua(method, ...) - return M.exec_lua([[return vim.api[...](select(2, ...))]], method, ...) -end - ---- @param timeout? integer ---- @return string? -function M.next_msg(timeout) - assert(session) - return session:next_message(timeout or 10000) -end - -function M.expect_twostreams(msgs1, msgs2) - local pos1, pos2 = 1, 1 - while pos1 <= #msgs1 or pos2 <= #msgs2 do - local msg = M.next_msg() - if pos1 <= #msgs1 and pcall(eq, msgs1[pos1], msg) then - pos1 = pos1 + 1 - elseif pos2 <= #msgs2 then - eq(msgs2[pos2], msg) - pos2 = pos2 + 1 - else - -- already failed, but show the right error message - eq(msgs1[pos1], msg) - end - end -end - --- Expects a sequence of next_msg() results. If multiple sequences are --- passed they are tried until one succeeds, in order of shortest to longest. --- --- Can be called with positional args (list of sequences only): --- expect_msg_seq(seq1, seq2, ...) --- or keyword args: --- expect_msg_seq{ignore={...}, seqs={seq1, seq2, ...}} --- --- ignore: List of ignored event names. --- seqs: List of one or more potential event sequences. -function M.expect_msg_seq(...) - if select('#', ...) < 1 then - error('need at least 1 argument') - end - local arg1 = select(1, ...) - if (arg1['seqs'] and select('#', ...) > 1) or type(arg1) ~= 'table' then - error('invalid args') - end - local ignore = arg1['ignore'] and arg1['ignore'] or {} - --- @type string[] - local seqs = arg1['seqs'] and arg1['seqs'] or { ... } - if type(ignore) ~= 'table' then - error("'ignore' arg must be a list of strings") - end - table.sort(seqs, function(a, b) -- Sort ascending, by (shallow) length. - return #a < #b - end) - - local actual_seq = {} - local nr_ignored = 0 - local final_error = '' - local function cat_err(err1, err2) - if err1 == nil then - return err2 - end - return string.format('%s\n%s\n%s', err1, string.rep('=', 78), err2) - end - local msg_timeout = M.load_adjust(10000) -- Big timeout for ASAN/valgrind. - for anum = 1, #seqs do - local expected_seq = seqs[anum] - -- Collect enough messages to compare the next expected sequence. - while #actual_seq < #expected_seq do - local msg = M.next_msg(msg_timeout) - local msg_type = msg and msg[2] or nil - if msg == nil then - error( - cat_err( - final_error, - string.format( - 'got %d messages (ignored %d), expected %d', - #actual_seq, - nr_ignored, - #expected_seq - ) - ) - ) - elseif vim.tbl_contains(ignore, msg_type) then - nr_ignored = nr_ignored + 1 - else - table.insert(actual_seq, msg) - end - end - local status, result = pcall(eq, expected_seq, actual_seq) - if status then - return result - end - local message = result - if type(result) == 'table' then - -- 'eq' returns several things - --- @type string - message = result.message - end - final_error = cat_err(final_error, message) - end - error(final_error) -end - -local function call_and_stop_on_error(lsession, ...) - local status, result = Session.safe_pcall(...) -- luacheck: ignore - if not status then - lsession:stop() - last_error = result - return '' - end - return result -end - -function M.set_method_error(err) - method_error = err -end - ---- @param lsession test.Session ---- @param request_cb function? ---- @param notification_cb function? ---- @param setup_cb function? ---- @param timeout integer ---- @return {[1]: integer, [2]: string} -function M.run_session(lsession, request_cb, notification_cb, setup_cb, timeout) - local on_request --- @type function? - local on_notification --- @type function? - local on_setup --- @type function? - - if request_cb then - function on_request(method, args) - method_error = nil - local result = call_and_stop_on_error(lsession, request_cb, method, args) - if method_error ~= nil then - return method_error, true - end - return result - end - end - - if notification_cb then - function on_notification(method, args) - call_and_stop_on_error(lsession, notification_cb, method, args) - end - end - - if setup_cb then - function on_setup() - call_and_stop_on_error(lsession, setup_cb) - end - end - - loop_running = true - lsession:run(on_request, on_notification, on_setup, timeout) - loop_running = false - if last_error then - local err = last_error - last_error = nil - error(err) - end - - return lsession.eof_err -end - -function M.run(request_cb, notification_cb, setup_cb, timeout) - assert(session) - return M.run_session(session, request_cb, notification_cb, setup_cb, timeout) -end - -function M.stop() - assert(session):stop() -end - -function M.nvim_prog_abs() - -- system(['build/bin/nvim']) does not work for whatever reason. It must - -- be executable searched in $PATH or something starting with / or ./. - if M.nvim_prog:match('[/\\]') then - return M.request('nvim_call_function', 'fnamemodify', { M.nvim_prog, ':p' }) - else - return M.nvim_prog - end -end - --- Use for commands which expect nvim to quit. --- The first argument can also be a timeout. -function M.expect_exit(fn_or_timeout, ...) - local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.' - if type(fn_or_timeout) == 'function' then - eq(eof_err_msg, M.pcall_err(fn_or_timeout, ...)) - else - eq( - eof_err_msg, - M.pcall_err(function(timeout, fn, ...) - fn(...) - assert(session) - while session:next_message(timeout) do - end - if session.eof_err then - error(session.eof_err[2]) - end - end, fn_or_timeout, ...) - ) - end -end - ---- Executes a Vimscript function via Lua. ---- Fails on Vimscript error, but does not update v:errmsg. ---- @param name string ---- @param ... any ---- @return any -function M.call_lua(name, ...) - return M.exec_lua([[return vim.call(...)]], name, ...) -end - ---- Sends user input to Nvim. ---- Does not fail on Vimscript error, but v:errmsg will be updated. ---- @param input string -local function nvim_feed(input) - while #input > 0 do - local written = M.request('nvim_input', input) - if written == nil then - M.assert_alive() - error('crash? (nvim_input returned nil)') - end - input = input:sub(written + 1) - end -end - ---- @param ... string -function M.feed(...) - for _, v in ipairs({ ... }) do - nvim_feed(dedent(v)) - end -end - ----@param ... string[]? ----@return string[] -function M.merge_args(...) - local i = 1 - local argv = {} --- @type string[] - for anum = 1, select('#', ...) do - --- @type string[]? - local args = select(anum, ...) - if args then - for _, arg in ipairs(args) do - argv[i] = arg - i = i + 1 - end - end - end - return argv -end - ---- Removes Nvim startup args from `args` matching items in `args_rm`. ---- ---- - Special case: "-u", "-i", "--cmd" are treated specially: their "values" are also removed. ---- - Special case: "runtimepath" will remove only { '--cmd', 'set runtimepath^=…', } ---- ---- Example: ---- args={'--headless', '-u', 'NONE'} ---- args_rm={'--cmd', '-u'} ---- Result: ---- {'--headless'} ---- ---- All matching cases are removed. ---- ---- Example: ---- args={'--cmd', 'foo', '-N', '--cmd', 'bar'} ---- args_rm={'--cmd', '-u'} ---- Result: ---- {'-N'} ---- @param args string[] ---- @param args_rm string[] ---- @return string[] -local function remove_args(args, args_rm) - local new_args = {} --- @type string[] - local skip_following = { '-u', '-i', '-c', '--cmd', '-s', '--listen' } - if not args_rm or #args_rm == 0 then - return { unpack(args) } - end - for _, v in ipairs(args_rm) do - assert(type(v) == 'string') - end - local last = '' - for _, arg in ipairs(args) do - if vim.tbl_contains(skip_following, last) then - last = '' - elseif vim.tbl_contains(args_rm, arg) then - last = arg - elseif arg == runtime_set and vim.tbl_contains(args_rm, 'runtimepath') then - table.remove(new_args) -- Remove the preceding "--cmd". - last = '' - else - table.insert(new_args, arg) - end - end - return new_args -end - -function M.check_close() - if not session then - return - end - local start_time = uv.now() - session:close() - uv.update_time() -- Update cached value of luv.now() (libuv: uv_now()). - local end_time = uv.now() - local delta = end_time - start_time - if delta > 500 then - print( - 'nvim took ' - .. delta - .. ' milliseconds to exit after last test\n' - .. 'This indicates a likely problem with the test even if it passed!\n' - ) - io.stdout:flush() - end - session = nil -end - ---- @param argv string[] ---- @param merge boolean? ---- @param env string[]? ---- @param keep boolean ---- @param io_extra uv.uv_pipe_t? used for stdin_fd, see :help ui-option ---- @return test.Session -function M.spawn(argv, merge, env, keep, io_extra) - if not keep then - M.check_close() - end - - local child_stream = - ChildProcessStream.spawn(merge and M.merge_args(prepend_argv, argv) or argv, env, io_extra) - return Session.new(child_stream) -end - --- Creates a new Session connected by domain socket (named pipe) or TCP. -function M.connect(file_or_address) - local addr, port = string.match(file_or_address, '(.*):(%d+)') - local stream = (addr and port) and SocketStream.connect(addr, port) - or SocketStream.open(file_or_address) - return Session.new(stream) -end - --- Starts (and returns) a new global Nvim session. --- --- Parameters are interpreted as startup args, OR a map with these keys: --- args: List: Args appended to the default `nvim_argv` set. --- args_rm: List: Args removed from the default set. All cases are --- removed, e.g. args_rm={'--cmd'} removes all cases of "--cmd" --- (and its value) from the default set. --- env: Map: Defines the environment of the new session. --- --- Example: --- clear('-e') --- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}} -function M.clear(...) - M.set_session(M.spawn_argv(false, ...)) - return M.get_session() -end - ---- same params as clear, but does returns the session instead ---- of replacing the default session ---- @return test.Session -function M.spawn_argv(keep, ...) - local argv, env, io_extra = M.new_argv(...) - return M.spawn(argv, nil, env, keep, io_extra) -end - ---- @class test.new_argv.Opts ---- @field args? string[] ---- @field args_rm? string[] ---- @field env? table<string,string> ---- @field io_extra? uv.uv_pipe_t - ---- Builds an argument list for use in clear(). ---- ---- @see clear() for parameters. ---- @param ... string ---- @return string[] ---- @return string[]? ---- @return uv.uv_pipe_t? -function M.new_argv(...) - local args = { unpack(M.nvim_argv) } - table.insert(args, '--headless') - if _G._nvim_test_id then - -- Set the server name to the test-id for logging. #8519 - table.insert(args, '--listen') - table.insert(args, _G._nvim_test_id) - end - local new_args --- @type string[] - local io_extra --- @type uv.uv_pipe_t? - local env --- @type string[]? - --- @type test.new_argv.Opts|string - local opts = select(1, ...) - if type(opts) ~= 'table' then - new_args = { ... } - else - args = remove_args(args, opts.args_rm) - if opts.env then - local env_opt = {} --- @type table<string,string> - for k, v in pairs(opts.env) do - assert(type(k) == 'string') - assert(type(v) == 'string') - env_opt[k] = v - end - for _, k in ipairs({ - 'HOME', - 'ASAN_OPTIONS', - 'TSAN_OPTIONS', - 'MSAN_OPTIONS', - 'LD_LIBRARY_PATH', - 'PATH', - 'NVIM_LOG_FILE', - 'NVIM_RPLUGIN_MANIFEST', - 'GCOV_ERROR_FILE', - 'XDG_DATA_DIRS', - 'TMPDIR', - 'VIMRUNTIME', - }) do - -- Set these from the environment unless the caller defined them. - if not env_opt[k] then - env_opt[k] = os.getenv(k) - end - end - env = {} - for k, v in pairs(env_opt) do - env[#env + 1] = k .. '=' .. v - end - end - new_args = opts.args or {} - io_extra = opts.io_extra - end - for _, arg in ipairs(new_args) do - table.insert(args, arg) - end - return args, env, io_extra -end - ---- @param ... string -function M.insert(...) - nvim_feed('i') - for _, v in ipairs({ ... }) do - local escaped = v:gsub('<', '<lt>') - M.feed(escaped) - end - nvim_feed('<ESC>') -end - ---- Executes an ex-command by user input. Because nvim_input() is used, Vimscript ---- errors will not manifest as client (lua) errors. Use command() for that. ---- @param ... string -function M.feed_command(...) - for _, v in ipairs({ ... }) do - if v:sub(1, 1) ~= '/' then - -- not a search command, prefix with colon - nvim_feed(':') - end - nvim_feed(v:gsub('<', '<lt>')) - nvim_feed('<CR>') - end -end - --- @deprecated use nvim_exec2() -function M.source(code) - M.exec(dedent(code)) -end - -function M.has_powershell() - return M.eval('executable("' .. (is_os('win') and 'powershell' or 'pwsh') .. '")') == 1 -end - ---- Sets Nvim shell to powershell. ---- ---- @param fake (boolean) If true, a fake will be used if powershell is not ---- found on the system. ---- @returns true if powershell was found on the system, else false. -function M.set_shell_powershell(fake) - local found = M.has_powershell() - if not fake then - assert(found) - end - local shell = found and (is_os('win') and 'powershell' or 'pwsh') or M.testprg('pwsh-test') - local cmd = 'Remove-Item -Force ' - .. table.concat( - is_os('win') and { 'alias:cat', 'alias:echo', 'alias:sleep', 'alias:sort', 'alias:tee' } - or { 'alias:echo' }, - ',' - ) - .. ';' - M.exec([[ - let &shell = ']] .. shell .. [[' - set shellquote= shellxquote= - let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ' - let &shellcmdflag .= '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();' - let &shellcmdflag .= '$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';' - let &shellcmdflag .= ']] .. cmd .. [[' - let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' - let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' - ]]) - return found -end - ----@param func function ----@return table<string,function> -function M.create_callindex(func) - return setmetatable({}, { - --- @param tbl table<any,function> - --- @param arg1 string - --- @return function - __index = function(tbl, arg1) - local ret = function(...) - return func(arg1, ...) - end - tbl[arg1] = ret - return ret - end, - }) -end - ---- @param method string ---- @param ... any -function M.nvim_async(method, ...) - assert(session):notify(method, ...) -end - ---- Executes a Vimscript function via RPC. ---- Fails on Vimscript error, but does not update v:errmsg. ---- @param name string ---- @param ... any ---- @return any -function M.call(name, ...) - return M.request('nvim_call_function', name, { ... }) -end - -M.async_meths = M.create_callindex(M.nvim_async) - -M.rpc = { - fn = M.create_callindex(M.call), - api = M.create_callindex(M.request), -} - -M.lua = { - fn = M.create_callindex(M.call_lua), - api = M.create_callindex(M.request_lua), -} - -M.describe_lua_and_rpc = function(describe) - return function(what, tests) - local function d(flavour) - describe(string.format('%s (%s)', what, flavour), function(...) - return tests(M[flavour].api, ...) - end) - end - - d('rpc') - d('lua') - end -end - ---- add for typing. The for loop after will overwrite this -M.api = vim.api -M.fn = vim.fn - -for name, fns in pairs(M.rpc) do - --- @diagnostic disable-next-line:no-unknown - M[name] = fns -end - --- Executes an ex-command. Vimscript errors manifest as client (lua) errors, but --- v:errmsg will not be updated. -M.command = M.api.nvim_command - --- Evaluates a Vimscript expression. --- Fails on Vimscript error, but does not update v:errmsg. -M.eval = M.api.nvim_eval - -function M.poke_eventloop() - -- Execute 'nvim_eval' (a deferred function) to - -- force at least one main_loop iteration - M.api.nvim_eval('1') -end - -function M.buf_lines(bufnr) - return M.exec_lua('return vim.api.nvim_buf_get_lines((...), 0, -1, false)', bufnr) -end - ----@see buf_lines() -function M.curbuf_contents() - M.poke_eventloop() -- Before inspecting the buffer, do whatever. - return table.concat(M.api.nvim_buf_get_lines(0, 0, -1, true), '\n') -end - -function M.expect(contents) - return eq(dedent(contents), M.curbuf_contents()) -end - -function M.expect_any(contents) - contents = dedent(contents) - return ok(nil ~= string.find(M.curbuf_contents(), contents, 1, true)) -end - ---- @param expected any[] ---- @param received any[] ---- @param kind string ---- @return any -function M.expect_events(expected, received, kind) - if not pcall(eq, expected, received) then - local msg = 'unexpected ' .. kind .. ' received.\n\n' - - msg = msg .. 'received events:\n' - for _, e in ipairs(received) do - msg = msg .. ' ' .. vim.inspect(e) .. ';\n' - end - msg = msg .. '\nexpected events:\n' - for _, e in ipairs(expected) do - msg = msg .. ' ' .. vim.inspect(e) .. ';\n' - end - fail(msg) - end - return received -end - --- Checks that the Nvim session did not terminate. -function M.assert_alive() - assert(2 == M.eval('1+1'), 'crash? request failed') -end - --- Asserts that buffer is loaded and visible in the current tabpage. -function M.assert_visible(bufnr, visible) - assert(type(visible) == 'boolean') - eq(visible, M.api.nvim_buf_is_loaded(bufnr)) - if visible then - assert( - -1 ~= M.fn.bufwinnr(bufnr), - 'expected buffer to be visible in current tabpage: ' .. tostring(bufnr) - ) - else - assert( - -1 == M.fn.bufwinnr(bufnr), - 'expected buffer NOT visible in current tabpage: ' .. tostring(bufnr) - ) - end -end - ---- @param path string -local function do_rmdir(path) - local stat = uv.fs_stat(path) - if stat == nil then - return - end - if stat.type ~= 'directory' then - error(string.format('rmdir: not a directory: %s', path)) - end - for file in vim.fs.dir(path) do - if file ~= '.' and file ~= '..' then - local abspath = path .. '/' .. file - if t_global.isdir(abspath) then - do_rmdir(abspath) -- recurse - else - local ret, err = os.remove(abspath) - if not ret then - if not session then - error('os.remove: ' .. err) - else - -- Try Nvim delete(): it handles `readonly` attribute on Windows, - -- and avoids Lua cross-version/platform incompatibilities. - if -1 == M.call('delete', abspath) then - local hint = (is_os('win') and ' (hint: try :%bwipeout! before rmdir())' or '') - error('delete() failed' .. hint .. ': ' .. abspath) - end - end - end - end - end - end - local ret, err = uv.fs_rmdir(path) - if not ret then - error('luv.fs_rmdir(' .. path .. '): ' .. err) - end -end - -local start_dir = uv.cwd() - -function M.rmdir(path) - local ret, _ = pcall(do_rmdir, path) - if not ret and is_os('win') then - -- Maybe "Permission denied"; try again after changing the nvim - -- process to the top-level directory. - M.command([[exe 'cd '.fnameescape(']] .. start_dir .. "')") - ret, _ = pcall(do_rmdir, path) - end - -- During teardown, the nvim process may not exit quickly enough, then rmdir() - -- will fail (on Windows). - if not ret then -- Try again. - sleep(1000) - do_rmdir(path) - end -end - -function M.exc_exec(cmd) - M.command(([[ - try - execute "%s" - catch - let g:__exception = v:exception - endtry - ]]):format(cmd:gsub('\n', '\\n'):gsub('[\\"]', '\\%0'))) - local ret = M.eval('get(g:, "__exception", 0)') - M.command('unlet! g:__exception') - return ret -end - ---- @param cond boolean ---- @param reason? string ---- @return boolean -function M.skip(cond, reason) - if cond then - --- @type fun(reason: string) - local pending = getfenv(2).pending - pending(reason or 'FIXME') - return true - end - return false -end - --- Calls pending() and returns `true` if the system is too slow to --- run fragile or expensive tests. Else returns `false`. -function M.skip_fragile(pending_fn, cond) - if pending_fn == nil or type(pending_fn) ~= type(function() end) then - error('invalid pending_fn') - end - if cond then - pending_fn('skipped (test is fragile on this system)', function() end) - return true - elseif os.getenv('TEST_SKIP_FRAGILE') then - pending_fn('skipped (TEST_SKIP_FRAGILE)', function() end) - return true - end - return false -end - -function M.exec(code) - M.api.nvim_exec2(code, {}) -end - ---- @param code string ---- @return string -function M.exec_capture(code) - return M.api.nvim_exec2(code, { output = true }).output -end - ---- @param code string ---- @return any -function M.exec_lua(code, ...) - return M.api.nvim_exec_lua(code, { ... }) -end - -function M.get_pathsep() - return is_os('win') and '\\' or '/' -end - ---- Gets the filesystem root dir, namely "/" or "C:/". -function M.pathroot() - local pathsep = package.config:sub(1, 1) - return is_os('win') and (M.nvim_dir:sub(1, 2) .. pathsep) or '/' -end - ---- Gets the full `…/build/bin/{name}` path of a test program produced by ---- `test/functional/fixtures/CMakeLists.txt`. ---- ---- @param name (string) Name of the test program. -function M.testprg(name) - local ext = M.is_os('win') and '.exe' or '' - return ('%s/%s%s'):format(M.nvim_dir, name, ext) -end - -function M.is_asan() - local version = M.eval('execute("verbose version")') - return version:match('-fsanitize=[a-z,]*address') -end - --- Returns a valid, platform-independent Nvim listen address. --- Useful for communicating with child instances. -function M.new_pipename() - -- HACK: Start a server temporarily, get the name, then stop it. - local pipename = M.eval('serverstart()') - M.fn.serverstop(pipename) - -- Remove the pipe so that trying to connect to it without a server listening - -- will be an error instead of a hang. - os.remove(pipename) - return pipename -end - ---- @param provider string ---- @return string|boolean? -function M.missing_provider(provider) - if provider == 'ruby' or provider == 'perl' then - --- @type string? - local e = M.exec_lua("return {require('vim.provider." .. provider .. "').detect()}")[2] - return e ~= '' and e or false - elseif provider == 'node' then - --- @type string? - local e = M.fn['provider#node#Detect']()[2] - return e ~= '' and e or false - elseif provider == 'python' then - return M.exec_lua([[return {require('vim.provider.python').detect_by_module('neovim')}]])[2] - end - assert(false, 'Unknown provider: ' .. provider) -end - ---- @param obj string|table ---- @return any -function M.alter_slashes(obj) - if not is_os('win') then - return obj - end - if type(obj) == 'string' then - local ret = obj:gsub('/', '\\') - return ret - elseif type(obj) == 'table' then - --- @cast obj table<any,any> - local ret = {} --- @type table<any,any> - for k, v in pairs(obj) do - ret[k] = M.alter_slashes(v) - end - return ret - end - assert(false, 'expected string or table of strings, got ' .. type(obj)) -end - -local load_factor = 1 -if t_global.is_ci() then - -- Compute load factor only once (but outside of any tests). - M.clear() - M.request('nvim_command', 'source test/old/testdir/load.vim') - load_factor = M.request('nvim_eval', 'g:test_load_factor') -end - ---- @param num number ---- @return number -function M.load_adjust(num) - return math.ceil(num * load_factor) -end - ---- @param ctx table<string,any> ---- @return table -function M.parse_context(ctx) - local parsed = {} --- @type table<string,any> - for _, item in ipairs({ 'regs', 'jumps', 'bufs', 'gvars' }) do - --- @param v any - parsed[item] = vim.tbl_filter(function(v) - return type(v) == 'table' - end, M.call('msgpackparse', ctx[item])) - end - parsed['bufs'] = parsed['bufs'][1] - --- @param v any - return vim.tbl_map(function(v) - if #v == 0 then - return nil - end - return v - end, parsed) -end - -function M.add_builddir_to_rtp() - -- Add runtime from build dir for doc/tags (used with :help). - M.command(string.format([[set rtp+=%s/runtime]], M.paths.test_build_dir)) -end - ---- Kill (reap) a process by PID. ---- @param pid string ---- @return boolean? -function M.os_kill(pid) - return os.execute( - ( - is_os('win') and 'taskkill /f /t /pid ' .. pid .. ' > nul' - or 'kill -9 ' .. pid .. ' > /dev/null' - ) - ) -end - ---- Create folder with non existing parents ---- @param path string ---- @return boolean? -function M.mkdir_p(path) - return os.execute((is_os('win') and 'mkdir ' .. path or 'mkdir -p ' .. path)) -end - -local testid = (function() - local id = 0 - return function() - id = id + 1 - return id - end -end)() - -return function() - local g = getfenv(2) - - --- @type function? - local before_each = g.before_each - --- @type function? - local after_each = g.after_each - - if before_each then - before_each(function() - local id = ('T%d'):format(testid()) - _G._nvim_test_id = id - end) - end - - if after_each then - after_each(function() - check_logs() - check_cores('build/bin/nvim') - if session then - local msg = session:next_message(0) - if msg then - if msg[1] == 'notification' and msg[2] == 'nvim_error_event' then - error(msg[3][2]) - end - end - end - end) - end - return M -end diff --git a/test/functional/treesitter/fold_spec.lua b/test/functional/treesitter/fold_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local eq = t.eq -local insert = t.insert -local exec_lua = t.exec_lua -local command = t.command -local feed = t.feed -local poke_eventloop = t.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear = n.clear +local eq = t.eq +local insert = n.insert +local exec_lua = n.exec_lua +local command = n.command +local feed = n.feed +local poke_eventloop = n.poke_eventloop + before_each(clear) describe('treesitter foldexpr', function() diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local insert = t.insert -local exec_lua = t.exec_lua -local feed = t.feed -local command = t.command -local api = t.api +local clear = n.clear +local insert = n.insert +local exec_lua = n.exec_lua +local feed = n.feed +local command = n.command +local api = n.api local eq = t.eq before_each(clear) @@ -872,7 +873,7 @@ describe('treesitter highlighting (help)', function() ]], } - t.api.nvim_buf_set_text(0, 0, 1, 0, 5, { 'lua' }) + n.api.nvim_buf_set_text(0, 0, 1, 0, 5, { 'lua' }) screen:expect { grid = [[ @@ -885,7 +886,7 @@ describe('treesitter highlighting (help)', function() ]], } - t.api.nvim_buf_set_text(0, 0, 1, 0, 4, { 'ruby' }) + n.api.nvim_buf_set_text(0, 0, 1, 0, 4, { 'ruby' }) screen:expect { grid = [[ diff --git a/test/functional/treesitter/inspect_tree_spec.lua b/test/functional/treesitter/inspect_tree_spec.lua @@ -1,17 +1,19 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local insert = t.insert +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local insert = n.insert local dedent = t.dedent local eq = t.eq -local exec_lua = t.exec_lua -local feed = t.feed +local exec_lua = n.exec_lua +local feed = n.feed describe('vim.treesitter.inspect_tree', function() before_each(clear) local expect_tree = function(x) local expected = vim.split(vim.trim(dedent(x)), '\n') - local actual = t.buf_lines(0) ---@type string[] + local actual = n.buf_lines(0) ---@type string[] eq(expected, actual) end diff --git a/test/functional/treesitter/language_spec.lua b/test/functional/treesitter/language_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local command = t.command -local exec_lua = t.exec_lua +local command = n.command +local exec_lua = n.exec_lua local pcall_err = t.pcall_err local matches = t.matches -local insert = t.insert +local insert = n.insert before_each(clear) diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua -local insert = t.insert -local assert_alive = t.assert_alive +local exec_lua = n.exec_lua +local insert = n.insert +local assert_alive = n.assert_alive before_each(clear) diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua @@ -1,12 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local dedent = t.dedent local eq = t.eq -local insert = t.insert -local exec_lua = t.exec_lua +local insert = n.insert +local exec_lua = n.exec_lua local pcall_err = t.pcall_err -local feed = t.feed +local feed = n.feed describe('treesitter parser API', function() before_each(function() @@ -381,7 +382,7 @@ int x = INT_MAX; { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y)) }, get_ranges()) - t.feed('ggo<esc>') + n.feed('ggo<esc>') eq(5, exec_lua('return #parser:children().c:trees()')) eq({ { 0, 0, 8, 0 }, -- root tree @@ -418,7 +419,7 @@ int x = INT_MAX; -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y)) }, get_ranges()) - t.feed('ggo<esc>') + n.feed('ggo<esc>') eq('table', exec_lua('return type(parser:children().c)')) eq(2, exec_lua('return #parser:children().c:trees()')) eq({ @@ -430,7 +431,7 @@ int x = INT_MAX; -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y)) }, get_ranges()) - t.feed('7ggI//<esc>') + n.feed('7ggI//<esc>') exec_lua([[parser:parse({6, 7})]]) eq('table', exec_lua('return type(parser:children().c)')) eq(2, exec_lua('return #parser:children().c:trees()')) @@ -468,7 +469,7 @@ int x = INT_MAX; { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y)) }, get_ranges()) - t.feed('ggo<esc>') + n.feed('ggo<esc>') eq(5, exec_lua('return #parser:children().c:trees()')) eq({ { 0, 0, 8, 0 }, -- root tree @@ -657,7 +658,7 @@ int x = INT_MAX; { 'declaration', 1, 2, 1, 12 }, }, run_query()) - t.command 'normal ggO' + n.command 'normal ggO' insert('int a;') eq({ diff --git a/test/functional/treesitter/query_spec.lua b/test/functional/treesitter/query_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local dedent = t.dedent local eq = t.eq -local insert = t.insert -local exec_lua = t.exec_lua +local insert = n.insert +local exec_lua = n.exec_lua local pcall_err = t.pcall_err local is_os = t.is_os -local api = t.api -local fn = t.fn +local api = n.api +local fn = n.fn describe('treesitter query API', function() before_each(function() @@ -67,7 +68,7 @@ void ui_refresh(void) it('supports caching queries', function() local long_query = test_query:rep(100) ---@return number - local function q(n) + local function q(_n) return exec_lua( [[ local query, n = ... @@ -79,7 +80,7 @@ void ui_refresh(void) return after - before ]], long_query, - n + _n ) end diff --git a/test/functional/treesitter/utils_spec.lua b/test/functional/treesitter/utils_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local insert = t.insert +local clear = n.clear +local insert = n.insert local eq = t.eq -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua before_each(clear) diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local command, neq = t.command, t.neq -local api = t.api +local clear, feed, insert = n.clear, n.feed, n.insert +local command, neq = n.command, t.neq +local api = n.api local eq = t.eq local pcall_err = t.pcall_err local set_virtual_text = api.nvim_buf_set_virtual_text diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local feed = t.feed -local clear = t.clear -local api = t.api -local fn = t.fn -local source = t.source -local exec_capture = t.exec_capture +local feed = n.feed +local clear = n.clear +local api = n.api +local fn = n.fn +local source = n.source +local exec_capture = n.exec_capture local dedent = t.dedent -local command = t.command +local command = n.command local screen diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed = t.clear, t.feed -local source = t.source -local command = t.command -local assert_alive = t.assert_alive -local poke_eventloop = t.poke_eventloop -local exec = t.exec -local eval = t.eval + +local clear, feed = n.clear, n.feed +local source = n.source +local command = n.command +local assert_alive = n.assert_alive +local poke_eventloop = n.poke_eventloop +local exec = n.exec +local eval = n.eval local eq = t.eq local is_os = t.is_os -local api = t.api +local api = n.api local function new_screen(opt) local screen = Screen.new(25, 5) diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, api = t.clear, t.api + +local clear, api = n.clear, n.api local eq = t.eq -local command = t.command +local command = n.command describe('ui/cursor', function() local screen @@ -213,8 +215,8 @@ describe('ui/cursor', function() } -- Change the cursor style. - t.command('hi Cursor guibg=DarkGray') - t.command( + n.command('hi Cursor guibg=DarkGray') + n.command( 'set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20' .. ',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor' .. ',sm:block-blinkwait175-blinkoff150-blinkon175' @@ -260,8 +262,8 @@ describe('ui/cursor', function() end) -- Change hl groups only, should update the styles - t.command('hi Cursor guibg=Red') - t.command('hi lCursor guibg=Green') + n.command('hi Cursor guibg=Red') + n.command('hi lCursor guibg=Green') -- Update the expected values. for _, m in ipairs(expected_mode_info) do @@ -280,7 +282,7 @@ describe('ui/cursor', function() end) -- update the highlight again to hide cursor - t.command('hi Cursor blend=100') + n.command('hi Cursor blend=100') for _, m in ipairs(expected_mode_info) do if m.hl_id then diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed = t.feed -local insert = t.insert -local exec_lua = t.exec_lua -local exec = t.exec +local clear = n.clear +local feed = n.feed +local insert = n.insert +local exec_lua = n.exec_lua +local exec = n.exec local expect_events = t.expect_events -local api = t.api -local fn = t.fn -local command = t.command +local api = n.api +local fn = n.fn +local command = n.command local eq = t.eq -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local pcall_err = t.pcall_err describe('decorations providers', function() @@ -723,7 +724,7 @@ describe('decorations providers', function() end ]] - t.assert_alive() + n.assert_alive() end) it('supports subpriorities (order of definitions in a query file #27131)', function() @@ -2438,7 +2439,7 @@ describe('extmark decorations', function() | ]]} - t.assert_alive() + n.assert_alive() end) it('priority ordering of overlay or win_col virtual text at same position', function() @@ -5153,8 +5154,8 @@ l5 insert(example_test3) feed 'gg' - t.command('sign define Oldsign text=x') - t.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) + n.command('sign define Oldsign text=x') + n.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) @@ -5177,8 +5178,8 @@ l5 insert(example_test3) feed 'gg' - t.command('sign define Oldsign text=x') - t.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) + n.command('sign define Oldsign text=x') + n.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed -local clear = t.clear -local command = t.command -local insert = t.insert +local feed = n.feed +local clear = n.clear +local command = n.command +local insert = n.insert local write_file = t.write_file local dedent = t.dedent -local exec = t.exec +local exec = n.exec local eq = t.eq -local api = t.api +local api = n.api before_each(clear) diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua @@ -1,20 +1,20 @@ -local uv = vim.uv - -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local uv = vim.uv -local api = t.api -local feed = t.feed +local api = n.api +local feed = n.feed local eq = t.eq local neq = t.neq -local clear = t.clear +local clear = n.clear local ok = t.ok -local fn = t.fn -local nvim_prog = t.nvim_prog +local fn = n.fn +local nvim_prog = n.nvim_prog local retry = t.retry local write_file = t.write_file local assert_log = t.assert_log -local check_close = t.check_close +local check_close = n.check_close local is_os = t.is_os local testlog = 'Xtest-embed-log' @@ -258,7 +258,7 @@ describe('--embed UI', function() } -- Change global cwd - t.command(string.format('cd %s/src/nvim', t.paths.test_source_path)) + n.command(string.format('cd %s/src/nvim', t.paths.test_source_path)) screen:expect { condition = function() @@ -267,8 +267,8 @@ describe('--embed UI', function() } -- Split the window and change the cwd in the split - t.command('new') - t.command(string.format('lcd %s/test', t.paths.test_source_path)) + n.command('new') + n.command(string.format('lcd %s/test', t.paths.test_source_path)) screen:expect { condition = function() @@ -277,7 +277,7 @@ describe('--embed UI', function() } -- Move to the original window - t.command('wincmd p') + n.command('wincmd p') screen:expect { condition = function() @@ -286,7 +286,7 @@ describe('--embed UI', function() } -- Change global cwd again - t.command(string.format('cd %s', t.paths.test_source_path)) + n.command(string.format('cd %s', t.paths.test_source_path)) screen:expect { condition = function() @@ -300,7 +300,7 @@ describe('--embed --listen UI', function() it('waits for connection on listening address', function() t.skip(t.is_os('win')) clear() - local child_server = assert(t.new_pipename()) + local child_server = assert(n.new_pipename()) fn.jobstart({ nvim_prog, '--embed', @@ -314,7 +314,7 @@ describe('--embed --listen UI', function() neq(nil, uv.fs_stat(child_server)) end) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) local info_ok, api_info = child_session:request('nvim_get_api_info') ok(info_ok) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua @@ -1,24 +1,26 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local os = require('os') -local clear, feed = t.clear, t.feed -local assert_alive = t.assert_alive -local command, feed_command = t.command, t.feed_command -local eval = t.eval + +local clear, feed = n.clear, n.feed +local assert_alive = n.assert_alive +local command, feed_command = n.command, n.feed_command +local eval = n.eval local eq = t.eq local neq = t.neq -local expect = t.expect -local exec = t.exec -local exec_lua = t.exec_lua -local insert = t.insert -local api = t.api -local fn = t.fn -local run = t.run +local expect = n.expect +local exec = n.exec +local exec_lua = n.exec_lua +local insert = n.insert +local api = n.api +local fn = n.fn +local run = n.run local pcall_err = t.pcall_err local tbl_contains = vim.tbl_contains -local curbuf = t.api.nvim_get_current_buf -local curwin = t.api.nvim_get_current_win -local curtab = t.api.nvim_get_current_tabpage +local curbuf = n.api.nvim_get_current_buf +local curwin = n.api.nvim_get_current_win +local curtab = n.api.nvim_get_current_tabpage local NIL = vim.NIL describe('float window', function() @@ -4120,7 +4122,7 @@ describe('float window', function() if multigrid then pending("supports second UI without multigrid", function() - local session2 = t.connect(eval('v:servername')) + local session2 = n.connect(eval('v:servername')) print(session2:request("nvim_eval", "2+2")) local screen2 = Screen.new(40,7) screen2:attach(nil, session2) @@ -8018,7 +8020,7 @@ describe('float window', function() end) it("correctly redraws when overlaid windows are resized #13991", function() - t.source([[ + n.source([[ let popup_config = {"relative" : "editor", \ "width" : 7, \ "height" : 3, @@ -8082,7 +8084,7 @@ describe('float window', function() ]]) end - t.source([[ + n.source([[ let new_popup_config = {"width" : 1, "height" : 3} let new_border_config = {"width" : 3, "height" : 5} @@ -8097,7 +8099,7 @@ describe('float window', function() nnoremap zz <cmd>call Resize()<cr> ]]) - t.feed("zz") + n.feed("zz") if multigrid then screen:expect{grid=[[ ## grid 1 diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, eq = t.clear, t.feed, t.eq -local command = t.command -local feed_command = t.feed_command -local insert = t.insert -local fn = t.fn -local api = t.api -local exec = t.exec -local assert_alive = t.assert_alive + +local clear, feed, eq = n.clear, n.feed, t.eq +local command = n.command +local feed_command = n.feed_command +local insert = n.insert +local fn = n.fn +local api = n.api +local exec = n.exec +local assert_alive = n.assert_alive local content1 = [[ This is a diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local os = require('os') -local clear, feed, insert = t.clear, t.feed, t.insert -local command, exec = t.command, t.exec -local eval = t.eval -local feed_command, eq = t.feed_command, t.eq -local fn = t.fn -local api = t.api -local exec_lua = t.exec_lua + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, exec = n.command, n.exec +local eval = n.eval +local feed_command, eq = n.feed_command, t.eq +local fn = n.fn +local api = n.api +local exec_lua = n.exec_lua describe('colorscheme compatibility', function() before_each(function() @@ -2196,7 +2198,7 @@ describe("'winhighlight' highlight", function() ]], } - t.assert_alive() + n.assert_alive() end) it('can redraw statusline on cursor movement', function() diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') - -local clear, insert = t.clear, t.insert -local command = t.command -local api = t.api -local testprg = t.testprg local tt = require('test.functional.terminal.testutil') + +local clear, insert = n.clear, n.insert +local command = n.command +local api = n.api +local testprg = n.testprg local skip = t.skip local is_os = t.is_os @@ -381,7 +382,7 @@ describe('ext_hlstate detailed highlights', function() }, } - t.feed('3ggV2jd') + n.feed('3ggV2jd') --screen:redraw_debug() screen:expect { grid = [[ @@ -478,7 +479,7 @@ describe('ext_hlstate detailed highlights', function() }, } - t.feed('3ggV2jd') + n.feed('3ggV2jd') --screen:redraw_debug() screen:expect { grid = [[ @@ -512,7 +513,7 @@ describe('ext_hlstate detailed highlights', function() end insert('last line') - t.feed('gg') + n.feed('gg') screen:expect { grid = [[ ^first line | @@ -555,7 +556,7 @@ describe('ext_hlstate detailed highlights', function() }, } - t.feed(string.format('3ggV%ijd', num_lines - 2)) + n.feed(string.format('3ggV%ijd', num_lines - 2)) --screen:redraw_debug(nil, nil, 100000) local expected_ids = {} diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua @@ -1,22 +1,24 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local expect = t.expect -local feed = t.feed -local insert = t.insert -local fn = t.fn -local api = t.api +local eval = n.eval +local expect = n.expect +local feed = n.feed +local insert = n.insert +local fn = n.fn +local api = n.api local neq = t.neq local ok = t.ok local retry = t.retry -local source = t.source -local poke_eventloop = t.poke_eventloop +local source = n.source +local poke_eventloop = n.poke_eventloop local sleep = vim.uv.sleep -local testprg = t.testprg -local assert_alive = t.assert_alive +local testprg = n.testprg +local assert_alive = n.assert_alive local default_text = [[ Inc substitution on diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local api = t.api -local clear = t.clear + +local api = n.api +local clear = n.clear local eq = t.eq -local exec_lua = t.exec_lua -local insert = t.insert -local feed = t.feed -local command = t.command -local assert_alive = t.assert_alive +local exec_lua = n.exec_lua +local insert = n.insert +local feed = n.feed +local command = n.command +local assert_alive = n.assert_alive -- Implements a :Replace command that works like :substitute and has multibuffer support. local setup_replace_cmd = [[ diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua @@ -1,16 +1,18 @@ -local t = require('test.functional.testutil')() -local clear, feed_command = t.clear, t.feed_command -local feed, next_msg, eq = t.feed, t.next_msg, t.eq -local command = t.command -local expect = t.expect -local curbuf_contents = t.curbuf_contents -local api = t.api -local exec_lua = t.exec_lua -local write_file = t.write_file -local fn = t.fn -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear, feed_command = n.clear, n.feed_command +local feed, next_msg, eq = n.feed, n.next_msg, t.eq +local command = n.command +local expect = n.expect +local curbuf_contents = n.curbuf_contents +local api = n.api +local exec_lua = n.exec_lua +local write_file = t.write_file +local fn = n.fn +local eval = n.eval + before_each(clear) describe('mappings', function() diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = t.feed -local clear = t.clear +local feed = n.feed +local clear = n.clear local write_file = t.write_file describe('Diff mode screen with 3 diffs open', function() @@ -1094,10 +1095,10 @@ describe('regressions', function() screen = Screen.new(100, 20) screen:attach() -- line must be greater than MATCH_CHAR_MAX_LEN - t.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' }) - t.exec 'vnew' - t.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1010) .. 'world' }) - t.exec 'windo diffthis' + n.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' }) + n.exec 'vnew' + n.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1010) .. 'world' }) + n.exec 'windo diffthis' end) it('properly computes filler lines for hunks bigger than linematch limit', function() @@ -1109,10 +1110,10 @@ describe('regressions', function() for i = 0, 29 do lines[#lines + 1] = tostring(i) end - t.api.nvim_buf_set_lines(0, 0, -1, false, lines) - t.exec 'vnew' - t.api.nvim_buf_set_lines(0, 0, -1, false, { '00', '29' }) - t.exec 'windo diffthis' + n.api.nvim_buf_set_lines(0, 0, -1, false, lines) + n.exec 'vnew' + n.api.nvim_buf_set_lines(0, 0, -1, false, { '00', '29' }) + n.exec 'windo diffthis' feed('<C-e>') screen:expect { grid = [[ diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua @@ -1,25 +1,27 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed = t.clear, t.feed -local eval = t.eval + +local clear, feed = n.clear, n.feed +local eval = n.eval local eq = t.eq local neq = t.neq -local command = t.command -local set_method_error = t.set_method_error -local api = t.api -local async_meths = t.async_meths +local command = n.command +local set_method_error = n.set_method_error +local api = n.api +local async_meths = n.async_meths local test_build_dir = t.paths.test_build_dir -local nvim_prog = t.nvim_prog -local testprg = t.testprg -local exec = t.exec -local exec_capture = t.exec_capture -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local poke_eventloop = t.poke_eventloop -local assert_alive = t.assert_alive +local nvim_prog = n.nvim_prog +local testprg = n.testprg +local exec = n.exec +local exec_capture = n.exec_capture +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local poke_eventloop = n.poke_eventloop +local assert_alive = n.assert_alive local retry = t.retry local is_os = t.is_os -local fn = t.fn +local fn = n.fn local skip = t.skip describe('ui/ext_messages', function() @@ -2723,13 +2725,13 @@ end) it('pager works in headless mode with UI attached', function() skip(is_os('win')) clear() - local child_server = assert(t.new_pipename()) + local child_server = assert(n.new_pipename()) fn.jobstart({ nvim_prog, '--clean', '--headless', '--listen', child_server }) retry(nil, nil, function() neq(nil, vim.uv.fs_stat(child_server)) end) - local child_session = t.connect(child_server) + local child_session = n.connect(child_server) local child_screen = Screen.new(40, 6) child_screen:attach(nil, child_session) child_screen._default_attr_ids = nil -- TODO: unskip with new color scheme diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua @@ -1,8 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local command = t.command +local clear, feed, insert = n.clear, n.feed, n.insert +local command = n.command local retry = t.retry describe('ui mode_change event', function() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, api = t.clear, t.feed, t.api -local insert, feed_command = t.insert, t.feed_command -local eq, fn = t.eq, t.fn -local poke_eventloop = t.poke_eventloop -local command = t.command -local exec = t.exec + +local clear, feed, api = n.clear, n.feed, n.api +local insert, feed_command = n.insert, n.feed_command +local eq, fn = t.eq, n.fn +local poke_eventloop = n.poke_eventloop +local command = n.command +local exec = n.exec describe('ui/mouse/input', function() local screen @@ -575,7 +577,7 @@ describe('ui/mouse/input', function() :tabprevious | ]]) feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab - t.poke_eventloop() + n.poke_eventloop() feed('<LeftMouse><0,1>') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -1856,8 +1858,8 @@ describe('ui/mouse/input', function() it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function() feed('<MouseMove>') - t.poke_eventloop() - t.assert_alive() + n.poke_eventloop() + n.assert_alive() end) it('mousemodel=popup_setpos', function() diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local feed = t.feed -local feed_command = t.feed_command -local insert = t.insert -local fn = t.fn -local api = t.api + +local clear = n.clear +local command = n.command +local feed = n.feed +local feed_command = n.feed_command +local insert = n.insert +local fn = n.fn +local api = n.api local split = vim.split local dedent = t.dedent diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local feed, command, insert = t.feed, t.command, t.insert + +local clear = n.clear +local feed, command, insert = n.feed, n.command, n.insert local eq = t.eq -local fn = t.fn -local api = t.api -local curwin = t.api.nvim_get_current_win -local poke_eventloop = t.poke_eventloop +local fn = n.fn +local api = n.api +local curwin = n.api.nvim_get_current_win +local poke_eventloop = n.poke_eventloop describe('ext_multigrid', function() diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq local shallowcopy = t.shallowcopy -local eval = t.eval +local eval = n.eval describe('UI receives option updates', function() local screen diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua @@ -1,18 +1,19 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local t = require('test.functional.testutil')() local tt = require('test.functional.terminal.testutil') -local assert_alive = t.assert_alive -local mkdir, write_file, rmdir = t.mkdir, t.write_file, t.rmdir +local assert_alive = n.assert_alive +local mkdir, write_file, rmdir = t.mkdir, t.write_file, n.rmdir local eq = t.eq -local feed = t.feed -local feed_command = t.feed_command -local clear = t.clear -local command = t.command -local testprg = t.testprg -local nvim_dir = t.nvim_dir -local has_powershell = t.has_powershell -local set_shell_powershell = t.set_shell_powershell +local feed = n.feed +local feed_command = n.feed_command +local clear = n.clear +local command = n.command +local testprg = n.testprg +local nvim_dir = n.nvim_dir +local has_powershell = n.has_powershell +local set_shell_powershell = n.set_shell_powershell local skip = t.skip local is_os = t.is_os @@ -30,7 +31,7 @@ describe('shell command :!', function() '--cmd', 'colorscheme vim', '--cmd', - t.nvim_set .. ' notermguicolors', + n.nvim_set .. ' notermguicolors', }) screen:expect([[ {1: } | @@ -81,7 +82,7 @@ describe('shell command :!', function() {3:-- TERMINAL --} | ]], { - -- test/functional/testutil.lua defaults to background=light. + -- test/functional/testnvim.lua defaults to background=light. [1] = { reverse = true }, [3] = { bold = true }, [10] = { foreground = 2 }, diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua @@ -1,17 +1,19 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local clear, feed = t.clear, t.feed -local source = t.source -local insert = t.insert -local api = t.api -local async_meths = t.async_meths -local command = t.command -local fn = t.fn + +local assert_alive = n.assert_alive +local clear, feed = n.clear, n.feed +local source = n.source +local insert = n.insert +local api = n.api +local async_meths = n.async_meths +local command = n.command +local fn = n.fn local eq = t.eq local pcall_err = t.pcall_err -local exec_lua = t.exec_lua -local exec = t.exec +local exec_lua = n.exec_lua +local exec = n.exec describe('ui/ext_popupmenu', function() local screen diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua @@ -1,7 +1,8 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, api = t.clear, t.feed, t.api -local insert, command = t.insert, t.command + +local clear, feed, api = n.clear, n.feed, n.api +local insert, command = n.insert, n.command describe('quickfix selection highlight', function() local screen diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua @@ -70,17 +70,19 @@ -- To help write screen tests, see Screen:snapshot_util(). -- To debug screen tests, see Screen:redraw_debug(). -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local busted = require('busted') + local deepcopy = vim.deepcopy local shallowcopy = t.shallowcopy local concat_tables = t.concat_tables local pesc = vim.pesc -local run_session = t.run_session +local run_session = n.run_session local eq = t.eq local dedent = t.dedent -local get_session = t.get_session -local create_callindex = t.create_callindex +local get_session = n.get_session +local create_callindex = n.create_callindex local inspect = vim.inspect diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local spawn, set_session, clear = t.spawn, t.set_session, t.clear -local feed, command = t.feed, t.command -local insert = t.insert + +local spawn, set_session, clear = n.spawn, n.set_session, n.clear +local feed, command = n.feed, n.command +local insert = n.insert local eq = t.eq -local fn, api = t.fn, t.api +local fn, api = n.fn, n.api describe('screen', function() local screen local nvim_argv = { - t.nvim_prog, + n.nvim_prog, '-u', 'NONE', '-i', @@ -700,7 +702,7 @@ describe('Screen default colors', function() local extra = (light and ' background=light') or '' local nvim_argv = { - t.nvim_prog, + n.nvim_prog, '-u', 'NONE', '-i', diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, insert = t.clear, t.feed, t.insert -local command = t.command -local feed_command = t.feed_command + +local clear, feed, insert = n.clear, n.feed, n.insert +local command = n.command +local feed_command = n.feed_command local eq = t.eq -local eval = t.eval -local fn = t.fn -local testprg = t.testprg +local eval = n.eval +local fn = n.fn +local testprg = n.testprg describe('search highlighting', function() local screen diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local api, clear, eq = t.api, t.clear, t.eq -local eval, exec, feed = t.eval, t.exec, t.feed + +local api, clear, eq = n.api, n.clear, t.eq +local eval, exec, feed = n.eval, n.exec, n.feed describe('Signs', function() local screen diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua @@ -1,12 +1,14 @@ -- Test for scenarios involving 'spell' -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local exec = t.exec -local feed = t.feed -local insert = t.insert -local api = t.api + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local insert = n.insert +local api = n.api local is_os = t.is_os describe("'spell'", function() diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local exec = t.exec -local eval = t.eval -local exec_lua = t.exec_lua -local feed = t.feed -local api = t.api +local exec = n.exec +local eval = n.eval +local exec_lua = n.exec_lua +local feed = n.feed +local api = n.api local pcall_err = t.pcall_err -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local mousemodels = { 'extend', 'popup', 'popup_setpos' } diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local clear = t.clear -local command = t.command -local feed = t.feed + +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command +local feed = n.feed local eq = t.eq -local fn = t.fn -local api = t.api -local exec = t.exec -local exec_lua = t.exec_lua -local eval = t.eval +local fn = n.fn +local api = n.api +local exec = n.exec +local exec_lua = n.exec_lua +local eval = n.eval local sleep = vim.uv.sleep local pcall_err = t.pcall_err diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, command = t.clear, t.feed, t.command + +local clear, feed, command = n.clear, n.feed, n.command local eq = t.eq -local insert = t.insert -local poke_eventloop = t.poke_eventloop -local exec = t.exec +local insert = n.insert +local poke_eventloop = n.poke_eventloop +local exec = n.exec describe('Screen', function() local screen diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua @@ -1,9 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command, eq = t.clear, t.command, t.eq -local insert = t.insert -local api = t.api -local assert_alive = t.assert_alive + +local clear, command, eq = n.clear, n.command, t.eq +local insert = n.insert +local api = n.api +local assert_alive = n.assert_alive describe('ui/ext_tabline', function() local screen diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local curwin = t.api.nvim_get_current_win + +local clear = n.clear +local command = n.command +local curwin = n.api.nvim_get_current_win local eq = t.eq -local exec_lua = t.exec_lua -local feed = t.feed -local fn = t.fn -local api = t.api +local exec_lua = n.exec_lua +local feed = n.feed +local fn = n.fn +local api = n.api local is_os = t.is_os describe('title', function() diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, command = t.clear, t.feed, t.command -local fn = t.fn -local api = t.api + +local clear, feed, command = n.clear, n.feed, n.command +local fn = n.fn +local api = n.api local eq = t.eq -local eval = t.eval +local eval = n.eval local retry = t.retry -local testprg = t.testprg +local testprg = n.testprg local is_os = t.is_os describe("'wildmenu'", function() diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local insert = t.insert -local api = t.api + +local clear = n.clear +local command = n.command +local insert = n.insert +local api = n.api local eq = t.eq -local poke_eventloop = t.poke_eventloop -local feed = t.feed -local fn = t.fn +local poke_eventloop = n.poke_eventloop +local feed = n.feed +local fn = n.fn local pcall_err = t.pcall_err describe('winbar', function() diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local neq, eq, command = t.neq, t.eq, t.command -local clear = t.clear -local exc_exec, expect, eval = t.exc_exec, t.expect, t.eval -local exec_lua = t.exec_lua -local insert, pcall_err = t.insert, t.pcall_err + +local neq, eq, command = t.neq, t.eq, n.command +local clear = n.clear +local exc_exec, expect, eval = n.exc_exec, n.expect, n.eval +local exec_lua = n.exec_lua +local insert, pcall_err = n.insert, t.pcall_err local matches = t.matches -local api = t.api -local feed = t.feed +local api = n.api +local feed = n.feed describe('eval-API', function() before_each(clear) diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local fn = t.fn -local api = t.api -local command = t.command -local exc_exec = t.exc_exec -local get_pathsep = t.get_pathsep -local rmdir = t.rmdir +local clear = n.clear +local fn = n.fn +local api = n.api +local command = n.command +local exc_exec = n.exc_exec +local get_pathsep = n.get_pathsep +local rmdir = n.rmdir local pcall_err = t.pcall_err local mkdir = t.mkdir diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local feed = t.feed -local clear = t.clear -local fn = t.fn -local api = t.api -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local feed = n.feed +local clear = n.clear +local fn = n.fn +local api = n.api +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local exec_capture = t.exec_capture +local exec_capture = n.exec_capture before_each(clear) diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local api = t.api -local clear = t.clear +local eval = n.eval +local api = n.api +local clear = n.clear before_each(clear) diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local call = t.call -local clear = t.clear -local command = t.command +local call = n.call +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed local map = vim.tbl_map -local api = t.api -local parse_context = t.parse_context -local exec_capture = t.exec_capture -local source = t.source +local api = n.api +local parse_context = n.parse_context +local exec_capture = n.exec_capture +local source = n.source local trim = vim.trim local write_file = t.write_file local pcall_err = t.pcall_err diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local environ = t.fn.environ -local exists = t.fn.exists -local system = t.fn.system -local nvim_prog = t.nvim_prog -local command = t.command -local eval = t.eval -local setenv = t.fn.setenv +local environ = n.fn.environ +local exists = n.fn.exists +local system = n.fn.system +local nvim_prog = n.nvim_prog +local command = n.command +local eval = n.eval +local setenv = n.fn.setenv describe('environment variables', function() it('environ() handles empty env variable', function() diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local exc_exec = t.exc_exec -local get_win_var = t.api.nvim_win_get_var +local exc_exec = n.exc_exec +local get_win_var = n.api.nvim_win_get_var describe('setqflist()', function() - local setqflist = t.fn.setqflist + local setqflist = n.fn.setqflist before_each(clear) @@ -46,7 +47,7 @@ describe('setqflist()', function() end) describe('setloclist()', function() - local setloclist = t.fn.setloclist + local setloclist = n.fn.setloclist before_each(clear) @@ -73,7 +74,7 @@ describe('setloclist()', function() end) it("doesn't crash when when window is closed in the middle #13721", function() - t.insert([[ + n.insert([[ hello world]]) command('vsplit') @@ -82,6 +83,6 @@ describe('setloclist()', function() command('call setloclist(0, [])') command('lopen') - t.assert_alive() + n.assert_alive() end) end) diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua @@ -9,37 +9,38 @@ -- test/functional/vimscript/<funcname>_spec.lua -- test/functional/vimscript/functions_spec.lua -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local mkdir = t.mkdir -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec = t.exec -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local exec_capture = t.exec_capture -local eval = t.eval -local command = t.command +local exec = n.exec +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local exec_capture = n.exec_capture +local eval = n.eval +local command = n.command local write_file = t.write_file -local api = t.api +local api = n.api local sleep = vim.uv.sleep local matches = t.matches local pcall_err = t.pcall_err -local assert_alive = t.assert_alive -local poke_eventloop = t.poke_eventloop -local feed = t.feed -local expect_exit = t.expect_exit +local assert_alive = n.assert_alive +local poke_eventloop = n.poke_eventloop +local feed = n.feed +local expect_exit = n.expect_exit describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h - local range = t.fn.range + local range = n.fn.range before_each(clear) it('printf()', function() - local printf = t.fn.printf - local rep = t.fn['repeat'] + local printf = n.fn.printf + local rep = n.fn['repeat'] local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args)))) local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -47,7 +48,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() end) it('rpcnotify()', function() - local rpcnotify = t.fn.rpcnotify + local rpcnotify = n.fn.rpcnotify local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) eq(1, ret) ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -69,7 +70,7 @@ describe('backtick expansion', function() end) teardown(function() - t.rmdir('test-backticks') + n.rmdir('test-backticks') end) it("with default 'shell'", function() diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local eq, clear, call, write_file, command = t.eq, t.clear, t.call, t.write_file, t.command -local exc_exec = t.exc_exec -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command +local exc_exec = n.exc_exec +local eval = n.eval local is_os = t.is_os describe('executable()', function() diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') + local eq = t.eq -local eval = t.eval -local clear = t.clear -local source = t.source -local exc_exec = t.exc_exec +local eval = n.eval +local clear = n.clear +local source = n.source +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local fn = t.fn -local Screen = require('test.functional.ui.screen') -local command = t.command -local feed = t.feed +local fn = n.fn +local command = n.command +local feed = n.feed local is_os = t.is_os describe('execute()', function() diff --git a/test/functional/vimscript/exepath_spec.lua b/test/functional/vimscript/exepath_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local eq, clear, call = t.eq, t.clear, t.call -local command = t.command -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear, call = t.eq, n.clear, n.call +local command = n.command +local exc_exec = n.exc_exec local matches = t.matches local is_os = t.is_os -local set_shell_powershell = t.set_shell_powershell -local eval = t.eval +local set_shell_powershell = n.set_shell_powershell +local eval = n.eval local find_dummies = function(ext_pat) local tmp_path = eval('$PATH') diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local fnamemodify = t.fn.fnamemodify -local getcwd = t.fn.getcwd -local command = t.command +local fnamemodify = n.fn.fnamemodify +local getcwd = n.fn.getcwd +local command = n.command local write_file = t.write_file -local alter_slashes = t.alter_slashes +local alter_slashes = n.alter_slashes local is_os = t.is_os local function eq_slashconvert(expected, got) @@ -24,7 +26,7 @@ describe('fnamemodify()', function() end) it('handles the root path', function() - local root = t.pathroot() + local root = n.pathroot() eq(root, fnamemodify([[/]], ':p:h')) eq(root, fnamemodify([[/]], ':p')) if is_os('win') then diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua @@ -5,10 +5,11 @@ -- -- Core "eval" tests live in eval_spec.lua. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local eval = t.eval +local clear = n.clear +local eval = n.eval local matches = t.matches local is_os = t.is_os diff --git a/test/functional/vimscript/getline_spec.lua b/test/functional/vimscript/getline_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local call = t.call -local clear = t.clear +local call = n.call +local clear = n.clear local eq = t.eq -local expect = t.expect +local expect = n.expect describe('getline()', function() before_each(function() diff --git a/test/functional/vimscript/glob_spec.lua b/test/functional/vimscript/glob_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command, eval, eq = n.clear, n.command, n.eval, t.eq local mkdir = t.mkdir before_each(function() diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local connect = t.connect + +local clear = n.clear +local connect = n.connect local eq = t.eq -local fn = t.fn +local fn = n.fn local is_os = t.is_os -local nvim_prog = t.nvim_prog +local nvim_prog = n.nvim_prog describe('has()', function() before_each(clear) diff --git a/test/functional/vimscript/hostname_spec.lua b/test/functional/vimscript/hostname_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq local ok = t.ok -local call = t.call -local clear = t.clear +local call = n.call +local clear = n.clear local is_os = t.is_os describe('hostname()', function() diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local feed = t.feed -local api = t.api -local clear = t.clear -local source = t.source -local command = t.command -local exc_exec = t.exc_exec -local async_meths = t.async_meths +local feed = n.feed +local api = n.api +local clear = n.clear +local source = n.source +local command = n.command +local exc_exec = n.exc_exec +local async_meths = n.async_meths local NIL = vim.NIL local screen diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local fn = t.fn -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local fn = n.fn +local api = n.api local eq = t.eq -local eval = t.eval -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err local NIL = vim.NIL -local source = t.source +local source = n.source describe('json_decode() function', function() local restart = function(...) diff --git a/test/functional/vimscript/lang_spec.lua b/test/functional/vimscript/lang_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local exc_exec, source = t.exc_exec, t.source +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local exc_exec, source = n.exc_exec, n.source describe('vimscript', function() before_each(clear) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local command = t.command -local eval = t.eval -local api = t.api -local exec = t.exec -local exec_capture = t.exec_capture -local expect_exit = t.expect_exit -local source = t.source -local testprg = t.testprg +local clear = n.clear +local command = n.command +local eval = n.eval +local api = n.api +local exec = n.exec +local exec_capture = n.exec_capture +local expect_exit = n.expect_exit +local source = n.source +local testprg = n.testprg before_each(clear) diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local exec = t.exec -local exec_lua = t.exec_lua -local expect = t.expect -local feed = t.feed -local fn = t.fn -local api = t.api -local source = t.source -local command = t.command -local exec_capture = t.exec_capture +local eval = n.eval +local exec = n.exec +local exec_lua = n.exec_lua +local expect = n.expect +local feed = n.feed +local fn = n.fn +local api = n.api +local source = n.source +local command = n.command +local exec_capture = n.exec_capture local pcall_err = t.pcall_err describe('maparg()', function() diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local clear = t.clear -local fn = t.fn -local command = t.command -local exc_exec = t.exc_exec +local clear = n.clear +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec before_each(clear) diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local command = t.command -local clear = t.clear -local fn = t.fn +local eval = n.eval +local command = n.command +local clear = n.clear +local fn = n.fn local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/modeline_spec.lua b/test/functional/vimscript/modeline_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local clear, command, write_file = t.clear, t.command, t.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear, command, write_file = n.clear, n.command, t.write_file describe('modeline', function() local tempfile = t.tmpname() diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local fn = t.fn -local eval, eq = t.eval, t.eq -local command = t.command -local api = t.api -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local fn = n.fn +local eval, eq = n.eval, t.eq +local command = n.command +local api = n.api +local exc_exec = n.exc_exec local is_os = t.is_os describe('msgpack*() functions', function() @@ -469,12 +471,12 @@ describe('msgpackparse() function', function() end) it('msgpackparse(systemlist(...)) does not segfault. #3135', function() - local cmd = "sort(keys(msgpackparse(systemlist('" .. t.nvim_prog .. " --api-info'))[0]))" + local cmd = "sort(keys(msgpackparse(systemlist('" .. n.nvim_prog .. " --api-info'))[0]))" eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again if is_os('win') then - t.assert_alive() + n.assert_alive() pending('msgpackparse() has a bug on windows') return end diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local exc_exec = t.exc_exec -local command = t.command -local clear = t.clear -local api = t.api -local fn = t.fn +local exc_exec = n.exc_exec +local command = n.command +local clear = n.clear +local api = n.api +local fn = n.fn local eq = t.eq local function redir_exec(cmd) diff --git a/test/functional/vimscript/operators_spec.lua b/test/functional/vimscript/operators_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local eval = t.eval -local clear = t.clear +local eval = n.eval +local clear = n.clear describe('Division operator', function() before_each(clear) diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local fn = t.fn -local api = t.api -local exc_exec = t.exc_exec +local eval = n.eval +local fn = n.fn +local api = n.api +local exc_exec = n.exc_exec describe('printf()', function() before_each(clear) diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eq, ok = t.clear, t.eq, t.ok -local neq, command, fn = t.neq, t.command, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, ok = n.clear, t.eq, t.ok +local neq, command, fn = t.neq, n.command, n.fn local matches = t.matches local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eq, neq = t.clear, t.eq, t.neq -local command, api, fn = t.command, t.api, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, neq = n.clear, t.eq, t.neq +local command, api, fn = n.command, n.api, n.fn local tbl_deep_extend = vim.tbl_deep_extend -- Set up two overlapping floating windows diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eq, api = t.clear, t.eq, t.api -local command, fn = t.command, t.fn -local feed = t.feed +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, api = n.clear, t.eq, n.api +local command, fn = n.command, n.fn +local feed = n.feed before_each(clear) diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local assert_log = t.assert_log -local eq, neq, eval = t.eq, t.neq, t.eval -local clear, fn, api = t.clear, t.fn, t.api +local eq, neq, eval = t.eq, t.neq, n.eval +local clear, fn, api = n.clear, n.fn, n.api local ok = t.ok local matches = t.matches local pcall_err = t.pcall_err -local check_close = t.check_close +local check_close = n.check_close local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local is_os = t.is_os local testlog = 'Xtest-server-log' @@ -148,7 +150,7 @@ describe('server', function() it('serverlist() returns the list of servers', function() clear() -- There should already be at least one server. - local n = eval('len(serverlist())') + local _n = eval('len(serverlist())') -- Add some servers. local servs = ( @@ -162,25 +164,25 @@ describe('server', function() local new_servs = eval('serverlist()') -- Exactly #servs servers should be added. - eq(n + #servs, #new_servs) + eq(_n + #servs, #new_servs) -- The new servers should be at the end of the list. for i = 1, #servs do - eq(servs[i], new_servs[i + n]) + eq(servs[i], new_servs[i + _n]) eq(1, eval("serverstop('" .. servs[i] .. "')")) end -- After serverstop() the servers should NOT be in the list. - eq(n, eval('len(serverlist())')) + eq(_n, eval('len(serverlist())')) end) end) describe('startup --listen', function() it('validates', function() clear() - local cmd = { unpack(t.nvim_argv) } + local cmd = { unpack(n.nvim_argv) } table.insert(cmd, '--listen') matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd)) - cmd = { unpack(t.nvim_argv) } + cmd = { unpack(n.nvim_argv) } table.insert(cmd, '--listen2') matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd)) end) diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() -local setpos = t.fn.setpos -local getpos = t.fn.getpos -local insert = t.insert -local clear = t.clear -local command = t.command -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local setpos = n.fn.setpos +local getpos = n.fn.getpos +local insert = n.insert +local clear = n.clear +local command = n.command +local eval = n.eval local eq = t.eq -local exc_exec = t.exc_exec +local exc_exec = n.exc_exec describe('setpos() function', function() before_each(function() diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local NIL = vim.NIL -local eval = t.eval -local clear = t.clear -local api = t.api -local fn = t.fn -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local clear = n.clear +local api = n.api +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local exc_exec = t.exc_exec -local command = t.command -local fn = t.fn -local clear = t.clear -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exc_exec = n.exc_exec +local command = n.command +local fn = n.fn +local clear = n.clear +local eval = n.eval local eq = t.eq -local api = t.api +local api = n.api local NIL = vim.NIL describe('Special values', function() diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local exec = t.exec -local exec_lua = t.exec_lua -local feed = t.feed -local api = t.api -local poke_eventloop = t.poke_eventloop +local exec = n.exec +local exec_lua = n.exec_lua +local feed = n.feed +local api = n.api +local poke_eventloop = n.poke_eventloop before_each(clear) diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local command = t.command -local api = t.api -local eval = t.eval -local exc_exec = t.exc_exec +local command = n.command +local api = n.api +local eval = n.eval +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn local NIL = vim.NIL -local source = t.source +local source = n.source describe('string() function', function() before_each(clear) diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua @@ -1,21 +1,21 @@ -- Tests for system() and :! shell. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local testprg = t.testprg +local assert_alive = n.assert_alive +local testprg = n.testprg local eq, call, clear, eval, feed_command, feed, api = - t.eq, t.call, t.clear, t.eval, t.feed_command, t.feed, t.api -local command = t.command -local insert = t.insert -local expect = t.expect -local exc_exec = t.exc_exec -local os_kill = t.os_kill + t.eq, n.call, n.clear, n.eval, n.feed_command, n.feed, n.api +local command = n.command +local insert = n.insert +local expect = n.expect +local exc_exec = n.exc_exec +local os_kill = n.os_kill local pcall_err = t.pcall_err local is_os = t.is_os -local Screen = require('test.functional.ui.screen') - local function create_file_with_nuls(name) return function() feed('ipart1<C-V>000part2<C-V>000part3<ESC>:w ' .. name .. '<CR>') @@ -183,7 +183,7 @@ describe('system()', function() end) it('with powershell', function() - t.set_shell_powershell() + n.set_shell_powershell() eq('a\nb\n', eval([[system('Write-Output a b')]])) eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]])) eq('a b\n', eval([[system('Write-Output "a b"')]])) @@ -191,11 +191,11 @@ describe('system()', function() end it('powershell w/ UTF-8 text #13713', function() - if not t.has_powershell() then + if not n.has_powershell() then pending('powershell not found', function() end) return end - t.set_shell_powershell() + n.set_shell_powershell() eq('ああ\n', eval([[system('Write-Output "ああ"')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -241,8 +241,8 @@ describe('system()', function() feed(':edit ' .. tempfile .. '<cr>') - local command_total_time = tonumber(t.fn.split(t.fn.getline(7))[2]) - local command_self_time = tonumber(t.fn.split(t.fn.getline(7))[3]) + local command_total_time = tonumber(n.fn.split(n.fn.getline(7))[2]) + local command_self_time = tonumber(n.fn.split(n.fn.getline(7))[3]) t.neq(nil, command_total_time) t.neq(nil, command_self_time) @@ -548,11 +548,11 @@ describe('systemlist()', function() end) it('powershell w/ UTF-8 text #13713', function() - if not t.has_powershell() then + if not n.has_powershell() then pending('powershell not found', function() end) return end - t.set_shell_powershell() + n.set_shell_powershell() eq({ is_os('win') and 'あ\r' or 'あ' }, eval([[systemlist('Write-Output あ')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -568,7 +568,7 @@ describe('shell :!', function() it(':{range}! with powershell filter/redirect #16271 #19250', function() local screen = Screen.new(500, 8) screen:attach() - local found = t.set_shell_powershell(true) + local found = n.set_shell_powershell(true) insert([[ 3 1 @@ -615,12 +615,12 @@ describe('shell :!', function() } end feed('<CR>') - t.set_shell_powershell(true) + n.set_shell_powershell(true) feed(':4verbose %w !sort<cr>') screen:expect { any = [[Executing command: .?& { Get%-Content .* | & sort }]], } feed('<CR>') - t.expect_exit(command, 'qall!') + n.expect_exit(command, 'qall!') end) end) diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, eq, eval, ok = t.feed, t.eq, t.eval, t.ok -local source, async_meths, run = t.source, t.async_meths, t.run -local clear, command, fn = t.clear, t.command, t.fn -local exc_exec = t.exc_exec -local api = t.api -local load_adjust = t.load_adjust + +local feed, eq, eval, ok = n.feed, t.eq, n.eval, t.ok +local source, async_meths, run = n.source, n.async_meths, n.run +local clear, command, fn = n.clear, n.command, n.fn +local exc_exec = n.exc_exec +local api = n.api +local load_adjust = n.load_adjust local retry = t.retry describe('timers', function() diff --git a/test/functional/vimscript/uniq_spec.lua b/test/functional/vimscript/uniq_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local command = t.command -local exc_exec = t.exc_exec +local clear = n.clear +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/vvar_event_spec.lua b/test/functional/vimscript/vvar_event_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local command = n.command describe('v:event', function() before_each(clear) it('is empty before any autocommand', function() diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local call = t.call -local clear = t.clear -local command = t.command -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local call = n.call +local clear = n.clear +local command = n.command +local eval = n.eval local eq = t.eq -local feed = t.feed -local feed_command = t.feed_command -local next_msg = t.next_msg -local api = t.api -local source = t.source +local feed = n.feed +local feed_command = n.feed_command +local next_msg = n.next_msg +local api = n.api +local source = n.source local pcall_err = t.pcall_err before_each(function() diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local mkdir = t.mkdir -local clear = t.clear +local clear = n.clear local eq = t.eq -local fn = t.fn -local api = t.api -local exc_exec = t.exc_exec +local fn = n.fn +local api = n.api +local exc_exec = n.exc_exec local read_file = t.read_file local write_file = t.write_file local pcall_err = t.pcall_err -local command = t.command +local command = n.command local fname = 'Xtest-functional-eval-writefile' local dname = fname .. '.d' diff --git a/test/old/testdir/load.vim b/test/old/testdir/load.vim @@ -1,4 +1,4 @@ -" Also used by: test/functional/testutil.lua +" Also used by: test/functional/testnvim.lua function! s:load_factor() abort let timeout = 200 diff --git a/test/testutil.lua b/test/testutil.lua @@ -16,6 +16,7 @@ local function shell_quote(str) return str end +--- This module uses functions from the context of the test runner. --- @class test.testutil local M = { paths = Paths, @@ -254,7 +255,7 @@ function M.pcall_err_withtrace(fn, ...) return ( errmsg - :gsub('^%.%.%./testutil%.lua:0: ', '') + :gsub('^%.%.%./testnvim%.lua:0: ', '') :gsub('^Error executing lua:- ', '') :gsub('^%[string "<nvim>"%]:0: ', '') ) @@ -776,4 +777,54 @@ function M.mkdir(path) return (uv.fs_mkdir(path, 493)) end +--- @param expected any[] +--- @param received any[] +--- @param kind string +--- @return any +function M.expect_events(expected, received, kind) + if not pcall(M.eq, expected, received) then + local msg = 'unexpected ' .. kind .. ' received.\n\n' + + msg = msg .. 'received events:\n' + for _, e in ipairs(received) do + msg = msg .. ' ' .. vim.inspect(e) .. ';\n' + end + msg = msg .. '\nexpected events:\n' + for _, e in ipairs(expected) do + msg = msg .. ' ' .. vim.inspect(e) .. ';\n' + end + M.fail(msg) + end + return received +end + +--- @param cond boolean +--- @param reason? string +--- @return boolean +function M.skip(cond, reason) + if cond then + --- @type fun(reason: string) + local pending = getfenv(2).pending + pending(reason or 'FIXME') + return true + end + return false +end + +-- Calls pending() and returns `true` if the system is too slow to +-- run fragile or expensive tests. Else returns `false`. +function M.skip_fragile(pending_fn, cond) + if pending_fn == nil or type(pending_fn) ~= type(function() end) then + error('invalid pending_fn') + end + if cond then + pending_fn('skipped (test is fragile on this system)', function() end) + return true + elseif os.getenv('TEST_SKIP_FRAGILE') then + pending_fn('skipped (TEST_SKIP_FRAGILE)', function() end) + return true + end + return false +end + return M