Patch 9.0.1604
Problem:    Errors from the codestyle test are a bit confusing.
Solution:   Use assert_report() with a clearer message.  Avoid a warning for
            an existing swap file.
Files:      src/testdir/test_codestyle.vim, src/testdir/runtest.vim


*** ../vim-9.0.1603/src/testdir/test_codestyle.vim      2023-05-19 
21:40:57.854218815 +0100
--- src/testdir/test_codestyle.vim      2023-06-04 16:52:28.458251897 +0100
***************
*** 1,17 ****
  " Test for checking the source code style.
  
  def Test_source_files()
    for fname in glob('../*.[ch]', 0, 1)
      bwipe!
      exe 'edit ' .. fname
  
      cursor(1, 1)
      var lnum = search(' \t')
!     assert_equal(0, lnum, fname .. ': space before tab')
  
      cursor(1, 1)
      lnum = search('\s$')
!     assert_equal(0, lnum, fname .. ': trailing white space')
  
      # some files don't stick to the Vim style rules
      if fname =~ 'iscygpty.c'
--- 1,24 ----
  " Test for checking the source code style.
  
+ def s:ReportError(fname: string, lnum: number, msg: string)
+   if lnum > 0
+     assert_report(fname .. ' line ' .. lnum .. ': ' .. msg)
+   endif
+ enddef
+ 
  def Test_source_files()
    for fname in glob('../*.[ch]', 0, 1)
      bwipe!
+     g:ignoreSwapExists = 'e'
      exe 'edit ' .. fname
  
      cursor(1, 1)
      var lnum = search(' \t')
!     ReportError(fname, lnum, 'space before Tab')
  
      cursor(1, 1)
      lnum = search('\s$')
!     ReportError(fname, lnum, 'trailing white space')
  
      # some files don't stick to the Vim style rules
      if fname =~ 'iscygpty.c'
***************
*** 25,46 ****
      var skip = 'getline(".") =~ "condition) {" || getline(".") =~ 
"vimglob_func" || getline(".") =~ "{\"" || getline(".") =~ "{\\d" || 
getline(".") =~ "{{{"'
      cursor(1, 1)
      lnum = search(')\s*{', '', 0, 0, skip)
!     assert_equal(0, lnum, fname .. ': curly after closing paren')
  
      # Examples in comments use double quotes.
      skip = "getline('.') =~ '\"'"
  
      cursor(1, 1)
      lnum = search('}\s*else', '', 0, 0, skip)
!     assert_equal(0, lnum, fname .. ': curly before "else"')
  
      cursor(1, 1)
      lnum = search('else\s*{', '', 0, 0, skip)
!     assert_equal(0, lnum, fname .. ': curly after "else"')
  
      cursor(1, 1)
      lnum = search('\<\(if\|while\|for\)(', '', 0, 0, skip)
!     assert_equal(0, lnum, fname .. ': missing white space after 
"if"/"while"/"for"')
    endfor
  
    bwipe!
--- 32,53 ----
      var skip = 'getline(".") =~ "condition) {" || getline(".") =~ 
"vimglob_func" || getline(".") =~ "{\"" || getline(".") =~ "{\\d" || 
getline(".") =~ "{{{"'
      cursor(1, 1)
      lnum = search(')\s*{', '', 0, 0, skip)
!     ReportError(fname, lnum, 'curly after closing paren')
  
      # Examples in comments use double quotes.
      skip = "getline('.') =~ '\"'"
  
      cursor(1, 1)
      lnum = search('}\s*else', '', 0, 0, skip)
!     ReportError(fname, lnum, 'curly before "else"')
  
      cursor(1, 1)
      lnum = search('else\s*{', '', 0, 0, skip)
!     ReportError(fname, lnum, 'curly after "else"')
  
      cursor(1, 1)
      lnum = search('\<\(if\|while\|for\)(', '', 0, 0, skip)
!     ReportError(fname, lnum, 'missing white space after "if"/"while"/"for"')
    endfor
  
    bwipe!
***************
*** 48,53 ****
--- 55,61 ----
  
  def Test_test_files()
    for fname in glob('*.vim', 0, 1)
+     g:ignoreSwapExists = 'e'
      exe 'edit ' .. fname
  
      # some files intentionally have misplaced white space
***************
*** 61,67 ****
          && fname !~ 'test_visual.vim'
        cursor(1, 1)
        var lnum = search(fname =~ "test_regexp_latin" ? '[^á] \t' : ' \t')
!       assert_equal(0, lnum, 'testdir/' .. fname .. ': space before tab')
      endif
  
      # skip files that are known to have trailing white space
--- 69,75 ----
          && fname !~ 'test_visual.vim'
        cursor(1, 1)
        var lnum = search(fname =~ "test_regexp_latin" ? '[^á] \t' : ' \t')
!       ReportError('testdir/' .. fname, lnum, 'space before Tab')
      endif
  
      # skip files that are known to have trailing white space
***************
*** 76,82 ****
            : fname =~ 'test_vim9_script.vim' ? '[^,:3]\s$'
            : fname =~ 'test_visual.vim' ? '[^/]\s$'
            : '[^\\]\s$')
!       assert_equal(0, lnum, 'testdir/' .. fname .. ': trailing white space')
      endif
    endfor
  
--- 84,90 ----
            : fname =~ 'test_vim9_script.vim' ? '[^,:3]\s$'
            : fname =~ 'test_visual.vim' ? '[^/]\s$'
            : '[^\\]\s$')
!       ReportError('testdir/' .. fname, lnum, 'trailing white space')
      endif
    endfor
  
***************
*** 88,93 ****
--- 96,102 ----
    set nowrapscan
  
    for fpath in glob('../../runtime/doc/*.txt', 0, 1)
+     g:ignoreSwapExists = 'e'
      exe 'edit ' .. fpath
  
      var fname = fnamemodify(fpath, ":t")
***************
*** 106,112 ****
          || fname == 'usr_27.txt' && getline(lnum) =~ "\[^\? \t\]"
          continue
        endif
!       assert_equal(0, lnum, fpath .. ': space before tab')
        if lnum == 0
          break
        endif
--- 115,121 ----
          || fname == 'usr_27.txt' && getline(lnum) =~ "\[^\? \t\]"
          continue
        endif
!       ReportError(fpath, lnum, 'space before tab')
        if lnum == 0
          break
        endif
***************
*** 123,140 ****
          || fname == 'change.txt' && getline(lnum) =~ "foobar bla $"
          continue
        endif
!       assert_equal(0, lnum, fpath .. ': trailing white space')
        if lnum == 0
          break
        endif
      endwhile
  
!     # TODO: Do check and fix help files
! #    # Check over 80 columns
  #    cursor(1, 1)
  #    while 1
  #      lnum = search('\%>80v.*$')
! #      assert_equal(0, lnum, fpath .. ': line over 80 columns')
  #      if lnum == 0
  #        break
  #      endif
--- 132,148 ----
          || fname == 'change.txt' && getline(lnum) =~ "foobar bla $"
          continue
        endif
!       ReportError('testdir' .. fpath, lnum, 'trailing white space')
        if lnum == 0
          break
        endif
      endwhile
  
! #    # TODO: Check for line over 80 columns
  #    cursor(1, 1)
  #    while 1
  #      lnum = search('\%>80v.*$')
! #      ReportError(fpath, lnum, 'line over 80 columns')
  #      if lnum == 0
  #        break
  #      endif
*** ../vim-9.0.1603/src/testdir/runtest.vim     2023-01-28 19:18:56.725720605 
+0000
--- src/testdir/runtest.vim     2023-06-04 16:53:47.626311774 +0100
***************
*** 111,119 ****
--- 111,123 ----
  else
    let s:test_script_fname = expand('%')
  endif
+ 
  au! SwapExists * call HandleSwapExists()
  func HandleSwapExists()
    if exists('g:ignoreSwapExists')
+     if type(g:ignoreSwapExists) == v:t_string
+       let v:swapchoice = g:ignoreSwapExists
+     endif
      return
    endif
    " Ignore finding a swap file for the test script (the user might be
*** ../vim-9.0.1603/src/version.c       2023-06-03 22:08:11.526360596 +0100
--- src/version.c       2023-06-04 16:37:17.687269957 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1604,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
113. You are asked about a bus schedule, you wonder if it is 16 or 32 bits.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230604155557.D07261C0595%40moolenaar.net.

Raspunde prin e-mail lui