mirror of
https://github.com/vim/vim.git
synced 2025-09-07 22:03:36 -04:00
patch 8.2.4087: cannot test items from an autoload script easily
Problem: Cannot test items from an autoload script easily. Solution: Add the "autoload" value for test_override().
This commit is contained in:
parent
d9d2fd0aa3
commit
3e4fa3d7d3
@ -188,23 +188,25 @@ test_override({name}, {val}) *test_override()*
|
|||||||
to run tests. Only to be used for testing Vim!
|
to run tests. Only to be used for testing Vim!
|
||||||
The override is enabled when {val} is non-zero and removed
|
The override is enabled when {val} is non-zero and removed
|
||||||
when {val} is zero.
|
when {val} is zero.
|
||||||
Current supported values for name are:
|
Current supported values for {name} are:
|
||||||
|
|
||||||
name effect when {val} is non-zero ~
|
{name} effect when {val} is non-zero ~
|
||||||
redraw disable the redrawing() function
|
autoload `import autoload` will load the script right
|
||||||
redraw_flag ignore the RedrawingDisabled flag
|
away, not postponed until an item is used
|
||||||
char_avail disable the char_avail() function
|
char_avail disable the char_avail() function
|
||||||
starting reset the "starting" variable, see below
|
|
||||||
nfa_fail makes the NFA regexp engine fail to force a
|
nfa_fail makes the NFA regexp engine fail to force a
|
||||||
fallback to the old engine
|
fallback to the old engine
|
||||||
no_query_mouse do not query the mouse position for "dec"
|
no_query_mouse do not query the mouse position for "dec"
|
||||||
terminals
|
terminals
|
||||||
no_wait_return set the "no_wait_return" flag. Not restored
|
no_wait_return set the "no_wait_return" flag. Not restored
|
||||||
with "ALL".
|
with "ALL".
|
||||||
ui_delay time in msec to use in ui_delay(); overrules a
|
redraw disable the redrawing() function
|
||||||
wait time of up to 3 seconds for messages
|
redraw_flag ignore the RedrawingDisabled flag
|
||||||
|
starting reset the "starting" variable, see below
|
||||||
term_props reset all terminal properties when the version
|
term_props reset all terminal properties when the version
|
||||||
string is detected
|
string is detected
|
||||||
|
ui_delay time in msec to use in ui_delay(); overrules a
|
||||||
|
wait time of up to 3 seconds for messages
|
||||||
uptime overrules sysinfo.uptime
|
uptime overrules sysinfo.uptime
|
||||||
ALL clear all overrides ({val} is not used)
|
ALL clear all overrides ({val} is not used)
|
||||||
|
|
||||||
|
@ -1643,6 +1643,7 @@ EXTERN int no_query_mouse_for_testing INIT(= FALSE);
|
|||||||
EXTERN int ui_delay_for_testing INIT(= 0);
|
EXTERN int ui_delay_for_testing INIT(= 0);
|
||||||
EXTERN int reset_term_props_on_termresponse INIT(= FALSE);
|
EXTERN int reset_term_props_on_termresponse INIT(= FALSE);
|
||||||
EXTERN long override_sysinfo_uptime INIT(= -1);
|
EXTERN long override_sysinfo_uptime INIT(= -1);
|
||||||
|
EXTERN int override_autoload INIT(= FALSE);
|
||||||
|
|
||||||
EXTERN int in_free_unref_items INIT(= FALSE);
|
EXTERN int in_free_unref_items INIT(= FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1288,6 +1288,42 @@ def Test_import_autoload_postponed()
|
|||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_import_autoload_override()
|
||||||
|
mkdir('Xdir/autoload', 'p')
|
||||||
|
var save_rtp = &rtp
|
||||||
|
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||||
|
test_override('autoload', 1)
|
||||||
|
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script autoload
|
||||||
|
|
||||||
|
g:loaded_override = 'true'
|
||||||
|
export var variable = 'bla'
|
||||||
|
export def Function(): string
|
||||||
|
return 'bla'
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xdir/autoload/override.vim')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
import autoload 'override.vim'
|
||||||
|
assert_equal('true', g:loaded_override)
|
||||||
|
|
||||||
|
def Tryit()
|
||||||
|
echo override.doesNotExist
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1)
|
||||||
|
|
||||||
|
test_override('autoload', 0)
|
||||||
|
unlet g:loaded_override
|
||||||
|
delete('Xdir', 'rf')
|
||||||
|
&rtp = save_rtp
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_autoload_mapping()
|
def Test_autoload_mapping()
|
||||||
mkdir('Xdir/autoload', 'p')
|
mkdir('Xdir/autoload', 'p')
|
||||||
var save_rtp = &rtp
|
var save_rtp = &rtp
|
||||||
|
@ -1055,6 +1055,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
reset_term_props_on_termresponse = val;
|
reset_term_props_on_termresponse = val;
|
||||||
else if (STRCMP(name, (char_u *)"uptime") == 0)
|
else if (STRCMP(name, (char_u *)"uptime") == 0)
|
||||||
override_sysinfo_uptime = val;
|
override_sysinfo_uptime = val;
|
||||||
|
else if (STRCMP(name, (char_u *)"autoload") == 0)
|
||||||
|
override_autoload = val;
|
||||||
else if (STRCMP(name, (char_u *)"ALL") == 0)
|
else if (STRCMP(name, (char_u *)"ALL") == 0)
|
||||||
{
|
{
|
||||||
disable_char_avail_for_testing = FALSE;
|
disable_char_avail_for_testing = FALSE;
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4087,
|
||||||
/**/
|
/**/
|
||||||
4086,
|
4086,
|
||||||
/**/
|
/**/
|
||||||
|
@ -496,6 +496,9 @@ handle_import(
|
|||||||
if (si->sn_autoload_prefix == NULL)
|
if (si->sn_autoload_prefix == NULL)
|
||||||
si->sn_autoload_prefix = get_autoload_prefix(si);
|
si->sn_autoload_prefix = get_autoload_prefix(si);
|
||||||
res = OK;
|
res = OK;
|
||||||
|
if (override_autoload && si->sn_state == SN_STATE_NOT_LOADED)
|
||||||
|
// testing override: load autoload script right away
|
||||||
|
(void)do_source(si->sn_name, FALSE, DOSO_NONE, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = FAIL;
|
res = FAIL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user