git-subrepo icon indicating copy to clipboard operation
git-subrepo copied to clipboard

make test doesn't work when run without .git directory

Open perlpunk opened this issue 4 years ago • 5 comments

make test doesn't work when run from a directory without git, e.g. from a tarball. Is this necessary? It would be cool if we could run the tests when building the rpm (or deb) package.

Reproduce:

% mv .git .git.bak
% make test
prove test/                                                                        
test/branch-all.t ................ fatal: not in a git directory
test/branch-all.t ................ Dubious, test returned 128 (wstat 32768, 0x8000)
No subtests run                                                                    
test/branch-rev-list-one-path.t .. fatal: not in a git directory
test/branch-rev-list-one-path.t .. Dubious, test returned 128 (wstat 32768, 0x8000)
No subtests run                                                                    
...

perlpunk avatar Jun 03 '20 18:06 perlpunk

Sorry I didn't test earlier, but #488 apparently did not fix this. I'm still getting the same errors for 0.4.3

perlpunk avatar Nov 24 '20 12:11 perlpunk

@perlpunk's repo still causes failure:

% mv .git .git.bak
% make test

ingydotnet avatar Nov 24 '20 13:11 ingydotnet

This patch might do the trick:

diff --git a/test/setup b/test/setup
index fc19786..bfe7667 100644
--- a/test/setup
+++ b/test/setup
@@ -8,6 +8,10 @@ set -e
 # Set the GIT_SUBREPO_ROOT for testing.
 source "$PWD"/.rc
 
+if [[ ! -e $GIT_SUBREPO_ROOT/.git ]]; then
+  git clone --bare https://github.com/ingydotnet/git-subrepo.git "$GIT_SUBREPO_ROOT/.git"
+fi
+
 # Get the location of this script
 SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

ingydotnet avatar Nov 24 '20 13:11 ingydotnet

This won't work for our case. We would like to do testing in the openSUSE build, and in there we don't have network access.

perlpunk avatar Nov 24 '20 13:11 perlpunk

Makes sense

ingydotnet avatar Nov 24 '20 13:11 ingydotnet