filter-repo: add some basic tests, with git-style test-lib.sh

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2018-11-05 06:30:50 -08:00
parent 4f149daacc
commit 17a2f7102d
7 changed files with 3008 additions and 0 deletions

37
t/t9390-filter-repo.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
test_description='Basic filter-repo tests'
. ./test-lib.sh
export PATH=$(dirname $TEST_DIRECTORY):$PATH # Put git-filter-repo in PATH
DATA="$TEST_DIRECTORY/t9390"
filter_testcase() {
INPUT=$1
OUTPUT=$2
shift 2
REST=("$@")
NAME="check: $INPUT -> $OUTPUT using '${REST[@]}'"
test_expect_success "$NAME" '
# Clean up from previous run
git pack-refs --all &&
rm .git/packed-refs &&
# Run the example
cat $DATA/$INPUT | git filter-repo --stdin --quiet --force ${REST[@]} &&
# Compare the resulting repo to expected value
git fast-export --use-done-feature --all >compare &&
test_cmp $DATA/$OUTPUT compare
'
}
filter_testcase basic basic-filename --path filename
filter_testcase basic basic-twenty --path twenty
filter_testcase basic basic-ten --path ten
test_done

95
t/t9390/basic Normal file
View File

@ -0,0 +1,95 @@
feature done
# Simple repo with three files, a merge where each side touches exactly one
# file, and a commit at the end touching all three. Note that the original-oid
# directives are very fake, but make it easy to recognize what original shas
# are.
blob
mark :1
original-oid 0000000000000000000000000000000000000001
data 8
initial
blob
mark :2
original-oid 0000000000000000000000000000000000000002
data 8
ten-mod
blob
mark :3
original-oid 0000000000000000000000000000000000000003
data 11
twenty-mod
blob
mark :4
original-oid 0000000000000000000000000000000000000004
data 6
final
reset refs/heads/master
commit refs/heads/master
mark :5
original-oid 0000000000000000000000000000000000000009
author Little O. Me <me@little.net> 1535228562 -0700
committer Little O. Me <me@little.net> 1535228562 -0700
data 8
Initial
M 100644 :1 filename
M 100644 :1 ten
M 100644 :1 twenty
commit refs/heads/B
mark :6
original-oid 000000000000000000000000000000000000000B
author Little 'ol Me <me@laptop.(none)> 1535229544 -0700
committer Little 'ol Me <me@laptop.(none)> 1535229544 -0700
data 11
add twenty
from :5
M 100644 :3 twenty
commit refs/heads/A
mark :7
original-oid 000000000000000000000000000000000000000A
author Little O. Me <me@machine52.little.net> 1535229523 -0700
committer Little O. Me <me@machine52.little.net> 1535229523 -0700
data 8
add ten
from :5
M 100644 :2 ten
commit refs/heads/master
mark :8
original-oid 000000000000000000000000000000000000000C
author Lit.e Me <me@fire.com> 1535229559 -0700
committer Lit.e Me <me@fire.com> 1535229580 -0700
data 24
Merge branch 'A' into B
from :6
merge :7
M 100644 :2 ten
commit refs/heads/master
mark :9
original-oid 000000000000000000000000000000000000000D
author Little Me <me@bigcompany.com> 1535229601 -0700
committer Little Me <me@bigcompany.com> 1535229601 -0700
data 9
whatever
from :8
M 100644 :4 filename
M 100644 :4 ten
M 100644 :4 twenty
tag v1.0
from :9
original-oid 000000000000000000000000000000000000000E
tagger Little John <second@merry.men> 1535229618 -0700
data 5
v1.0
reset refs/heads/master
from :9
done

39
t/t9390/basic-filename Normal file
View File

@ -0,0 +1,39 @@
feature done
blob
mark :1
data 8
initial
reset refs/heads/A
commit refs/heads/A
mark :2
author Little O. Me <me@little.net> 1535228562 -0700
committer Little O. Me <me@little.net> 1535228562 -0700
data 8
Initial
M 100644 :1 filename
blob
mark :3
data 6
final
commit refs/heads/master
mark :4
author Little Me <me@bigcompany.com> 1535229601 -0700
committer Little Me <me@bigcompany.com> 1535229601 -0700
data 9
whatever
from :2
M 100644 :3 filename
reset refs/heads/B
from :2
tag v1.0
from :4
tagger Little John <second@merry.men> 1535229618 -0700
data 5
v1.0
done

50
t/t9390/basic-ten Normal file
View File

@ -0,0 +1,50 @@
feature done
blob
mark :1
data 8
initial
reset refs/heads/B
commit refs/heads/B
mark :2
author Little O. Me <me@little.net> 1535228562 -0700
committer Little O. Me <me@little.net> 1535228562 -0700
data 8
Initial
M 100644 :1 ten
blob
mark :3
data 8
ten-mod
commit refs/heads/A
mark :4
author Little O. Me <me@machine52.little.net> 1535229523 -0700
committer Little O. Me <me@machine52.little.net> 1535229523 -0700
data 8
add ten
from :2
M 100644 :3 ten
blob
mark :5
data 6
final
commit refs/heads/master
mark :6
author Little Me <me@bigcompany.com> 1535229601 -0700
committer Little Me <me@bigcompany.com> 1535229601 -0700
data 9
whatever
from :4
M 100644 :5 ten
tag v1.0
from :6
tagger Little John <second@merry.men> 1535229618 -0700
data 5
v1.0
done

50
t/t9390/basic-twenty Normal file
View File

@ -0,0 +1,50 @@
feature done
blob
mark :1
data 8
initial
reset refs/heads/A
commit refs/heads/A
mark :2
author Little O. Me <me@little.net> 1535228562 -0700
committer Little O. Me <me@little.net> 1535228562 -0700
data 8
Initial
M 100644 :1 twenty
blob
mark :3
data 11
twenty-mod
commit refs/heads/B
mark :4
author Little 'ol Me <me@laptop.(none)> 1535229544 -0700
committer Little 'ol Me <me@laptop.(none)> 1535229544 -0700
data 11
add twenty
from :2
M 100644 :3 twenty
blob
mark :5
data 6
final
commit refs/heads/master
mark :6
author Little Me <me@bigcompany.com> 1535229601 -0700
committer Little Me <me@bigcompany.com> 1535229601 -0700
data 9
whatever
from :4
M 100644 :5 twenty
tag v1.0
from :6
tagger Little John <second@merry.men> 1535229618 -0700
data 5
v1.0
done

1311
t/test-lib-functions.sh Normal file

File diff suppressed because it is too large Load Diff

1426
t/test-lib.sh Normal file

File diff suppressed because it is too large Load Diff