To: vim_dev@googlegroups.com Subject: Patch 8.2.5084 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5084 Problem: When the GUI shows a dialog tests get stuck. Solution: Add the --gui-dialog-file argument. Files: runtime/doc/starting.txt, src/Make_mvc.mak, src/gui.c, src/main.c, src/message.c, src/os_mswin.c, src/proto/gui.pro, src/proto/main.pro, src/structs.h, src/testdir/Make_dos.mak, src/testdir/Make_ming.mak, src/testdir/Makefile, src/testdir/runtest.vim, src/testdir/shared.vim *** ../vim-8.2.5083/runtime/doc/starting.txt 2022-06-04 22:15:48.788982835 +0100 --- runtime/doc/starting.txt 2022-06-13 20:39:37.821111648 +0100 *************** *** 431,436 **** --- 431,443 ---- 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. *** ../vim-8.2.5083/src/Make_mvc.mak 2022-03-07 15:16:11.461689545 +0000 --- src/Make_mvc.mak 2022-06-13 20:34:40.545159063 +0100 *************** *** 1466,1472 **** $(MAKE) /NOLOGO -f Make_dos.mak cd .. ! testgvim: cd testdir $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\gvim cd .. --- 1466,1472 ---- $(MAKE) /NOLOGO -f Make_dos.mak cd .. ! testgvim testgui: cd testdir $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\gvim cd .. *** ../vim-8.2.5083/src/gui.c 2022-05-09 20:09:19.286641426 +0100 --- src/gui.c 2022-06-13 21:32:30.249620467 +0100 *************** *** 5641,5643 **** --- 5641,5666 ---- 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; + } *** ../vim-8.2.5083/src/main.c 2022-06-04 22:15:48.788982835 +0100 --- src/main.c 2022-06-13 21:28:48.508601625 +0100 *************** *** 1025,1030 **** --- 1025,1041 ---- ; } + #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,2014 **** --- 2020,2026 ---- // "--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 " execute cmd before vimrc *************** *** 2052,2057 **** --- 2064,2075 ---- 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,2453 **** --- 2466,2480 ---- 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 " already handled // "--log " already handled break; *************** *** 3515,3520 **** --- 3542,3550 ---- #endif main_msg(_("-T \tSet terminal type to ")); 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 \t\tUse instead of any .vimrc")); #ifdef FEAT_GUI *** ../vim-8.2.5083/src/message.c 2022-06-09 13:55:23.167025955 +0100 --- src/message.c 2022-06-13 20:34:40.549159061 +0100 *************** *** 3798,3804 **** // 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, textfield, ex_cmd); // avoid a hit-enter prompt without clearing the cmdline need_wait_return = FALSE; --- 3798,3808 ---- // When GUI is running and 'c' not in 'guioptions', use the GUI dialog if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL) { ! // --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; *** ../vim-8.2.5083/src/os_mswin.c 2022-06-08 15:13:42.884129614 +0100 --- src/os_mswin.c 2022-06-13 20:34:40.553159061 +0100 *************** *** 676,682 **** for (p = (char *)error_ga.ga_data; *p; ++p) if (!isspace(*p)) { ! (void)gui_mch_dialog( gui.starting ? VIM_INFO : VIM_ERROR, gui.starting ? (char_u *)_("Message") : --- 676,685 ---- for (p = (char *)error_ga.ga_data; *p; ++p) if (!isspace(*p)) { ! // 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") : *** ../vim-8.2.5083/src/proto/gui.pro 2021-10-16 20:52:01.772842109 +0100 --- src/proto/gui.pro 2022-06-13 21:27:25.012293458 +0100 *************** *** 67,70 **** --- 67,71 ---- 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 : */ *** ../vim-8.2.5083/src/proto/main.pro 2020-04-05 19:20:40.104596563 +0100 --- src/proto/main.pro 2022-06-13 21:27:22.100283788 +0100 *************** *** 2,7 **** --- 2,8 ---- 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); *** ../vim-8.2.5083/src/structs.h 2022-06-07 10:16:09.453398794 +0100 --- src/structs.h 2022-06-13 20:34:40.557159061 +0100 *************** *** 4207,4212 **** --- 4207,4215 ---- 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 *** ../vim-8.2.5083/src/testdir/Make_dos.mak 2020-08-26 21:29:53.565864941 +0100 --- src/testdir/Make_dos.mak 2022-06-13 20:34:40.557159061 +0100 *************** *** 19,24 **** --- 19,27 ---- .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,37 **** @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 @echo. @echo Test results: @cmd /c type test_result.log --- 34,40 ---- @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 $(COMMON_ARGS) -S summarize.vim messages @echo. @echo Test results: @cmd /c type test_result.log *************** *** 70,75 **** --- 73,80 ---- -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,90 **** $(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 # For each input file dostmp/test99.in run the tests. # This moves test99.in to test99.in.bak temporarily. --- 89,95 ---- $(DOSTMP_INFILES): $(*B).in if not exist $(DOSTMP)\NUL md $(DOSTMP) if exist $@ del $@ ! $(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,100 **** 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 -@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 --- 99,105 ---- move $(*B).in $(*B).in.bak > nul copy $(DOSTMP)\$(*B).in $(*B).in > nul copy $(*B).ok test.ok > nul ! $(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,109 **** -@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" \ $(DOSTMP)\$(*B).out @diff test.out $*.ok & if errorlevel 1 \ ( move /y test.out $*.failed > nul \ --- 108,114 ---- -@if exist XfakeHOME rd /s /q XfakeHOME -@del X* -@if exist viminfo del viminfo ! $(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,134 **** .vim.res: @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @del vimcmd test_gui.res: test_gui.vim @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @del vimcmd test_gui_init.res: test_gui_init.vim --- 128,139 ---- .vim.res: @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim @del vimcmd test_gui.res: test_gui.vim @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim @del vimcmd test_gui_init.res: test_gui_init.vim *************** *** 142,147 **** 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 @del vimcmd @IF EXIST benchmark.out ( type benchmark.out ) --- 147,152 ---- test_bench_regexp.res: test_bench_regexp.vim -if exist benchmark.out del benchmark.out @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim @del vimcmd @IF EXIST benchmark.out ( type benchmark.out ) *** ../vim-8.2.5083/src/testdir/Make_ming.mak 2020-09-13 20:01:18.502468650 +0100 --- src/testdir/Make_ming.mak 2022-06-13 20:34:40.561159059 +0100 *************** *** 31,36 **** --- 31,39 ---- .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,49 **** @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 @echo. @echo Test results: @cmd /c type test_result.log --- 46,52 ---- @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 $(COMMON_ARGS) -S summarize.vim messages @echo. @echo Test results: @cmd /c type test_result.log *************** *** 82,87 **** --- 85,92 ---- -@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,102 **** $(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" $< # For each input file dostmp/test99.in run the tests. # This moves test99.in to test99.in.bak temporarily. --- 101,107 ---- $(DOSTMP)/%.in : %.in if not exist $(DOSTMP)\nul mkdir $(DOSTMP) if exist $(DOSTMP)\$< $(DEL) $(DOSTMP)\$< ! $(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,112 **** $(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 $<) -@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 --- 111,117 ---- $(MV) $(notdir $<) $(notdir $<).bak > NUL $(CP) $(DOSTMP)\$(notdir $<) $(notdir $<) > NUL $(CP) $(basename $@).ok test.ok > NUL ! $(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,121 **** -@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" \ $(DOSTMP)\$@ @diff test.out $(basename $@).ok & if errorlevel 1 \ ( $(MV) test.out $(basename $@).failed > NUL \ --- 120,126 ---- -@if exist XfakeHOME $(DELDIR) XfakeHOME -@del X* -@if exist viminfo del viminfo ! $(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,146 **** .vim.res: @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @$(DEL) vimcmd test_gui.res: test_gui.vim @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $< @$(DEL) vimcmd test_gui_init.res: test_gui_init.vim --- 140,151 ---- .vim.res: @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim @$(DEL) vimcmd test_gui.res: test_gui.vim @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $< @$(DEL) vimcmd test_gui_init.res: test_gui_init.vim *************** *** 154,159 **** test_bench_regexp.res: test_bench_regexp.vim -$(DEL) benchmark.out @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @$(DEL) vimcmd $(CAT) benchmark.out --- 159,164 ---- test_bench_regexp.res: test_bench_regexp.vim -$(DEL) benchmark.out @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim @$(DEL) vimcmd $(CAT) benchmark.out *** ../vim-8.2.5083/src/testdir/Makefile 2022-05-27 20:13:24.491044228 +0100 --- src/testdir/Makefile 2022-06-13 20:34:40.561159059 +0100 *************** *** 89,94 **** --- 89,95 ---- -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,133 **** # 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 newtests: newtestssilent @/bin/sh -c "if test -f messages; then cat messages; fi" --- 128,135 ---- # 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. ! # 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" *** ../vim-8.2.5083/src/testdir/runtest.vim 2022-03-20 13:40:37.309000517 +0000 --- src/testdir/runtest.vim 2022-06-13 20:34:40.561159059 +0100 *************** *** 245,250 **** --- 245,256 ---- 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() *** ../vim-8.2.5083/src/testdir/shared.vim 2022-05-05 20:46:41.407274630 +0100 --- src/testdir/shared.vim 2022-06-13 20:34:40.561159059 +0100 *************** *** 276,281 **** --- 276,282 ---- 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. *** ../vim-8.2.5083/src/version.c 2022-06-12 23:26:46.132949646 +0100 --- src/version.c 2022-06-13 20:39:47.761110045 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5084, /**/ -- Citizens are not allowed to attend a movie house or theater nor ride in a public streetcar within at least four hours after eating garlic. [real standing law in Indiana, United States of America] /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///