<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rneovim.git/test/functional/api/proc_spec.lua, branch userreg</title>
<subtitle>Neovim fork with Rahm's personal hacks.</subtitle>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/'/>
<entry>
<title>refactor(api): consistent VALIDATE messages #22262</title>
<updated>2023-02-14T19:19:28+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2023-02-14T19:19:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=556f8646c01d1751cf39fe4df9c622899dceab9d'/>
<id>556f8646c01d1751cf39fe4df9c622899dceab9d</id>
<content type='text'>
Problem:
Validation messages are not consistently formatted.
- Parameter names sometimes are NOT quoted.
- Descriptive names (non-parameters) sometimes ARE quoted.

Solution:
Always quote the `name` value passed to a VALIDATE macro _unless_ the
value has whitespace.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
Validation messages are not consistently formatted.
- Parameter names sometimes are NOT quoted.
- Descriptive names (non-parameters) sometimes ARE quoted.

Solution:
Always quote the `name` value passed to a VALIDATE macro _unless_ the
value has whitespace.</pre>
</div>
</content>
</entry>
<entry>
<title>refactor(api): VALIDATE macros #22256</title>
<updated>2023-02-14T13:07:38+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2023-02-14T13:07:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=ff3d04b75b4a9314815c37d53ebc4d035a043335'/>
<id>ff3d04b75b4a9314815c37d53ebc4d035a043335</id>
<content type='text'>
- VALIDATE() takes a format string
- deduplicate check_string_array
- VALIDATE_RANGE
- validate UI args</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- VALIDATE() takes a format string
- deduplicate check_string_array
- VALIDATE_RANGE
- validate UI args</pre>
</div>
</content>
</entry>
<entry>
<title>docs: fix typos (#21196)</title>
<updated>2022-11-29T01:45:48+00:00</updated>
<author>
<name>dundargoc</name>
<email>33953936+dundargoc@users.noreply.github.com</email>
</author>
<published>2022-11-29T01:45:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=615f124003376c007442319b31a172360796974c'/>
<id>615f124003376c007442319b31a172360796974c</id>
<content type='text'>
Co-authored-by: zeertzjq &lt;zeertzjq@outlook.com&gt;
Co-authored-by: Raphael &lt;glephunter@gmail.com&gt;
Co-authored-by: Gregory Anders &lt;greg@gpanders.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: zeertzjq &lt;zeertzjq@outlook.com&gt;
Co-authored-by: Raphael &lt;glephunter@gmail.com&gt;
Co-authored-by: Gregory Anders &lt;greg@gpanders.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>test: simplify platform detection (#21020)</title>
<updated>2022-11-22T00:13:30+00:00</updated>
<author>
<name>dundargoc</name>
<email>33953936+dundargoc@users.noreply.github.com</email>
</author>
<published>2022-11-22T00:13:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=5eb5f4948826e9d47685ea9e257409cc3e693614'/>
<id>5eb5f4948826e9d47685ea9e257409cc3e693614</id>
<content type='text'>
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.</pre>
</div>
</content>
</entry>
<entry>
<title>test: correct order of arguments to eq() and neq()</title>
<updated>2022-04-26T03:38:58+00:00</updated>
<author>
<name>zeertzjq</name>
<email>zeertzjq@outlook.com</email>
</author>
<published>2022-04-26T03:35:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=519e4c44720be9b0c8584cb53a902bc1e5bfe3a3'/>
<id>519e4c44720be9b0c8584cb53a902bc1e5bfe3a3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>doc + extmarks tweaks #11421</title>
<updated>2019-11-25T09:08:02+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2019-11-25T09:08:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=fd5710ae9a3bcbc0f9cbb71de9e39253350ff09c'/>
<id>fd5710ae9a3bcbc0f9cbb71de9e39253350ff09c</id>
<content type='text'>
- nvim_buf_get_extmarks: rename "amount" =&gt; "limit"
- rename `set_extmark_index_from_obj`</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- nvim_buf_get_extmarks: rename "amount" =&gt; "limit"
- rename `set_extmark_index_from_obj`</pre>
</div>
</content>
</entry>
<entry>
<title>tests: support msg with global_helpers.ok (#10820)</title>
<updated>2019-08-21T00:32:20+00:00</updated>
<author>
<name>Daniel Hahler</name>
<email>git@thequod.de</email>
</author>
<published>2019-08-21T00:32:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=47e27a4f5b2b2ae20e20a51a6cf0f76078c28698'/>
<id>47e27a4f5b2b2ae20e20a51a6cf0f76078c28698</id>
<content type='text'>
Ref: https://github.com/neovim/neovim/pull/10768#discussion_r315904175

Co-Authored-By: Justin M. Keyes &lt;justinkz@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ref: https://github.com/neovim/neovim/pull/10768#discussion_r315904175

Co-Authored-By: Justin M. Keyes &lt;justinkz@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: fix "api nvim_get_proc_children returns child process ids" (#10296)</title>
<updated>2019-06-22T13:29:39+00:00</updated>
<author>
<name>Daniel Hahler</name>
<email>git@thequod.de</email>
</author>
<published>2019-06-22T13:29:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=bc10a15ea7a5e9108a0d60a2092b099b9a6a4805'/>
<id>bc10a15ea7a5e9108a0d60a2092b099b9a6a4805</id>
<content type='text'>
There might be an existing job already - maybe due to some other test,
but in this case there was only one failure in the test run.

```
[----------] Running tests from C:/projects/neovim/test/functional\api\proc_spec.lua
  [ RUN      ] api nvim_get_proc_children returns child process ids: ERR
  test\functional\helpers.lua:392:
  retry() attempts: 450
  C:/projects/neovim/test/functional\api\proc_spec.lua:22: Expected objects to be the same.
  Passed in:
  (number) 2
  Expected:
  (number) 1

  stack traceback:
  	test\functional\helpers.lua:392: in function 'retry'
  	C:/projects/neovim/test/functional\api\proc_spec.lua:21: in function &lt;C:/projects/neovim/test/functional\api\proc_spec.lua:17&gt;
```

https://ci.appveyor.com/project/neovim/neovim/builds/25461215/job/8ns204v6091iy9rs?fullLog=true#L2672</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There might be an existing job already - maybe due to some other test,
but in this case there was only one failure in the test run.

```
[----------] Running tests from C:/projects/neovim/test/functional\api\proc_spec.lua
  [ RUN      ] api nvim_get_proc_children returns child process ids: ERR
  test\functional\helpers.lua:392:
  retry() attempts: 450
  C:/projects/neovim/test/functional\api\proc_spec.lua:22: Expected objects to be the same.
  Passed in:
  (number) 2
  Expected:
  (number) 1

  stack traceback:
  	test\functional\helpers.lua:392: in function 'retry'
  	C:/projects/neovim/test/functional\api\proc_spec.lua:21: in function &lt;C:/projects/neovim/test/functional\api\proc_spec.lua:17&gt;
```

https://ci.appveyor.com/project/neovim/neovim/builds/25461215/job/8ns204v6091iy9rs?fullLog=true#L2672</pre>
</div>
</content>
</entry>
<entry>
<title>API: nvim_get_proc()</title>
<updated>2018-03-17T23:11:45+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2018-03-16T04:13:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=a034d4b69d6032b3431c10b8a11c998551700fc2'/>
<id>a034d4b69d6032b3431c10b8a11c998551700fc2</id>
<content type='text'>
TODO: "exepath" field (win32: QueryFullProcessImageName())

On unix-likes `ps` is used because the platform-specific APIs are
a nightmare.  For reference, below is a (incomplete) attempt:

diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c
index 09769925aca5..99afbbf290c1 100644
--- a/src/nvim/os/process.c
+++ b/src/nvim/os/process.c
@@ -208,3 +210,60 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
   return 0;
 }

+/// Gets various properties of the process identified by `pid`.
+///
+/// @param pid Process to inspect.
+/// @return Map of process properties, empty on error.
+Dictionary os_proc_info(int pid)
+{
+  Dictionary pinfo = ARRAY_DICT_INIT;
+#ifdef WIN32
+
+#elif defined(__APPLE__)
+  char buf[PROC_PIDPATHINFO_MAXSIZE];
+  if (proc_pidpath(pid, buf, sizeof(buf))) {
+    name = getName(buf);
+    PUT(pinfo, "exepath", STRING_OBJ(cstr_to_string(buf)));
+    return name;
+  } else {
+    ILOG("proc_pidpath() failed for pid: %d", pid);
+  }
+#elif defined(BSD)
+# if defined(__FreeBSD__)
+#  define KP_COMM(o) o.ki_comm
+# else
+#  define KP_COMM(o) o.p_comm
+# endif
+  struct kinfo_proc *proc = kinfo_getproc(pid);
+  if (proc) {
+    PUT(pinfo, "name", cstr_to_string(KP_COMM(proc)));
+    xfree(proc);
+  } else {
+    ILOG("kinfo_getproc() failed for pid: %d", pid);
+  }
+
+#elif defined(__linux__)
+  char fname[256] = { 0 };
+  char buf[MAXPATHL];
+  snprintf(fname, sizeof(fname), "/proc/%d/comm", pid);
+  FILE *fp = fopen(fname, "r");
+  // FileDescriptor *f = file_open_new(&amp;error, fname, kFileReadOnly, 0);
+  // ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf,
+  //                     const size_t size)
+  if (fp == NULL) {
+    ILOG("fopen() of /proc/%d/comm failed", pid);
+  } else {
+    size_t n = fread(buf, sizeof(char), sizeof(buf) - 1, fp);
+    if (n == 0) {
+      WLOG("fread() of /proc/%d/comm failed", pid);
+    } else {
+      size_t end = MIN(sizeof(buf) - 1, n);
+      end = (end &gt; 0 &amp;&amp; buf[end - 1] == '\n') ? end - 1 : end;
+      buf[end] = '\0';
+      PUT(pinfo, "name", STRING_OBJ(cstr_to_string(buf)));
+    }
+  }
+  fclose(fp);
+#endif
+  return pinfo;
+}
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
TODO: "exepath" field (win32: QueryFullProcessImageName())

On unix-likes `ps` is used because the platform-specific APIs are
a nightmare.  For reference, below is a (incomplete) attempt:

diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c
index 09769925aca5..99afbbf290c1 100644
--- a/src/nvim/os/process.c
+++ b/src/nvim/os/process.c
@@ -208,3 +210,60 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
   return 0;
 }

+/// Gets various properties of the process identified by `pid`.
+///
+/// @param pid Process to inspect.
+/// @return Map of process properties, empty on error.
+Dictionary os_proc_info(int pid)
+{
+  Dictionary pinfo = ARRAY_DICT_INIT;
+#ifdef WIN32
+
+#elif defined(__APPLE__)
+  char buf[PROC_PIDPATHINFO_MAXSIZE];
+  if (proc_pidpath(pid, buf, sizeof(buf))) {
+    name = getName(buf);
+    PUT(pinfo, "exepath", STRING_OBJ(cstr_to_string(buf)));
+    return name;
+  } else {
+    ILOG("proc_pidpath() failed for pid: %d", pid);
+  }
+#elif defined(BSD)
+# if defined(__FreeBSD__)
+#  define KP_COMM(o) o.ki_comm
+# else
+#  define KP_COMM(o) o.p_comm
+# endif
+  struct kinfo_proc *proc = kinfo_getproc(pid);
+  if (proc) {
+    PUT(pinfo, "name", cstr_to_string(KP_COMM(proc)));
+    xfree(proc);
+  } else {
+    ILOG("kinfo_getproc() failed for pid: %d", pid);
+  }
+
+#elif defined(__linux__)
+  char fname[256] = { 0 };
+  char buf[MAXPATHL];
+  snprintf(fname, sizeof(fname), "/proc/%d/comm", pid);
+  FILE *fp = fopen(fname, "r");
+  // FileDescriptor *f = file_open_new(&amp;error, fname, kFileReadOnly, 0);
+  // ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf,
+  //                     const size_t size)
+  if (fp == NULL) {
+    ILOG("fopen() of /proc/%d/comm failed", pid);
+  } else {
+    size_t n = fread(buf, sizeof(char), sizeof(buf) - 1, fp);
+    if (n == 0) {
+      WLOG("fread() of /proc/%d/comm failed", pid);
+    } else {
+      size_t end = MIN(sizeof(buf) - 1, n);
+      end = (end &gt; 0 &amp;&amp; buf[end - 1] == '\n') ? end - 1 : end;
+      buf[end] = '\0';
+      PUT(pinfo, "name", STRING_OBJ(cstr_to_string(buf)));
+    }
+  }
+  fclose(fp);
+#endif
+  return pinfo;
+}
</pre>
</div>
</content>
</entry>
<entry>
<title>API: nvim_get_proc_children()</title>
<updated>2018-03-16T09:55:12+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2018-03-11T20:47:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=dbad797edd4636f830abd7ade1138a1a27ac30d2'/>
<id>dbad797edd4636f830abd7ade1138a1a27ac30d2</id>
<content type='text'>
ref https://github.com/libuv/libuv/pull/836
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ref https://github.com/libuv/libuv/pull/836
</pre>
</div>
</content>
</entry>
</feed>
