Git-secret: Fix tests when run from git hooks

Created on 30 Jan 2019  Â·  4Comments  Â·  Source: sobolevn/git-secret

CONTRIBUTING.md says to use make install-hooks to install pre- and post-commit hooks, but if you do that then the self-tests fail on commit:

````
% # make a meaningless, whitespace change to a file in src/commands/
% git commit -a
1..88
ok 1 run 'add' normally
ok 2 run 'add' for unignored file

...

ok 27 run 'hide' with '-P'
not ok 28 run 'hide' from inside subdirectory

(in test file /home/joshr/gitsrc/git-secret/tests/test_hide.bats, line 88)

`[ "$status" -eq 0 ]' failed

rm: cannot remove ‘space file’: No such file or directory

fatal: Not a git repository: '.git'

find: ‘/tmp/tmp.aBlVDAbUQF’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-rtkit-daemon.service-KNfvrc’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-colord.service-ivZa8u’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-fwupd.service-07aFP3’: Permission denied

find: ‘/tmp/tmp.UbZvBTtYAa’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-chronyd.service-G1ov1r’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-cups.service-kAx3OS’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-bolt.service-IZaN9N’: Permission denied

find: ‘/tmp/tmp.1L9d7x7l3I’: Permission denied

not ok 29 run 'hide' with missing file

(from function `set_state_secret_init' in file /home/joshr/gitsrc/git-secret/tests/_test_base.bash, line 202,

from function `setup' in test file /home/joshr/gitsrc/git-secret/tests/test_hide.bats, line 14)

`set_state_secret_init' failed

find: ‘/tmp/tmp.aBlVDAbUQF’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-rtkit-daemon.service-KNfvrc’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-colord.service-ivZa8u’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-fwupd.service-07aFP3’: Permission denied

find: ‘/tmp/tmp.UbZvBTtYAa’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-chronyd.service-G1ov1r’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-cups.service-kAx3OS’: Permission denied

find: ‘/tmp/systemd-private-8b7dddc415874f87ad46f53ff94b4d7f-bolt.service-IZaN9N’: Permission denied

find: ‘/tmp/tmp.1L9d7x7l3I’: Permission denied

ok 30 run 'hide' with multiple files

...
```

bug help wanted

All 4 comments

@sobolevn but.... why does running under a 'git commit' fail?

Is there a better fix for this that doesn't require disabling the test in that situation?

That's some deep git magic about its internal state: it is obviously different in normat mode and "commiting" state. I am not sure how different it is, however. And I was not able to find the correct solution back then.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rjcoelho picture rjcoelho  Â·  8Comments

doomsower picture doomsower  Â·  7Comments

tonyskapunk picture tonyskapunk  Â·  5Comments

eduncan911 picture eduncan911  Â·  8Comments

joshrabinowitz picture joshrabinowitz  Â·  3Comments