summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/starting.txt7
-rw-r--r--src/Make_mvc.mak2
-rw-r--r--src/gui.c23
-rw-r--r--src/main.c30
-rw-r--r--src/message.c6
-rw-r--r--src/os_mswin.c5
-rw-r--r--src/proto/gui.pro1
-rw-r--r--src/proto/main.pro1
-rw-r--r--src/structs.h3
-rw-r--r--src/testdir/Make_dos.mak19
-rw-r--r--src/testdir/Make_ming.mak19
-rw-r--r--src/testdir/Makefile4
-rw-r--r--src/testdir/runtest.vim6
-rw-r--r--src/testdir/shared.vim1
-rw-r--r--src/version.c2
15 files changed, 111 insertions, 18 deletions
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index f50462a56a..aa6fc838ed 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -431,6 +431,13 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
Also avoids the "Reading from stdin..." message.
Also avoids the "N files to edit" message.
+--gui-dialog-file {name} *--gui-dialog-file*
+ When using the GUI, instead of showing a dialog, write the
+ title and message of the dialog to file {name}. The file is
+ careted or appended to. Only useful for testing, to avoid
+ that the test gets stuck on a dialog that can't be seen.
+ Without the GUI the argument is ignored.
+
*--ttyfail*
--ttyfail When the stdin or stdout is not a terminal (tty) then exit
right away.
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index aaaf5303dd..52282cb1e7 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -1466,7 +1466,7 @@ test:
$(MAKE) /NOLOGO -f Make_dos.mak
cd ..
-testgvim:
+testgvim testgui:
cd testdir
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\gvim
cd ..
diff --git a/src/gui.c b/src/gui.c
index 3b0ebac3f6..68c64d298e 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -5641,3 +5641,26 @@ check_for_interrupt(int key, int modifiers_arg)
return NUL;
}
+/*
+ * If the "--gui-log-file fname" argument is given write the dialog title and
+ * message to a file and return TRUE. Otherwise return FALSE.
+ * When there is any problem opening the file or writing to the file this is
+ * ignored, showing the dialog might get the test to get stuck.
+ */
+ int
+gui_dialog_log(char_u *title, char_u *message)
+{
+ char_u *fname = get_gui_dialog_file();
+ FILE *fd;
+
+ if (fname == NULL)
+ return FALSE;
+
+ fd = mch_fopen((char *)fname, "a");
+ if (fd != NULL)
+ {
+ fprintf(fd, "%s: %s\n", title, message);
+ fclose(fd);
+ }
+ return TRUE;
+}
diff --git a/src/main.c b/src/main.c
index b92be4cfef..3d86796906 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1025,6 +1025,17 @@ is_not_a_term_or_gui()
;
}
+#if defined(FEAT_GUI) || defined(PROTO)
+/*
+ * If a --gui-dialog-file argument was given return the file name.
+ * Otherwise return NULL.
+ */
+ char_u *
+get_gui_dialog_file(void)
+{
+ return params.gui_dialog_file;
+}
+#endif
// When TRUE in a safe state when starting to wait for a character.
static int was_safe = FALSE;
@@ -2009,6 +2020,7 @@ command_line_scan(mparm_T *parmp)
// "--log fname" start logging early
// "--nofork" don't fork
// "--not-a-term" don't warn for not a term
+ // "--gui-dialog-file fname" write dialog text
// "--ttyfail" exit if not a term
// "--noplugin[s]" skip plugins
// "--cmd <cmd>" execute cmd before vimrc
@@ -2052,6 +2064,12 @@ command_line_scan(mparm_T *parmp)
p_lpl = FALSE;
else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0)
parmp->not_a_term = TRUE;
+ else if (STRNICMP(argv[0] + argv_idx, "gui-dialog-file", 15)
+ == 0)
+ {
+ want_argument = TRUE;
+ argv_idx += 15;
+ }
else if (STRNICMP(argv[0] + argv_idx, "ttyfail", 7) == 0)
parmp->tty_fail = TRUE;
else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0)
@@ -2448,6 +2466,15 @@ command_line_scan(mparm_T *parmp)
parmp->pre_commands[parmp->n_pre_commands++] =
(char_u *)argv[0];
}
+ // --gui-dialog-file fname
+ if (argv[-1][2] == 'g')
+ {
+ // without GUI ignore the argument
+#ifdef FEAT_GUI
+ parmp->gui_dialog_file = (char_u *)argv[0];
+#endif
+ }
+
// "--startuptime <file>" already handled
// "--log <file>" already handled
break;
@@ -3515,6 +3542,9 @@ usage(void)
#endif
main_msg(_("-T <terminal>\tSet terminal type to <terminal>"));
main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal"));
+#ifdef FEAT_GUI
+ main_msg(_("--gui-dialog-file {fname} For testing: write dialog text"));
+#endif
main_msg(_("--ttyfail\t\tExit if input or output is not a terminal"));
main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc"));
#ifdef FEAT_GUI
diff --git a/src/message.c b/src/message.c
index ed9b532512..3c9e4a0119 100644
--- a/src/message.c
+++ b/src/message.c
@@ -3798,7 +3798,11 @@ do_dialog(
// When GUI is running and 'c' not in 'guioptions', use the GUI dialog
if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)
{
- c = gui_mch_dialog(type, title, message, buttons, dfltbutton,
+ // --gui-dialog-file: write text to a file
+ if (gui_dialog_log(title, message))
+ c = dfltbutton;
+ else
+ c = gui_mch_dialog(type, title, message, buttons, dfltbutton,
textfield, ex_cmd);
// avoid a hit-enter prompt without clearing the cmdline
need_wait_return = FALSE;
diff --git a/src/os_mswin.c b/src/os_mswin.c
index b6e8d71e43..48a6972035 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -676,7 +676,10 @@ display_errors(void)
for (p = (char *)error_ga.ga_data; *p; ++p)
if (!isspace(*p))
{
- (void)gui_mch_dialog(
+ // Only use a dialog when not using --gui-dialog-file:
+ // write text to a file.
+ if (!gui_dialog_log((char_u *)"Errors", p))
+ (void)gui_mch_dialog(
gui.starting ? VIM_INFO :
VIM_ERROR,
gui.starting ? (char_u *)_("Message") :
diff --git a/src/proto/gui.pro b/src/proto/gui.pro
index 209e7f12e4..2a0ac806f0 100644
--- a/src/proto/gui.pro
+++ b/src/proto/gui.pro
@@ -67,4 +67,5 @@ char_u *get_find_dialog_text(char_u *arg, int *wwordp, int *mcasep);
int gui_do_findrepl(int flags, char_u *find_text, char_u *repl_text, int down);
void gui_handle_drop(int x, int y, int_u modifiers, char_u **fnames, int count);
int check_for_interrupt(int key, int modifiers_arg);
+int gui_dialog_log(char_u *title, char_u *message);
/* vim: set ft=c : */
diff --git a/src/proto/main.pro b/src/proto/main.pro
index ff3e1a5037..4368e24fc2 100644
--- a/src/proto/main.pro
+++ b/src/proto/main.pro
@@ -2,6 +2,7 @@
int vim_main2(void);
void common_init(mparm_T *paramp);
int is_not_a_term(void);
+char_u *get_gui_dialog_file(void);
int op_pending(void);
void may_trigger_safestate(int safe);
void state_no_longer_safe(char *reason);
diff --git a/src/structs.h b/src/structs.h
index 58152b98bf..7fe97fdbb3 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4207,6 +4207,9 @@ typedef struct
int want_full_screen;
int not_a_term; // no warning for missing term?
+#ifdef FEAT_GUI
+ char_u *gui_dialog_file; // file to write dialog text in
+#endif
int tty_fail; // exit if not a tty
char_u *term; // specified terminal name
#ifdef FEAT_CRYPT
diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak
index 89563848ec..9d1dc4ecc2 100644
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -19,6 +19,9 @@ DOSTMP_INFILES = $(DOSTMP_OUTFILES:.out=.in)
.SUFFIXES: .in .out .res .vim
+# Add --gui-dialog-file to avoid getting stuck in a dialog.
+COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog
+
nongui: nolog tinytests newtests report
gui: nolog tinytests newtests report
@@ -31,7 +34,7 @@ report:
@rem without the +eval feature test_result.log is a copy of test.log
@if exist test.log ( copy /y test.log test_result.log > nul ) \
else ( echo No failures reported > test_result.log )
- $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
@echo.
@echo Test results:
@cmd /c type test_result.log
@@ -70,6 +73,8 @@ clean:
-if exist messages del messages
-if exist benchmark.out del benchmark.out
-if exist opt_test.vim del opt_test.vim
+ -if exist guidialog del guidialog
+ -if exist guidialogfile del guidialogfile
nolog:
-if exist test.log del test.log
@@ -84,7 +89,7 @@ tinytests: $(SCRIPTS_TINY_OUT)
$(DOSTMP_INFILES): $(*B).in
if not exist $(DOSTMP)\NUL md $(DOSTMP)
if exist $@ del $@
- $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $(*B).in
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $(*B).in
# For each input file dostmp/test99.in run the tests.
# This moves test99.in to test99.in.bak temporarily.
@@ -94,7 +99,7 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in
move $(*B).in $(*B).in.bak > nul
copy $(DOSTMP)\$(*B).in $(*B).in > nul
copy $(*B).ok test.ok > nul
- $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(*B).in
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) -s dotest.in $(*B).in
-@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
-@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
-@if exist test.ok del test.ok
@@ -103,7 +108,7 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in
-@if exist XfakeHOME rd /s /q XfakeHOME
-@del X*
-@if exist viminfo del viminfo
- $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \
$(DOSTMP)\$(*B).out
@diff test.out $*.ok & if errorlevel 1 \
( move /y test.out $*.failed > nul \
@@ -123,12 +128,12 @@ newtestssilent: $(NEW_TESTS_RES)
.vim.res:
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
@del vimcmd
test_gui.res: test_gui.vim
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
@del vimcmd
test_gui_init.res: test_gui_init.vim
@@ -142,6 +147,6 @@ opt_test.vim: ../optiondefs.h gen_opt_test.vim
test_bench_regexp.res: test_bench_regexp.vim
-if exist benchmark.out del benchmark.out
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
@del vimcmd
@IF EXIST benchmark.out ( type benchmark.out )
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
index 5e17963c5e..0638adef98 100644
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -31,6 +31,9 @@ DOSTMP = dostmp
.SUFFIXES: .in .out .res .vim
+# Add --gui-dialog-file to avoid getting stuck in a dialog.
+COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog
+
nongui: nolog tinytests newtests report
gui: nolog tinytests newtests report
@@ -43,7 +46,7 @@ report:
@rem without the +eval feature test_result.log is a copy of test.log
@if exist test.log ( copy /y test.log test_result.log > nul ) \
else ( echo No failures reported > test_result.log )
- $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
@echo.
@echo Test results:
@cmd /c type test_result.log
@@ -82,6 +85,8 @@ clean:
-@if exist messages $(DEL) messages
-@if exist benchmark.out del benchmark.out
-@if exist opt_test.vim $(DEL) opt_test.vim
+ -@if exist guidialog $(DEL) guidialog
+ -@if exist guidialogfile $(DEL) guidialogfile
nolog:
-@if exist test.log $(DEL) test.log
@@ -96,7 +101,7 @@ tinytests: $(SCRIPTS_TINY_OUT)
$(DOSTMP)/%.in : %.in
if not exist $(DOSTMP)\nul mkdir $(DOSTMP)
if exist $(DOSTMP)\$< $(DEL) $(DOSTMP)\$<
- $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $<
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $<
# For each input file dostmp/test99.in run the tests.
# This moves test99.in to test99.in.bak temporarily.
@@ -106,7 +111,7 @@ $(DOSTMP)/%.in : %.in
$(MV) $(notdir $<) $(notdir $<).bak > NUL
$(CP) $(DOSTMP)\$(notdir $<) $(notdir $<) > NUL
$(CP) $(basename $@).ok test.ok > NUL
- $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(notdir $<)
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) -s dotest.in $(notdir $<)
-@if exist test.out $(MV) test.out $(DOSTMP)\$@ > NUL
-@if exist $(notdir $<).bak $(MV) $(notdir $<).bak $(notdir $<) > NUL
-@if exist test.ok $(DEL) test.ok
@@ -115,7 +120,7 @@ $(DOSTMP)/%.in : %.in
-@if exist XfakeHOME $(DELDIR) XfakeHOME
-@del X*
-@if exist viminfo del viminfo
- $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
+ $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \
$(DOSTMP)\$@
@diff test.out $(basename $@).ok & if errorlevel 1 \
( $(MV) test.out $(basename $@).failed > NUL \
@@ -135,12 +140,12 @@ newtestssilent: $(NEW_TESTS_RES)
.vim.res:
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
@$(DEL) vimcmd
test_gui.res: test_gui.vim
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $<
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $<
@$(DEL) vimcmd
test_gui_init.res: test_gui_init.vim
@@ -154,6 +159,6 @@ opt_test.vim: ../optiondefs.h gen_opt_test.vim
test_bench_regexp.res: test_bench_regexp.vim
-$(DEL) benchmark.out
@echo $(VIMPROG) > vimcmd
- $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+ $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
@$(DEL) vimcmd
$(CAT) benchmark.out
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
index c782da9dfe..adec1f167e 100644
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -89,6 +89,7 @@ clean:
-rm -rf $(RM_ON_RUN) $(RM_ON_START)
-rm -f valgrind.*
-rm -f asan.*
+ -rm -f guidialog guidialogfile
# Delete the files produced by benchmarking, so they can run again.
benchmarkclean:
@@ -127,7 +128,8 @@ tinytests: $(SCRIPTS_TINY_OUT)
# New style of tests uses Vim script with assert calls. These are easier
# to write and a lot easier to read and debug.
# Limitation: Only works with the +eval feature.
-RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
+# Add --gui-dialog-file to avoid getting stuck in a dialog.
+RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim --gui-dialog-file guidialog
newtests: newtestssilent
@/bin/sh -c "if test -f messages; then cat messages; fi"
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index 766f983cf9..a4c238e8a2 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -245,6 +245,12 @@ func RunTheTest(test)
call popup_clear(1)
endif
+ if filereadable('guidialogfile')
+ call add(v:errors, "Unexpected dialog:")
+ call add(v:errors, readfile('guidialogfile').join('\n'))
+ call delete('guidialogfile')
+ endif
+
" Close any extra tab pages and windows and make the current one not modified.
while tabpagenr('$') > 1
let winid = win_getid()
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index e442a59ec7..60636fd314 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -276,6 +276,7 @@ func GetVimCommand(...)
let cmd = cmd . ' -u ' . name
endif
let cmd .= ' --not-a-term'
+ let cmd .= ' --gui-dialog-file guidialogfile'
let cmd = substitute(cmd, 'VIMRUNTIME=\S\+', '', '')
" If using valgrind, make sure every run uses a different log file.
diff --git a/src/version.c b/src/version.c
index 745f85c108..eef7e5165c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 5084,
+/**/
5083,
/**/
5082,