-
Notifications
You must be signed in to change notification settings - Fork 7
/
testlib.sh
48 lines (42 loc) · 1.15 KB
/
testlib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
# GitBSLR is available under the same license as Git itself.
#This script contains various helper functions needed by all of GitBSLR's tests.
#dash doesn't support pipefail
set -eu
make
rm -rf test/
[ -e test/ ] && exit 1
mkdir test/
echo "Signature: 8a477f597d28d172789f06886806bc55" > test/CACHEDIR.TAG
GIT=/usr/bin/git
git()
{
>&2 echo git "$@"
$GIT "$@"
}
GITBSLR=$(pwd)/gitbslr.so
gitbslr()
{
>&2 echo gitbslr "$@"
LD_PRELOAD=$GITBSLR $GIT "$@"
}
export GITBSLR_DEBUG=1
ln_sr()
{
#Perl is no beauty, but anything else I could find requires bash, or other programs not guaranteed to exist
ln -sr $1 $2 || perl -e'use File::Spec; use File::Basename;
symlink File::Spec->abs2rel($ARGV[0], dirname($ARGV[1])), $ARGV[1] or
die qq{cannot create symlink: $!$/}' $1 $2
}
tree()
{
find $1 -printf '%P -> %l\n' | grep -v .git | LC_ALL=C sort ||
perl -e '
chdir $ARGV[0];
use File::Find qw(finddepth);
finddepth(sub {
print $File::Find::name, " -> ", (readlink $_ or ""), "\n";
}, ".");
' $1 | grep -v .git | LC_ALL=C sort
}