[vim/vim] Fix #12718 (PR #14792)

45 views
Skip to first unread message

ubaldot

unread,
May 17, 2024, 7:56:17 AMMay 17
to vim/vim, Subscribed

Hi!

This is my proposal for fixing #12718
I could have done something even more robust, like

if empty(glob('gdb'))
     file gdb
  elseif empty(glob(' Termdebug-gdb-console'))
     file Termdebug-gdb-console
  else
    Echoerr("You have a file/folder named 'gdb' or 'Termdebug-gdb-console'. Termdebug cannot start. Please rename them. ")
endif

Shall the same if-then-else condition be placed in other lines of the form file <hard-coded name> ?


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14792

Commit Summary

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792@github.com>

Christian Brabandt

unread,
May 17, 2024, 12:17:21 PMMay 17
to vim/vim, Subscribed

Thanks, are there other places where this could clash? I think the warning approach is good, although you have a leading white space inside your glob() function. Can you fix this up and add a test to https://github.com/vim/vim/blob/master/src/testdir/test_termdebug.vim ?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2117939350@github.com>

ubaldot

unread,
May 17, 2024, 12:31:38 PMMay 17
to vim/vim, Subscribed

Sure thing! Yes, there are some other places where this could happen: pretty much everywhere where file command is used. You could /file in the source and see that you have it in other 2-3 places. I can use the same solution there as well. Regarding the tests: I never wrote a test for vimscripts, if there is some guideline it would be great to read! Finally: I will try to fix it during the weekend if I will find some time or during next week. Would that work?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2117962181@github.com>

Christian Brabandt

unread,
May 17, 2024, 12:38:33 PMMay 17
to vim/vim, Subscribed

that sounds perfect. Regarding the tests, just check the existing termdebug test. It's not so hard, you basically need to create a gdb file and then check that either the plugin is not loaded (so you are still in a clean state, e.g. only one single buffer opened), or check if you can see the error message in the messages list. Or something like this :) Thanks for looking into this!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2117974888@github.com>

ubaldot

unread,
May 20, 2024, 4:34:52 AMMay 20
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18498105967@github.com>

ubaldot

unread,
May 20, 2024, 4:50:00 AMMay 20
to vim/vim, Push

@ubaldot pushed 2 commits.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18498314521@github.com>

K.Takata

unread,
May 20, 2024, 4:52:36 AMMay 20
to vim/vim, Subscribed

@k-takata commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> @@ -415,7 +415,17 @@ func s:StartDebug_prompt(dict)
   let s:promptbuf = bufnr('')
   call prompt_setprompt(s:promptbuf, 'gdb> ')
   set buftype=prompt
-  file gdb
+
+  if empty(glob('gdb'))
+    file gdb
+  elseif empty(glob(' Termdebug-gdb-console'))
⬇️ Suggested change
-  elseif empty(glob(' Termdebug-gdb-console'))
+  elseif empty(glob('Termdebug-gdb-console'))

Is this space intentional?


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> @@ -415,7 +415,17 @@ func s:StartDebug_prompt(dict)
   let s:promptbuf = bufnr('')
   call prompt_setprompt(s:promptbuf, 'gdb> ')
   set buftype=prompt
-  file gdb
+
+  if empty(glob('gdb'))
+    file gdb
+  elseif empty(glob(' Termdebug-gdb-console'))
+     file Termdebug-gdb-console
⬇️ Suggested change
-     file Termdebug-gdb-console
+    file Termdebug-gdb-console

wrong indent


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> +    Echoerr("You have a file/folder named 'gdb'
+          \ or 'Termdebug-gdb-console'.
+          \ Termdebug cannot start. Please rename them. ")
⬇️ Suggested change
-    Echoerr("You have a file/folder named 'gdb'
-          \ or 'Termdebug-gdb-console'.
-          \ Termdebug cannot start. Please rename them. ")
+    call s:Echoerr("You have a file/folder named 'gdb'
+          \ or 'Termdebug-gdb-console'.
+          \ Termdebug cannot start. Please rename them.")

In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> +      Echoerr("You have a file/folder named Termdebug-asm-listing'.
+          \ Termdebug cannot start. Please rename such a file/folder. ")
⬇️ Suggested change
-      Echoerr("You have a file/folder named Termdebug-asm-listing'.
-          \ Termdebug cannot start. Please rename such a file/folder. ")
+      call s:Echoerr("You have a file/folder named Termdebug-asm-listing'.
+          \ Termdebug cannot start. Please rename such a file/folder.")

In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> +      Echoerr("You have a file/folder named Termdebug-variables-listing'.
+          \ Termdebug cannot start. Please rename such a file/folder. ")
⬇️ Suggested change
-      Echoerr("You have a file/folder named Termdebug-variables-listing'.
-          \ Termdebug cannot start. Please rename such a file/folder. ")
+      call s:Echoerr("You have a file/folder named Termdebug-variables-listing'.
+          \ Termdebug cannot start. Please rename such a file/folder.")

In src/testdir/test_termdebug.vim:

> +  call writefile(['This', 'is', 'a', 'test'], filename)
+  " Throw away the file once the test has done.
+  execute 'defer ' .. filename
⬇️ Suggested change
-  call writefile(['This', 'is', 'a', 'test'], filename)
-  " Throw away the file once the test has done.
-  execute 'defer ' .. filename
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')

You can use the 'D' flag.


In src/testdir/test_termdebug.vim:

> +  call writefile(['This', 'is', 'a', 'test'], filename)
+  " Throw away the file once the test has done.
+  execute 'defer delete(filename)'
⬇️ Suggested change
-  call writefile(['This', 'is', 'a', 'test'], filename)
-  " Throw away the file once the test has done.
-  execute 'defer delete(filename)'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')

You can use the 'D' flag.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2065695441@github.com>

ubaldot

unread,
May 20, 2024, 4:59:29 AMMay 20
to vim/vim, Subscribed

.. working on it. Please ignore all the pushes until I notify.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2119997319@github.com>

ubaldot

unread,
May 20, 2024, 5:26:05 AMMay 20
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18498832591@github.com>

ubaldot

unread,
May 20, 2024, 5:26:25 AMMay 20
to vim/vim, Subscribed

Try now! :)
Are the tests enough?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2120046478@github.com>

K.Takata

unread,
May 20, 2024, 6:17:01 AMMay 20
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/testdir/test_termdebug.vim:

> @@ -300,4 +300,21 @@ func Test_termdebug_mapping()
   %bw!
 endfunc
 
+func Test_termdebug_bufnames()
+  " Test if user has filename/folders named gdb, Termdebug-gdb-console,
+  " etc. in the current directory
+  let filename = 'gdb'
+  let replacement_filename = 'Termdebug-gdb-console'
+
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Throw away the file once the test has done.
+  execute 'Termdebug'
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(bureplacement_filename))})

Mistake?

⬇️ Suggested change
-  call WaitForAssert({-> assert_true(bufexists(bureplacement_filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2065873605@github.com>

ubaldot

unread,
May 20, 2024, 7:43:20 AMMay 20
to vim/vim, Push

@ubaldot pushed 1 commit.

  • 158668f Added check on error messages list


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18500746245@github.com>

ubaldot

unread,
May 20, 2024, 7:45:00 AMMay 20
to vim/vim, Subscribed

Check it now!
(yes, the previous bureplacement_filename was a typo!)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2120292507@github.com>

ubaldot

unread,
May 20, 2024, 8:23:18 AMMay 20
to vim/vim, Push

@ubaldot pushed 1 commit.

  • 648aedf A typo was still there... now it should be fixed


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18501306923@github.com>

ubaldot

unread,
May 20, 2024, 10:58:53 AMMay 20
to vim/vim, Subscribed

It seems some tests failed due to the following:

Failures: 
	From test_termdebug.vim:
	Found errors in Test_termdebug_bufnames():
	Caught exception in Test_termdebug_bufnames(): Vim(bwipeout):E517: No buffers were wiped out: bwipe! 12 @ command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[607]..function 
	

Most likely it is due to lines 319 and 332 of [src/testdir/test_termdebug.vim](https://github.com/vim/vim/pull/14792/files#diff-07567861d8244d8d0078cb5d13045a8fb5d438ec20af2d2341f648ca6d3b05f7) and it is not super clear to me how to solve it... any hints?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2120633692@github.com>

K.Takata

unread,
May 20, 2024, 4:37:10 PMMay 20
to vim/vim, Subscribed

RunTheTest[57]..Test_termdebug_bufnames[20]..9_EndPromptDebug[9]..9_EndDebugCommon, line 4

The error occurs here:
https://github.com/vim/vim/blob/648aedf7c2e89ad2fb55e2f4d0c4aa81808acd50/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim#L741


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2121166289@github.com>

K.Takata

unread,
May 20, 2024, 4:52:31 PMMay 20
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/testdir/test_termdebug.vim:

> @@ -300,4 +300,42 @@ func Test_termdebug_mapping()
   %bw!
 endfunc
 
+func Test_termdebug_bufnames()
+  " Test if user has filename/folders named gdb, Termdebug-gdb-console,
+  " etc. in the current directory
+  let g:termdebug_config = {}
+  let g:termdebug_config['use_prompt'] = 1
+  let filename = 'gdb'
+  let replacement_filename = 'Termdebug-gdb-console'
+
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Throw away the file once the test has done.
+  execute 'Termdebug'
⬇️ Suggested change
-  execute 'Termdebug'
+  Termdebug

No need to use "execute" if you don't use parameters.


In src/testdir/test_termdebug.vim:

> +  sleep 2
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  %bw!
+
+  " Check if error message is in :message
+  " Delay for securing that Termdebug is shutoff
+  sleep 1
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  execute 'Termdebug'
⬇️ Suggested change
-  execute 'Termdebug'
+  Termdebug

In src/testdir/test_termdebug.vim:

> +  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  %bw!
+
+  " Check if error message is in :message
+  " Delay for securing that Termdebug is shutoff
+  sleep 1
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  execute 'Termdebug'
+  sleep 2
+  call WaitForAssert({->assert_true(stridx(execute('messages'), error_message) != -1 )})
⬇️ Suggested change
-  call WaitForAssert({->assert_true(stridx(execute('messages'), error_message) != -1 )})
+  call WaitForAssert({-> assert_notequal(-1, stridx(execute('messages'), error_message))})

In src/testdir/test_termdebug.vim:

> +  unlet g:termdebug_config
+  unlet filename
+  unlet replacement_filename
+  unlet error_message
⬇️ Suggested change
-  unlet g:termdebug_config
-  unlet filename
-  unlet replacement_filename
-  unlet error_message
+  unlet g:termdebug_config

No need to unlet local variables.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2067003326@github.com>

ubaldot

unread,
May 21, 2024, 4:05:43 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18514895767@github.com>

ubaldot

unread,
May 21, 2024, 4:06:35 AMMay 21
to vim/vim, Subscribed

Working on it... ignore push!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122016165@github.com>

ubaldot

unread,
May 21, 2024, 4:08:37 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18514941710@github.com>

ubaldot

unread,
May 21, 2024, 4:09:07 AMMay 21
to vim/vim, Subscribed

Ready for review. :)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122021100@github.com>

ubaldot

unread,
May 21, 2024, 4:29:55 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.

  • 61f703f execute 'Termdebug'-> Termdebug


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18515285144@github.com>

K.Takata

unread,
May 21, 2024, 6:49:48 AMMay 21
to vim/vim, Subscribed

It seems that the following patch fixes the CI failure:

--- a/src/testdir/test_termdebug.vim
+++ b/src/testdir/test_termdebug.vim
@@ -317,10 +317,9 @@ func Test_termdebug_bufnames()
   call WaitForAssert({-> assert_false(bufexists(filename))})
   call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
   quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
 
   " Check if error message is in :message
-  " Delay for securing that Termdebug is shutoff
-  sleep 1
   let g:termdebug_config['disasm_window'] = 1
   let filename = 'Termdebug-asm-listing'
   call writefile(['This', 'is', 'a', 'test'], filename, 'D')
@@ -328,10 +327,11 @@ func Test_termdebug_bufnames()
   let error_message = "You have a file/folder named '" .. filename .. "'"
   Termdebug
   sleep 2
-  call WaitForAssert({->assert_notequal(-1, stridx(execute('messages'), error_message))})
+  call WaitForAssert({-> assert_notequal(-1, stridx(execute('messages'), error_message))})
   quit!
-  wincmd t
+  wincmd b
   wincmd q
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
 
   unlet g:termdebug_config
 endfunc


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122349582@github.com>

ubaldot

unread,
May 21, 2024, 7:15:36 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.

  • f0ff599 Changes for fixing CI failures implementes


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18518008714@github.com>

ubaldot

unread,
May 21, 2024, 7:15:56 AMMay 21
to vim/vim, Subscribed

Changes implemented.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122397390@github.com>

ubaldot

unread,
May 21, 2024, 7:50:51 AMMay 21
to vim/vim, Subscribed

Hum... still does not pass some CI tests.

I am wondering if the following shall be changed somewhere as well...

--- a/src/testdir/test_termdebug.vim
+++ b/src/testdir/test_termdebug.vim


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122456657@github.com>

K.Takata

unread,
May 21, 2024, 8:14:58 AMMay 21
to vim/vim, Subscribed

Hmm, it passed in my repository...
https://github.com/k-takata/vim/actions/runs/9173423210
Commit: k-takata@f9523a2


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122499303@github.com>

K.Takata

unread,
May 21, 2024, 8:16:03 AMMay 21
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  " etc. in the current directory
+  let g:termdebug_config = {}
+  let g:termdebug_config['use_prompt'] = 1
+  let filename = 'gdb'
+  let replacement_filename = 'Termdebug-gdb-console'
+
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Throw away the file once the test has done.
+  Termdebug
+  sleep 2
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))}
⬇️ Suggested change
-  call WaitForAssert({-> assert_equal(1, winnr('$'))}
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2068468554@github.com>

ubaldot

unread,
May 21, 2024, 8:16:37 AMMay 21
to vim/vim, Subscribed

Hum... could you double check my changes to check if I did everything right?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122502512@github.com>

ubaldot

unread,
May 21, 2024, 8:20:23 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.

  • bf3e7b8 Update src/testdir/test_termdebug.vim


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18519013040@github.com>

ubaldot

unread,
May 21, 2024, 8:21:49 AMMay 21
to vim/vim, Subscribed

Usch! Hopefully one day someone will make a Vim/Vim9 language server to catch these typos :D


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2122511601@github.com>

Yegappan Lakshmanan

unread,
May 21, 2024, 9:46:26 AMMay 21
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/testdir/test_termdebug.vim:

> @@ -300,4 +300,41 @@ func Test_termdebug_mapping()
   %bw!
 endfunc
 
+func Test_termdebug_bufnames()
+  " Test if user has filename/folders named gdb, Termdebug-gdb-console,
+  " etc. in the current directory
+  let g:termdebug_config = {}
+  let g:termdebug_config['use_prompt'] = 1
+  let filename = 'gdb'
+  let replacement_filename = 'Termdebug-gdb-console'
+
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Throw away the file once the test has done.
+  Termdebug
+  sleep 2

Using hard-coded sleeps in tests will increase the time it takes to run the tests. Can you change these
to WaitForAssert() calls?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2068695711@github.com>

ubaldot

unread,
May 21, 2024, 9:55:54 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.

  • add255f Replaced hardcoded sleep with WaitForAssert()


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18520680090@github.com>

ubaldot

unread,
May 21, 2024, 9:57:47 AMMay 21
to vim/vim, Subscribed

@ubaldot commented on this pull request.


In src/testdir/test_termdebug.vim:

> @@ -300,4 +300,41 @@ func Test_termdebug_mapping()
   %bw!
 endfunc
 
+func Test_termdebug_bufnames()
+  " Test if user has filename/folders named gdb, Termdebug-gdb-console,
+  " etc. in the current directory
+  let g:termdebug_config = {}
+  let g:termdebug_config['use_prompt'] = 1
+  let filename = 'gdb'
+  let replacement_filename = 'Termdebug-gdb-console'
+
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Throw away the file once the test has done.
+  Termdebug
+  sleep 2

Ok, I replaced the sleep 2 with call WaitForAssert({-> assert_equal(3, winnr('$'))} , which, in my understanding, wait until the third window is available (in this case, given the termdebug setup, it means that termdebug is up and running).


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2068727311@github.com>

Yegappan Lakshmanan

unread,
May 21, 2024, 10:49:51 AMMay 21
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

Can you replace this hard-coded sleep with WaitForAssert()?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2068863446@github.com>

ubaldot

unread,
May 21, 2024, 11:46:45 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.

  • 5777753 Replaced the second sleep 2 statement and fixed typos


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18522579809@github.com>

ubaldot

unread,
May 21, 2024, 11:48:16 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18522603763@github.com>

ubaldot

unread,
May 21, 2024, 11:52:28 AMMay 21
to vim/vim, Push

@ubaldot pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/push/18522672600@github.com>

ubaldot

unread,
May 21, 2024, 11:57:03 AMMay 21
to vim/vim, Subscribed

@ubaldot commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

Done! Sorry for so many commits, it's my first time. I wish I could test the CI on my fork first... shall I cancel the PR if the CI still fails?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069035258@github.com>

Christian Brabandt

unread,
May 21, 2024, 12:18:03 PMMay 21
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

No worries. After all, that's what we have CI for ;) BTW: you can also run the tests locally: https://github.com/vim/vim/blob/master/src/testdir/README.txt

Just need to run make test_termdebug.res and then check the test.log and messages file.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069084202@github.com>

ubaldot

unread,
May 21, 2024, 12:24:13 PMMay 21
to vim/vim, Subscribed

@ubaldot commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

AWESOME! I am going to give it a shot straight away. :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069096005@github.com>

ubaldot

unread,
May 21, 2024, 12:41:29 PMMay 21
to vim/vim, Subscribed

@ubaldot commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

From the README

RUNNING THE TESTS:

To run a single test from the src directory:

    $ make test_<name>

The below commands should be run from the src/testdir directory.

To run a single test:

    $ make test_<name>.res

I am in ./vim/src/testdir but when I run make test_termdebug.res I get make: *** No rule to make target '../vim', needed by 'test_termdebug.res'. Stop. Perhaps there is some requirement that I am missing?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069130478@github.com>

Christian Brabandt

unread,
May 21, 2024, 12:44:00 PMMay 21
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

go up and directory and make vim first (cd .. && make)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069134949@github.com>

ubaldot

unread,
May 21, 2024, 12:58:59 PMMay 21
to vim/vim, Subscribed

@ubaldot commented on this pull request.


In src/testdir/test_termdebug.vim:

> +  call WaitForAssert({-> assert_equal(3, winnr('$'))}
+  " A file named filename already exists in the working directory,
+  " hence you must call the newly created buffer differently
+  call WaitForAssert({-> assert_false(bufexists(filename))})
+  call WaitForAssert({-> assert_true(bufexists(replacement_filename))})
+  quit!
+  call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+  " Check if error message is in :message
+  let g:termdebug_config['disasm_window'] = 1
+  let filename = 'Termdebug-asm-listing'
+  call writefile(['This', 'is', 'a', 'test'], filename, 'D')
+  " Check only the head of the error message
+  let error_message = "You have a file/folder named '" .. filename .. "'"
+  Termdebug
+  sleep 2

Thanks!
I built the vim executable. The test run but it seems that my tests are not run:

$ make test_termdebug.res
VIMRUNTIME=../../runtime  ../vim -f  -u unix.vim --gui-dialog-file guidialog -U NONE --noplugin --not-a-term -S runtest.vim test_termdebug.vim --cmd 'au SwapExists * let v:swapchoice = "e"' | LC_ALL=C LANG=C LANGUAGE=C awk '/Executing Test_/{match($0, "([0-9][0-9]:[0-9][0-9] *)?Executing Test_[^\\)]*\\)"); print substr($0, RSTART, RLENGTH) "\r"; fflush()}'
02:05 Executing Test_termdebug_basic()
02:09 Executing Test_termdebug_bufnames()
02:09 Executing Test_termdebug_mapping()
02:09 Executing Test_termdebug_tbreak() 

It is missing Test_termdebug_bufnames(). Shall I add it to some other file?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/review/2069163268@github.com>

Christian Brabandt

unread,
May 21, 2024, 5:34:34 PMMay 21
to vim/vim, Subscribed

thanks, looks good now.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/c2123478130@github.com>

Christian Brabandt

unread,
May 21, 2024, 5:35:10 PMMay 21
to vim/vim, Subscribed

Closed #14792 via 62ccaa6.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14792/issue_event/12885710131@github.com>

Reply all
Reply to author
Forward
0 new messages