Function: projectile-related-files-fn-test-with-suffix

projectile-related-files-fn-test-with-suffix is an autoloaded and byte-compiled function defined in projectile.el.

Signature

(projectile-related-files-fn-test-with-suffix EXTENSION TEST-SUFFIX)

Documentation

Generate a related-files-fn which relates tests and impl.

Use files with EXTENSION based on TEST-SUFFIX.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
;;;###autoload
(defun projectile-related-files-fn-test-with-suffix(extension test-suffix)
  "Generate a related-files-fn which relates tests and impl.
Use files with EXTENSION based on TEST-SUFFIX."
  (lambda (path)
    (when (equal (file-name-extension path) extension)
      (let* ((file-name (file-name-nondirectory path))
             (dot-ext (concat "." extension))
             (suffix-ext (concat test-suffix dot-ext))
             (find-impl? (string-suffix-p suffix-ext file-name))
             (file-name-to-find (if find-impl?
                                    (concat (substring file-name 0 (- (length suffix-ext)))
                                            dot-ext)
                                  (concat (substring file-name 0 (- (length dot-ext)))
                                          suffix-ext))))
        (list (if find-impl? :impl :test)
              (lambda (other-path)
                (and (string-suffix-p file-name-to-find other-path)
                     (equal (file-name-nondirectory other-path) file-name-to-find))))))))