emacsorphanage/git-gutter

selftests: please check for .git and 'git init' if it isn't found

sten0 opened this issue · 3 comments

sten0 commented

Hello, and thank you for maintaining emacs-git-gutter!

While working on preliminary packaging for Debian, I noticed that three self-tests fail:

Running 18 tests (2019-02-03 07:48:02+0000)
   passed   1/18  git-gutter
   passed   2/18  git-gutter-bzr-diff-arguments
   passed   3/18  git-gutter-git-diff-arguments
   passed   4/18  git-gutter-hg-diff-arguments
   passed   5/18  git-gutter-mode-failed
Test git-gutter-mode-success backtrace:
  signal(ert-test-failed (((should git-gutter-mode) :form git-gutter-m
  ert-fail(((should git-gutter-mode) :form git-gutter-mode :value nil)
  (if (unwind-protect (setq value-65 git-gutter-mode) (setq form-descr
  (let (form-description-66) (if (unwind-protect (setq value-65 git-gu
  (let ((value-65 (gensym "ert-form-evaluation-aborted-"))) (let (form
  (save-current-buffer (set-buffer (find-file-noselect "test-git-gutte
  (lambda nil (save-current-buffer (set-buffer (find-file-noselect "te
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name git-gutter-mode-success :documentatio
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test 
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  eval((ert-run-tests-batch-and-exit))
  command-line-1(("-l" "package" "--eval" "(add-to-list 'package-direc
  command-line()
  normal-top-level()
Test git-gutter-mode-success condition:
    (ert-test-failed
     ((should git-gutter-mode)
      :form git-gutter-mode :value nil))
   FAILED   6/18  git-gutter-mode-success
   passed   7/18  git-gutter-read-header
   passed   8/18  git-gutter-show-backends
   passed   9/18  git-gutter:changes-to-number
   passed  10/18  git-gutter:collect-deleted-line
   passed  11/18  git-gutter:diff-content
Test git-gutter:in-git-repository-p backtrace:
  signal(ert-test-failed (((should (git-gutter:in-git-repository-p)) :
  ert-fail(((should (git-gutter:in-git-repository-p)) :form (git-gutte
  (if (unwind-protect (setq value-32 (apply fn-30 args-31)) (setq form
  (let (form-description-34) (if (unwind-protect (setq value-32 (apply
  (let ((value-32 'ert-form-evaluation-aborted-33)) (let (form-descrip
  (let* ((fn-30 (function git-gutter:in-git-repository-p)) (args-31 (c
  (let ((default-directory (file-name-directory (locate-library "git-g
  (lambda nil (if (file-directory-p ".git") (progn (let ((buf (find-fi
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name git-gutter:in-git-repository-p :docum
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test 
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  eval((ert-run-tests-batch-and-exit))
  command-line-1(("-l" "package" "--eval" "(add-to-list 'package-direc
  command-line()
  normal-top-level()
Test git-gutter:in-git-repository-p condition:
    (ert-test-failed
     ((should
       (git-gutter:in-git-repository-p))
      :form
      (git-gutter:in-git-repository-p)
      :value nil))
   FAILED  12/18  git-gutter:in-git-repository-p
   passed  13/18  git-gutter:insert-deleted-lines
   passed  14/18  git-gutter:propertized-sign
   passed  15/18  git-gutter:set-window-margin
   passed  16/18  git-gutter:sign-width
   passed  17/18  global-git-gutter-mode-failed
Test global-git-gutter-mode-success backtrace:
  signal(ert-test-failed (((should git-gutter-mode) :form git-gutter-m
  ert-fail(((should git-gutter-mode) :form git-gutter-mode :value nil)
  (if (unwind-protect (setq value-75 git-gutter-mode) (setq form-descr
  (let (form-description-76) (if (unwind-protect (setq value-75 git-gu
  (let ((value-75 (gensym "ert-form-evaluation-aborted-"))) (let (form
  (save-current-buffer (set-buffer (find-file-noselect "test-git-gutte
  (lambda nil (save-current-buffer (set-buffer (find-file-noselect "te
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name global-git-gutter-mode-success :docum
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test 
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  eval((ert-run-tests-batch-and-exit))
  command-line-1(("-l" "package" "--eval" "(add-to-list 'package-direc
  command-line()
  normal-top-level()
Test global-git-gutter-mode-success condition:
    (ert-test-failed
     ((should git-gutter-mode)
      :form git-gutter-mode :value nil))
   FAILED  18/18  global-git-gutter-mode-success

Ran 18 tests, 15 results as expected, 3 unexpected (2019-02-03 07:48:02+0000)

3 unexpected results:
   FAILED  git-gutter-mode-success
   FAILED  git-gutter:in-git-repository-p
   FAILED  global-git-gutter-mode-success

Entering a debugging shell (SH, not Lisp), I was able to make two of these succeed with the following commands from inside the unpacked git-gutter source package (similar to what you get if you unpack the MELPA tarball):

git config user.email "foo@bar.com"
git config user.name "Foo Bar"
git init
git add * -am "Initial commit"
emacs -Q -batch -l git-gutter.el -l test/test-git-gutter.el -f ert-run-tests-batch-and-exit

but unfortunately in-git-repository-p still fails.

It would be really nice if these self tests would set up a git repository if one isn't detected! :-)

Huh, interesting. Thanks for the report. We've just transferred this project from it's previous maintainer to the "emacsorphanage" project. I'll tag this as "maintenance" and continue sifting through the backlog.

You should set load path option by -L .

Resolved. Added a test fixture that creates a temporary directory, initializes a git repo using vc-create-repo, and then runs the necessary test cases within.