patch 9.1.0791: tests: errors in gen_opt_test.vim are not shown

Problem:  tests: errors in gen_opt_test.vim are not shown
Solution: update gen_opt_test.vim and write test.log,
          let the makefile output test.log (Milly)

closes: #15887

Signed-off-by: Milly <milly.ca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
index 2827f99..66b8f1b 100644
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -160,8 +160,14 @@
 	$(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
 	@rm vimcmd
 
-opt_test.vim: ../optiondefs.h gen_opt_test.vim
-	$(VIMPROG) -e -s -u NONE $(NO_INITS) --nofork --gui-dialog-file guidialog -S gen_opt_test.vim ../optiondefs.h
+GEN_OPT_DEPS = gen_opt_test.vim ../optiondefs.h
+
+opt_test.vim: $(GEN_OPT_DEPS)
+	$(VIMPROG) -e -s -u NONE $(NO_INITS) --nofork --gui-dialog-file guidialog -S $(GEN_OPT_DEPS)
+	@if test -f test.log; then \
+		cat test.log; \
+		exit 1; \
+	fi
 
 test_xxd.res:
 	XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim