Przeglądaj źródła

Add xtests for existing Git implementation

Benjamin Sago 8 lat temu
rodzic
commit
e10c4b3eb9
4 zmienionych plików z 42 dodań i 0 usunięć
  1. 31 0
      Vagrantfile
  2. 3 0
      xtests/git_additions
  3. 3 0
      xtests/git_edits
  4. 5 0
      xtests/run.sh

+ 31 - 0
Vagrantfile

@@ -339,6 +339,37 @@ Vagrant.configure(2) do |config|
     EOF
 
 
+    # A sample Git repository
+    # This uses cd because it's easier than telling Git where to go each time
+    config.vm.provision :shell, privileged: false, inline: <<-EOF
+        set -xe
+        mkdir "#{test_dir}/git"
+        cd    "#{test_dir}/git"
+        git init
+
+        mkdir edits additions moves
+
+        echo "original content" | tee edits/{staged,unstaged,both}
+        echo "this file gets moved" > moves/hither
+
+        git add edits moves
+        git commit -m "Automated test commit"
+
+
+        echo "modifications!" | tee edits/{staged,both}
+        touch additions/{staged,edited}
+        mv moves/{hither,thither}
+
+        git add edits moves additions
+        echo "more modifications!" | tee edits/unstaged edits/both additions/edited
+        touch additions/unstaged
+
+
+        touch -t #{some_date} "#{test_dir}/git/"*/*
+        sudo chown #{user}:#{user} -R "#{test_dir}/git"
+    EOF
+
+
     # Install kcov for test coverage
     # This doesn’t run coverage over the xtests so it’s less useful for now
     if ENV.key?('INSTALL_KCOV')

+ 3 - 0
xtests/git_additions

@@ -0,0 +1,3 @@
+.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

+ 3 - 0
xtests/git_edits

@@ -0,0 +1,3 @@
+.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

+ 5 - 0
xtests/run.sh

@@ -101,4 +101,9 @@ COLUMNS=80 $exa $testcases/links    2>&1 | diff -q - $results/links        || ex
 $exa $testcases/links/* -1 | diff -q - $results/links_1_files || exit 1
 
 
+# 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
+
+
 echo "All the tests passed!"