From 55aaecb74dab4e6adb5d3a454df3bbe78994cbd3 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Mon, 28 Aug 2017 15:10:29 +0100 Subject: [PATCH] Improve Git test coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- Vagrantfile | 35 +++++++++++++++++++---- xtests/git_12 | 9 ++++++ xtests/git_1212 | 15 ++++++++++ xtests/{git_additions => git_1_additions} | 0 xtests/{git_both => git_1_both} | 0 xtests/{git_edits => git_1_edits} | 0 xtests/git_1_long | 3 ++ xtests/git_1_nogit | 3 ++ xtests/git_1_recurse | 16 +++++++++++ xtests/git_1_tree | 11 +++++++ xtests/git_21221 | 19 ++++++++++++ xtests/git_2_all | 9 ++++++ xtests/git_2_ignoreds | 2 ++ xtests/git_2_long | 3 ++ xtests/git_2_nogit | 3 ++ xtests/git_2_recurse | 20 +++++++++++++ xtests/git_2_target | 1 + xtests/git_2_tree | 11 +++++++ xtests/run.sh | 28 ++++++++++++++++-- 19 files changed, 179 insertions(+), 9 deletions(-) create mode 100644 xtests/git_12 create mode 100644 xtests/git_1212 rename xtests/{git_additions => git_1_additions} (100%) rename xtests/{git_both => git_1_both} (100%) rename xtests/{git_edits => git_1_edits} (100%) create mode 100644 xtests/git_1_long create mode 100644 xtests/git_1_nogit create mode 100644 xtests/git_1_recurse create mode 100644 xtests/git_1_tree create mode 100644 xtests/git_21221 create mode 100644 xtests/git_2_all create mode 100644 xtests/git_2_ignoreds create mode 100644 xtests/git_2_long create mode 100644 xtests/git_2_nogit create mode 100644 xtests/git_2_recurse create mode 100644 xtests/git_2_target create mode 100644 xtests/git_2_tree diff --git a/Vagrantfile b/Vagrantfile index 7335be9..c08c394 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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. diff --git a/xtests/git_12 b/xtests/git_12 new file mode 100644 index 0000000..1cb8570 --- /dev/null +++ b/xtests/git_12 @@ -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 diff --git a/xtests/git_1212 b/xtests/git_1212 new file mode 100644 index 0000000..a283aff --- /dev/null +++ b/xtests/git_1212 @@ -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 diff --git a/xtests/git_additions b/xtests/git_1_additions similarity index 100% rename from xtests/git_additions rename to xtests/git_1_additions diff --git a/xtests/git_both b/xtests/git_1_both similarity index 100% rename from xtests/git_both rename to xtests/git_1_both diff --git a/xtests/git_edits b/xtests/git_1_edits similarity index 100% rename from xtests/git_edits rename to xtests/git_1_edits diff --git a/xtests/git_1_long b/xtests/git_1_long new file mode 100644 index 0000000..404545d --- /dev/null +++ b/xtests/git_1_long @@ -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 diff --git a/xtests/git_1_nogit b/xtests/git_1_nogit new file mode 100644 index 0000000..42500ad --- /dev/null +++ b/xtests/git_1_nogit @@ -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 diff --git a/xtests/git_1_recurse b/xtests/git_1_recurse new file mode 100644 index 0000000..c15df47 --- /dev/null +++ b/xtests/git_1_recurse @@ -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 diff --git a/xtests/git_1_tree b/xtests/git_1_tree new file mode 100644 index 0000000..97500fb --- /dev/null +++ b/xtests/git_1_tree @@ -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 diff --git a/xtests/git_21221 b/xtests/git_21221 new file mode 100644 index 0000000..186707a --- /dev/null +++ b/xtests/git_21221 @@ -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 diff --git a/xtests/git_2_all b/xtests/git_2_all new file mode 100644 index 0000000..cd3bb02 --- /dev/null +++ b/xtests/git_2_all @@ -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 diff --git a/xtests/git_2_ignoreds b/xtests/git_2_ignoreds new file mode 100644 index 0000000..341a7ea --- /dev/null +++ b/xtests/git_2_ignoreds @@ -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 diff --git a/xtests/git_2_long b/xtests/git_2_long new file mode 100644 index 0000000..d530895 --- /dev/null +++ b/xtests/git_2_long @@ -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 diff --git a/xtests/git_2_nogit b/xtests/git_2_nogit new file mode 100644 index 0000000..74fb129 --- /dev/null +++ b/xtests/git_2_nogit @@ -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 diff --git a/xtests/git_2_recurse b/xtests/git_2_recurse new file mode 100644 index 0000000..16d3738 --- /dev/null +++ b/xtests/git_2_recurse @@ -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 diff --git a/xtests/git_2_target b/xtests/git_2_target new file mode 100644 index 0000000..6a636a0 --- /dev/null +++ b/xtests/git_2_target @@ -0,0 +1 @@ +.rw-rw-r-- 0 cassowary  1 Jan 12:34 -- another ignored file diff --git a/xtests/git_2_tree b/xtests/git_2_tree new file mode 100644 index 0000000..b57e1bc --- /dev/null +++ b/xtests/git_2_tree @@ -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 diff --git a/xtests/run.sh b/xtests/run.sh index 4b1e782..ad17c67 100755 --- a/xtests/run.sh +++ b/xtests/run.sh @@ -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