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/gen_opt_test.vim b/src/testdir/gen_opt_test.vim
index 4ca3c09..372070b 100644
--- a/src/testdir/gen_opt_test.vim
+++ b/src/testdir/gen_opt_test.vim
@@ -192,6 +192,12 @@
       \ 'otherstring': [['', 'xxx'], []],
       \}
 
+const invalid_options = test_values->keys()
+      \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")})
+if !empty(invalid_options)
+  throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'"
+endif
+
 1
 /struct vimoption options
 while 1
@@ -253,11 +259,14 @@
 
 call writefile(script, 'opt_test.vim')
 
-" Exit with error-code if error occurs.
+" Write error messages if error occurs.
 catch
-  set verbose=1
-  echoc 'Error:' v:exception 'in' v:throwpoint
-  cq! 1
+  " Append errors to test.log
+  let error = $'Error: {v:exception} in {v:throwpoint}'
+  echoc error
+  split test.log
+  call append('$', error)
+  write
 endtry
 
 endif