Improve Git test coverage

- Two different repositories being queried at once
- The same one being queried twice, at different depths
- Tests for --tree and --recurse that should break in the future when that’s implemented
- Also just more tests in general
This commit is contained in:
Benjamin Sago 2017-08-28 15:10:29 +01:00
parent be70fbdf98
commit 55aaecb74d
19 changed files with 179 additions and 9 deletions

35
Vagrantfile vendored
View File

@ -480,10 +480,7 @@ Vagrant.configure(2) do |config|
touch $dir/that-file
done
touch -t #{some_date} "#{test_dir}/attributes" # there's probably
touch -t #{some_date} "#{test_dir}/attributes"/* # a better
touch -t #{some_date} "#{test_dir}/attributes"/*/* # way to
touch -t #{some_date} "#{test_dir}/attributes"/*/*/* # do this
find "#{test_dir}/attributes" -exec touch {} -t #{some_date} \\;
# I want to use the following to test,
# but it only works on macos:
@ -519,12 +516,38 @@ Vagrant.configure(2) do |config|
echo "more modifications!" | tee edits/unstaged edits/both additions/edited
touch additions/unstaged
touch -t #{some_date} "#{test_dir}/git/"*/*
find "#{test_dir}/git" -exec touch {} -t #{some_date} \\;
sudo chown #{user}:#{user} -R "#{test_dir}/git"
EOF
# A second Git repository
# for testing two at once
config.vm.provision :shell, privileged: false, inline: <<-EOF
set -xe
mkdir -p "#{test_dir}/git2/deeply/nested/directory"
cd "#{test_dir}/git2"
git init
touch "deeply/nested/directory/upd8d"
git add "deeply/nested/directory/upd8d"
git commit -m "Automated test commit"
echo "Now with contents" > "deeply/nested/directory/upd8d"
touch "deeply/nested/directory/l8st"
echo -e "target\n*.mp3" > ".gitignore"
mkdir "ignoreds"
touch "ignoreds/music.mp3"
touch "ignoreds/music.m4a"
mkdir "target"
touch "target/another ignored file"
find "#{test_dir}/git2" -exec touch {} -t #{some_date} \\;
sudo chown #{user}:#{user} -R "#{test_dir}/git2"
EOF
# Hidden and dot file testcases.
# We need to set the permissions of `.` and `..` because they actually
# get displayed in the output here, so this has to come last.

9
xtests/git_12 Normal file
View File

@ -0,0 +1,9 @@
/testcases/git:
drwxrwxr-x - cassowary  1 Jan 12:34 NN additions
drwxrwxr-x - cassowary  1 Jan 12:34 MM edits
drwxrwxr-x - cassowary  1 Jan 12:34 N- moves
/testcases/git2:
drwxrwxr-x - cassowary  1 Jan 12:34 -N deeply
drwxrwxr-x - cassowary  1 Jan 12:34 -N ignoreds
drwxrwxr-x - cassowary  1 Jan 12:34 -- target

15
xtests/git_1212 Normal file
View File

@ -0,0 +1,15 @@
/testcases/git/additions:
.rw-rw-r-- 20 cassowary  1 Jan 12:34 NM edited
.rw-rw-r-- 0 cassowary  1 Jan 12:34 N- staged
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -N unstaged
/testcases/git2/deeply:
drwxrwxr-x - cassowary  1 Jan 12:34 -N nested
/testcases/git/edits:
.rw-rw-r-- 20 cassowary  1 Jan 12:34 MM both
.rw-rw-r-- 15 cassowary  1 Jan 12:34 M- staged
.rw-rw-r-- 20 cassowary  1 Jan 12:34 -M unstaged
/testcases/git2/deeply/nested:
drwxrwxr-x - cassowary  1 Jan 12:34 -N directory

3
xtests/git_1_long Normal file
View File

@ -0,0 +1,3 @@
drwxrwxr-x - cassowary  1 Jan 12:34 NN additions
drwxrwxr-x - cassowary  1 Jan 12:34 MM edits
drwxrwxr-x - cassowary  1 Jan 12:34 N- moves

3
xtests/git_1_nogit Normal file
View File

@ -0,0 +1,3 @@
drwxrwxr-x - cassowary  1 Jan 12:34 additions
drwxrwxr-x - cassowary  1 Jan 12:34 edits
drwxrwxr-x - cassowary  1 Jan 12:34 moves

16
xtests/git_1_recurse Normal file
View File

@ -0,0 +1,16 @@
drwxrwxr-x - cassowary  1 Jan 12:34 NN additions
drwxrwxr-x - cassowary  1 Jan 12:34 MM edits
drwxrwxr-x - cassowary  1 Jan 12:34 N- moves
/testcases/git/additions:
.rw-rw-r-- 20 cassowary  1 Jan 12:34 edited
.rw-rw-r-- 0 cassowary  1 Jan 12:34 staged
.rw-rw-r-- 0 cassowary  1 Jan 12:34 unstaged
/testcases/git/edits:
.rw-rw-r-- 20 cassowary  1 Jan 12:34 both
.rw-rw-r-- 15 cassowary  1 Jan 12:34 staged
.rw-rw-r-- 20 cassowary  1 Jan 12:34 unstaged
/testcases/git/moves:
.rw-rw-r-- 21 cassowary  1 Jan 12:34 thither

11
xtests/git_1_tree Normal file
View File

@ -0,0 +1,11 @@
drwxrwxr-x - cassowary  1 Jan 12:34 /testcases/git
drwxrwxr-x - cassowary  1 Jan 12:34 ├── additions
.rw-rw-r-- 20 cassowary  1 Jan 12:34 │ ├── edited
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ ├── staged
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ └── unstaged
drwxrwxr-x - cassowary  1 Jan 12:34 ├── edits
.rw-rw-r-- 20 cassowary  1 Jan 12:34 │ ├── both
.rw-rw-r-- 15 cassowary  1 Jan 12:34 │ ├── staged
.rw-rw-r-- 20 cassowary  1 Jan 12:34 │ └── unstaged
drwxrwxr-x - cassowary  1 Jan 12:34 └── moves
.rw-rw-r-- 21 cassowary  1 Jan 12:34  └── thither

19
xtests/git_21221 Normal file
View File

@ -0,0 +1,19 @@
/testcases/git2/deeply/nested/directory:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -N l8st
.rw-rw-r-- 18 cassowary  1 Jan 12:34 -M upd8d
/testcases/git/edits:
.rw-rw-r-- 20 cassowary  1 Jan 12:34 MM both
.rw-rw-r-- 15 cassowary  1 Jan 12:34 M- staged
.rw-rw-r-- 20 cassowary  1 Jan 12:34 -M unstaged
/testcases/git2/target:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- another ignored file
/testcases/git2/deeply:
drwxrwxr-x - cassowary  1 Jan 12:34 -N nested
/testcases/git:
drwxrwxr-x - cassowary  1 Jan 12:34 NN additions
drwxrwxr-x - cassowary  1 Jan 12:34 MM edits
drwxrwxr-x - cassowary  1 Jan 12:34 N- moves

9
xtests/git_2_all Normal file
View File

@ -0,0 +1,9 @@
/testcases/git2/deeply:
drwxrwxr-x - cassowary  1 Jan 12:34 -N nested
/testcases/git2/ignoreds:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -N music.m4a
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- music.mp3
/testcases/git2/target:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- another ignored file

2
xtests/git_2_ignoreds Normal file
View File

@ -0,0 +1,2 @@
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -N music.m4a
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- music.mp3

3
xtests/git_2_long Normal file
View File

@ -0,0 +1,3 @@
drwxrwxr-x - cassowary  1 Jan 12:34 -N deeply
drwxrwxr-x - cassowary  1 Jan 12:34 -N ignoreds
drwxrwxr-x - cassowary  1 Jan 12:34 -- target

3
xtests/git_2_nogit Normal file
View File

@ -0,0 +1,3 @@
drwxrwxr-x - cassowary  1 Jan 12:34 deeply
drwxrwxr-x - cassowary  1 Jan 12:34 ignoreds
drwxrwxr-x - cassowary  1 Jan 12:34 target

20
xtests/git_2_recurse Normal file
View File

@ -0,0 +1,20 @@
drwxrwxr-x - cassowary  1 Jan 12:34 -N deeply
drwxrwxr-x - cassowary  1 Jan 12:34 -N ignoreds
drwxrwxr-x - cassowary  1 Jan 12:34 -- target
/testcases/git2/deeply:
drwxrwxr-x - cassowary  1 Jan 12:34 nested
/testcases/git2/deeply/nested:
drwxrwxr-x - cassowary  1 Jan 12:34 directory
/testcases/git2/deeply/nested/directory:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 l8st
.rw-rw-r-- 18 cassowary  1 Jan 12:34 upd8d
/testcases/git2/ignoreds:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 music.m4a
.rw-rw-r-- 0 cassowary  1 Jan 12:34 music.mp3
/testcases/git2/target:
.rw-rw-r-- 0 cassowary  1 Jan 12:34 another ignored file

1
xtests/git_2_target Normal file
View File

@ -0,0 +1 @@
.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- another ignored file

11
xtests/git_2_tree Normal file
View File

@ -0,0 +1,11 @@
drwxrwxr-x - cassowary  1 Jan 12:34 /testcases/git2
drwxrwxr-x - cassowary  1 Jan 12:34 ├── deeply
drwxrwxr-x - cassowary  1 Jan 12:34 │ └── nested
drwxrwxr-x - cassowary  1 Jan 12:34 │ └── directory
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ ├── l8st
.rw-rw-r-- 18 cassowary  1 Jan 12:34 │ └── upd8d
drwxrwxr-x - cassowary  1 Jan 12:34 ├── ignoreds
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ ├── music.m4a
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ └── music.mp3
drwxrwxr-x - cassowary  1 Jan 12:34 └── target
.rw-rw-r-- 0 cassowary  1 Jan 12:34  └── another ignored file

View File

@ -188,9 +188,31 @@ COLUMNS=80 $exa_binary --colour=never $testcases/file-names-exts | diff -q -
# Git
$exa $testcases/git/additions -l --git 2>&1 | diff -q - $results/git_additions || exit 1
$exa $testcases/git/edits -l --git 2>&1 | diff -q - $results/git_edits || exit 1
$exa $testcases/git/{additions,edits} -l --git 2>&1 | diff -q - $results/git_both || exit 1
$exa $testcases/git -l --git 2>&1 | diff -q - $results/git_1_long || exit 1
$exa $testcases/git -l 2>&1 | diff -q - $results/git_1_nogit || exit 1
$exa $testcases/git --tree -l --git 2>&1 | diff -q - $results/git_1_tree || exit 1
$exa $testcases/git --recurse -l --git 2>&1 | diff -q - $results/git_1_recurse || exit 1
$exa $testcases/git/additions -l --git 2>&1 | diff -q - $results/git_1_additions || exit 1
$exa $testcases/git/edits -l --git 2>&1 | diff -q - $results/git_1_edits || exit 1
$exa $testcases/git/{additions,edits} -l --git 2>&1 | diff -q - $results/git_1_both || exit 1
$exa $testcases/git2 -l --git 2>&1 | diff -q - $results/git_2_long || exit 1
$exa $testcases/git2 -l 2>&1 | diff -q - $results/git_2_nogit || exit 1
$exa $testcases/git2 --tree -l --git 2>&1 | diff -q - $results/git_2_tree || exit 1
$exa $testcases/git2 --recurse -l --git 2>&1 | diff -q - $results/git_2_recurse || exit 1
$exa $testcases/git2/ignoreds -l --git 2>&1 | diff -q - $results/git_2_ignoreds || exit 1
$exa $testcases/git2/target -l --git 2>&1 | diff -q - $results/git_2_target || exit 1
$exa $testcases/git2/{deeply,ignoreds,target} -l --git 2>&1 | diff -q - $results/git_2_all || exit 1
$exa $testcases/git $testcases/git2 --git --long | diff -q - $results/git_12 || exit 1
$exa $testcases/git/additions $testcases/git2/deeply \
$testcases/git/edits $testcases/git2/deeply/nested --git --long | diff -q - $results/git_1212 || exit 1
$exa $testcases/git2/deeply/nested/directory $testcases/git/edits \
$testcases/git2/target $testcases/git2/deeply $testcases/git --git --long | diff -q - $results/git_21221 || exit 1
# Hidden files