<feed xmlns='http://www.w3.org/2005/Atom'>
<title>dotemacs/tests/test-gptel-tools-list-directory-files.el, branch main</title>
<subtitle>My Emacs configuration
</subtitle>
<id>https://git.cjennings.net/dotemacs/atom?h=main</id>
<link rel='self' href='https://git.cjennings.net/dotemacs/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/'/>
<updated>2026-05-16T16:30:04+00:00</updated>
<entry>
<title>feat(gptel-tools): harden path validation with file-truename realpath</title>
<updated>2026-05-16T16:30:04+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-16T16:30:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/commit/?id=244d4c56768fcc60bd1b23fe45df7a57c7b293ec'/>
<id>urn:sha1:244d4c56768fcc60bd1b23fe45df7a57c7b293ec</id>
<content type='text'>
Resolves PATH through file-truename before applying home-directory and
read/write checks across the path-handling tools (git_status, git_log,
git_diff, move_to_trash, read_text_file, update_text_file,
write_text_file, list_directory_files, read_buffer, web_fetch).
Without the resolve step, a symlink under HOME pointing outside HOME
would pass the prefix check but the tool would act on the real target
-- a symlink-escape.

move_to_trash also tightens the trash-bin construction (treats empty
file extensions correctly) and switches the "critical directories"
list to truename-resolved canonical forms so a symlinked ~/.config
can't be trashed via an aliased path.

update_text_file fixes an off-by-one in the line-count derivation
when the source content is empty.

Each source change pairs with tests in tests/test-gptel-tools-*.el
and tests/test-update-text-file.el covering the realpath escape
paths, the empty-extension trash case, and the empty-content line-
count edge.  Combined coverage is now 100% across all ten gptel-tools
source files: 516 / 516 executable lines, 217 tests.
</content>
</entry>
<entry>
<title>test(gptel-tools): cover the helpers across the five remaining tools</title>
<updated>2026-05-16T06:39:57+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-16T06:39:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/commit/?id=73e63b6c6850f8e14d8374c7bf6b127971cfbb08'/>
<id>urn:sha1:73e63b6c6850f8e14d8374c7bf6b127971cfbb08</id>
<content type='text'>
The gptel-tools files had zero direct coverage outside of
`update_text_file`, which landed with its rewrite earlier this
session.  This commit adds 52 tests across the five other tools.

For three of the tools the helpers were already top-level defuns
(`read_text_file`, `list_directory_files`, `move_to_trash`).  The
other two had their main bodies inlined into the `gptel-make-tool`
lambda -- I extracted them so the work is testable without mocking
gptel itself:

  read_buffer.el     -&gt; `cj/read-buffer--get-content`
  write_text_file.el -&gt; `cj/write-text-file--run` plus
                        `--validate-path`, `--backup-name`,
                        `--ensure-parent`

Test files, by tool:

- read_buffer.el          (5 tests):  normal, empty, buffer-object,
  text-property-stripping, missing buffer.
- write_text_file.el     (10 tests):  validate-path, backup-name
  shape, ensure-parent (creates missing / rejects unwritable), run
  with normal / overwrite / existing-no-overwrite / empty content /
  outside-home.
- read_text_file.el      (12 tests):  validate-file-path (normal +
  three error shapes), metadata plist shape, size limits (no-op /
  hard cap / warning bypass with no-confirm), binary detection
  (text vs null-byte), special-type EPUB and generic-binary paths.
- list_directory_files.el (15 tests):  mode-to-permissions (file /
  dir / executable), get-file-info (file / directory), extension
  filter (keep / drop / always-dir / nil-extension), format-file-
  entry, list-directory flat / recursive / error, format-output
  with and without files.
- move_to_trash.el       (10 tests):  unique-name (no conflict /
  conflict with timestamp / no-extension), validate-path (HOME / /tmp
  / outside / critical-dir / missing), perform on file and
  directory.

Each test file uses the same load-path / gptel-stub idiom
(`eval-and-compile` block, gptel stub when the real package isn't
available) so the byte-compile hook is happy.
</content>
</entry>
</feed>
