Function: projectile--test-at-point-file-name
projectile--test-at-point-file-name is an autoloaded and byte-compiled
function defined in projectile.el.
Signature
(projectile--test-at-point-file-name FILE DIR)
Documentation
Return FILE spelled relative to DIR for a test-at-point command.
Prefer the name as spelled. A file under a symlinked subdirectory of
the project resolves to somewhere outside it, so running it through
file-truename would produce a ../.. path for a file that is really
sitting right there.
The spelled name is the wrong one in the mirror-image case: the project
itself reached through a symlink that projectile-compilation-dir has
already resolved. Then the two spellings disagree about the root, the
relative name climbs out of the project, and the test runner is handed a
path it rejects - which is what every project under /tmp looks like on
macOS. Fall back to resolving both, and keep that only if it does stay
inside DIR.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260930.434/projectile.el
;;;###autoload
(defun projectile--test-at-point-file-name (file dir)
"Return FILE spelled relative to DIR for a test-at-point command.
Prefer the name as spelled. A file under a symlinked subdirectory of
the project resolves to somewhere outside it, so running it through
`file-truename' would produce a `../..' path for a file that is really
sitting right there.
The spelled name is the wrong one in the mirror-image case: the project
itself reached through a symlink that `projectile-compilation-dir' has
already resolved. Then the two spellings disagree about the root, the
relative name climbs out of the project, and the test runner is handed a
path it rejects - which is what every project under /tmp looks like on
macOS. Fall back to resolving both, and keep that only if it does stay
inside DIR."
(let ((spelled (file-relative-name file dir)))
(if (not (string-prefix-p ".." spelled))
spelled
(let ((resolved (file-relative-name (file-truename file)
(file-truename dir))))
(if (string-prefix-p ".." resolved) spelled resolved)))))