Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions eldev-doctor.el
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,24 @@ Consider installing %s by running:
(eldev-message-enumerate nil not-installed) (if (cddr not-installed) "them" "it")))
'(result t)))))

(eldev-defdoctest eldev-doctest-tar-windows (_results)
:caption "Is the tar executable found compatible with Eldev on MS-Windows?"
:categories (eldev package tar)
(let ((tar-exe (eldev-tar-executable 'not-required)))
(if (not tar-exe)
'(result nil warnings "Cannot find a `tar` executable in the `PATH` env variable, `package` commands are likely to fail. Please install a tar program in `PATH`.")
(if (eq system-type 'windows-nt)
(let ((temp-file (make-temp-file "eldev-doctor-tar-win")))
(unwind-protect
;; in absence of any test files, try to tar the tar
;; executable itself.
(eldev-call-process tar-exe `("-cf" ,temp-file ,(expand-file-name (eldev-tar-executable)))
(when (/= exit-code 0)
`(result nil warnings ,(eldev-format-message "\
The tar executable found at `%s` is not compatible with Eldev, please use the one provided with MS-Windows (typically located at `c:\\Windows\\system32\\tar.exe`), by either rearranging the entries in the PATH environment variable to pick that up first, or by setting the `eldev-tar-executable' in `Eldev-local` to something like

(setf eldev-tar-executable \"C:/Windows/system32/tar.exe\")." tar-exe))))
(delete-file temp-file)))
'(result t)))))

(provide 'eldev-doctor)
14 changes: 14 additions & 0 deletions test/doctor.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,19 @@
(should-not (string-match-p "eldev-presence" stdout))
(should (= exit-code 0))))

(ert-deftest eldev-doctor-tar-win ()
(eldev--test-run "trivial-project" ("doctor" "tar-windows")
(should (= exit-code 0)))
(when (eq system-type 'windows-nt)
(let* ((file (make-temp-file "doctor-" nil ".bat"))
(eldev-tar-executable file))
(unwind-protect
;; use a mock .bat file that will fail when run
(with-temp-file file
(insert "@echo off\nexit 1"))
(eldev--test-run "trivial-project" ("--setup" `(setf eldev-tar-executable ,file) "doctor" "tar-windows")
(should (string-match-p "The tar executable" stdout))
(should (= exit-code 1)))
(delete-file file)))))

(provide 'test/doctor)