Skip to content

Commit e7a7b36

Browse files
author
alexandresalome
committed
script to test against different git version (fixes #22)
1 parent ab8fc27 commit e7a7b36

File tree

3 files changed

+97
-3
lines changed

3 files changed

+97
-3
lines changed

doc/development.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ is located in https://github.com/gitonomy/website/blob/master/bin/conf.py
1111

1212
You will need to fetch vendor modules for PHP blocks especially. If you really
1313
want to generate it, install the website project locally and hack into it.
14+
15+
Test against different git versions
16+
:::::::::::::::::::::::::::::::::::
17+
18+
A script ``test-git-version.sh`` is available in repository to test gitlib against
19+
many git versions.
20+
21+
This script is not usable on Travis-CI, they would hate me for this. It creates
22+
a local cache to avoid fetching from Github and compiling if already compiled.
23+
24+
Use it at your own risk, it's still under experiment.

test-git-versions.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
set -e
3+
4+
URL="[email protected]:git/git.git"
5+
VERSIONS="v1.6.3 v1.6.6 v1.7.1 v1.7.5 v1.7.9 v1.8.1"
6+
DIRNAME="git-builds"
7+
8+
if [ ! -d "$DIRNAME" ]; then
9+
mkdir - "$DIRNAME"
10+
fi
11+
12+
cd "$DIRNAME"
13+
14+
# remote repository
15+
if [ -d cache ]; then
16+
echo "- update from github..."
17+
cd cache
18+
git fetch -q
19+
cd ..
20+
else
21+
echo "- clone from github..."
22+
git clone "$URL" cache -q
23+
fi
24+
25+
# build
26+
for VERSION in $VERSIONS; do
27+
28+
echo "- build $VERSION"
29+
LOGFILE="build.$VERSION.log"
30+
LOCKFILE="build.$VERSION.lock"
31+
32+
if [ -f "$LOCKFILE" ]; then
33+
echo " - lock present, destroy build..."
34+
rm -rf "$VERSION" "build.$VERSION.log"
35+
fi
36+
37+
if [ -d "$VERSION" ]; then
38+
echo " - already built, skipping..."
39+
continue
40+
fi
41+
42+
touch "$LOCKFILE"
43+
44+
echo " - log: $LOGFILE"
45+
touch "$LOGFILE"
46+
mkdir "$VERSION"
47+
echo " - clone repository"
48+
git clone -s cache "$VERSION/source" -q
49+
echo " - checkout version"
50+
cd "$VERSION/source"
51+
git checkout "$VERSION" -q
52+
53+
mkdir ../build
54+
PREFIX="`readlink -f ../build`"
55+
56+
echo " - build..."
57+
autoconf >> "../../$LOGFILE" 2>&1
58+
./configure --prefix="$PREFIX" >> "../../$LOGFILE" 2>&1
59+
make all >> "../../$LOGFILE" 2>&1
60+
make install >> "../../$LOGFILE" 2>&1
61+
echo " - build ok"
62+
cd ../..
63+
rm "$LOCKFILE"
64+
done
65+
cd ..
66+
67+
# test
68+
echo ""
69+
for VERSION in $VERSIONS; do
70+
echo "- test $VERSION"
71+
GIT_COMMAND="`readlink -f $DIRNAME/$VERSION/build/bin/git`"
72+
echo " - command: $GIT_COMMAND"
73+
GIT_COMMAND="$GIT_COMMAND" phpunit || true
74+
done

tests/Gitonomy/Git/Tests/AbstractTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase
3939
public static function createEmptyRepository($bare = true)
4040
{
4141
$dir = self::createTempDir();
42-
$repository = Admin::init($dir, $bare);
42+
$repository = Admin::init($dir, $bare, self::getOptions());
4343
self::registerDeletion($repository);
4444

4545
return $repository;
@@ -64,10 +64,10 @@ public static function provideFoobar()
6464
public static function createFoobarRepository($bare = true)
6565
{
6666
if (null === self::$localRepository) {
67-
self::$localRepository = Admin::cloneTo(self::createTempDir(), self::REPOSITORY_URL);
67+
self::$localRepository = Admin::cloneTo(self::createTempDir(), self::REPOSITORY_URL, self::getOptions());
6868
}
6969

70-
$repository = self::$localRepository->cloneTo(self::createTempDir(), $bare);
70+
$repository = self::$localRepository->cloneTo(self::createTempDir(), $bare, self::getOptions());
7171
self::registerDeletion($repository);
7272

7373
return $repository;
@@ -118,4 +118,13 @@ public static function deleteDir($dir)
118118

119119
rmdir($dir);
120120
}
121+
122+
private static function getOptions()
123+
{
124+
$command = isset($_SERVER['GIT_COMMAND']) ? $_SERVER['GIT_COMMAND'] : 'git';
125+
126+
return array(
127+
'command' => $command
128+
);
129+
}
121130
}

0 commit comments

Comments
 (0)