[ostree] Consolidate tests



commit c910f29c004aa0a803061c1eaf2c6bf719ffdf94
Author: Colin Walters <walters verbum org>
Date:   Mon Oct 31 22:42:14 2011 -0400

    Consolidate tests
    
    Rather than having a ton of separate tests, be like git and have
    a "basic" test that does a lot of the, well, basics.

 tests/libtest.sh                                   |   38 +++++++---------
 tests/{t0007-commit-stdin.sh => t0000-basic.sh}    |   35 ++++++++++++---
 tests/t0000-init-link-files-fsck.sh                |   45 --------------------
 .../{t0004-checkout-test1.sh => t0001-archive.sh}  |   18 ++++----
 tests/t0001-init-out-of-tree.sh                    |   37 ----------------
 tests/t0002-commit-one.sh                          |   40 -----------------
 tests/{t0008-log.sh => t0002-log.sh}               |    2 +-
 tests/t0003-commit-multiple.sh                     |   41 ------------------
 tests/{t0011-remote-add.sh => t0003-remote-add.sh} |    2 +-
 tests/{t0012-pull.sh => t0004-pull.sh}             |    0
 tests/t0005-nested-tree.sh                         |   41 ------------------
 tests/t0006-removal.sh                             |   40 -----------------
 tests/t0009-commit-symlink.sh                      |   35 ---------------
 tests/t0010-multiple-branches.sh                   |   37 ----------------
 tests/t0013-commit-archive.sh                      |   42 ------------------
 15 files changed, 57 insertions(+), 396 deletions(-)
---
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 9601ec2..cbd3ea6 100644
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -51,47 +51,43 @@ assert_file_has_content () {
     fi
 }
 
-setup_test_repository1 () {
-    mkdir files
-    cd files
-    ht_files=`pwd`
-    export ht_files
-    echo first > firstfile
-    echo second > secondfile
+setup_test_repository () {
+    mode=$1
+    shift
 
-    mkdir ../repo
-    ot_repo="--repo=../repo"
-    export ot_repo
-    ostree init $ot_repo
-    ostree commit $ot_repo -b test -s "Test Commit 1" -m "Commit body first" --add=firstfile
-    ostree commit $ot_repo -b test -s "Test Commit 2" -m "Commit body second" --add=secondfile
-    ostree fsck -q $ot_repo
-}
+    oldpwd=`pwd`
 
-setup_test_repository2 () {
     mkdir files
     cd files
-    ht_files=`pwd`
+    ot_files=`pwd`
     export ht_files
+    ln -s nosuchfile somelink
     echo first > firstfile
     mkdir baz
     echo moo > baz/cow
     echo alien > baz/saucer
     mkdir baz/deeper
     echo hi > baz/deeper/ohyeah
+    ln -s nonexistent baz/alink
     mkdir baz/another/
     echo x > baz/another/y
 
-    cd ..
+    cd ${test_tmpdir}
     mkdir repo
     cd repo
     ot_repo="--repo=`pwd`"
     cd ../files
     export ot_repo
-    ostree init $ot_repo
-    ostree commit $ot_repo -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile
-    ostree commit $ot_repo -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow  --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
+    if test "$mode" = "archive"; then
+	ostree init --archive $ot_repo
+    else
+	ostree init --archive $ot_repo
+    fi
+    ostree commit $ot_repo -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile --add=somelink
+    ostree commit $ot_repo -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow  --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y --add=baz/alink
     ostree fsck -q $ot_repo
+
+    cd $oldpwd
 }
 
 setup_fake_remote_repo1() {
diff --git a/tests/t0007-commit-stdin.sh b/tests/t0000-basic.sh
similarity index 64%
rename from tests/t0007-commit-stdin.sh
rename to tests/t0000-basic.sh
index ce5a48c..57315de 100755
--- a/tests/t0007-commit-stdin.sh
+++ b/tests/t0000-basic.sh
@@ -20,13 +20,32 @@
 
 set -e
 
+echo "1..6"
+
 . libtest.sh
 
-echo "1..2"
+setup_test_repository "regular"
+echo "ok setup"
+
+ostree checkout $ot_repo test2 checkout-test2
+echo "ok checkout"
+
+cd checkout-test2
+assert_has_file firstfile
+assert_has_file baz/cow
+assert_file_has_content baz/cow moo
+assert_has_file baz/deeper/ohyeah
+echo "ok content"
+
+ostree commit $ot_repo -b test2 -s delete -r firstfile
+assert_has_file firstfile  # It should still exist in this checkout
+cd $test_tmpdir
+ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-2
+cd $test_tmpdir/checkout-test2-2
+assert_not_has_file firstfile
+assert_has_file baz/saucer
+echo "ok removal"
 
-setup_test_repository2
-ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
-cd $test_tmpdir/checkout2-head
 mkdir -p a/nested/tree
 echo one > a/nested/tree/1
 echo two2 > a/nested/2
@@ -40,9 +59,11 @@ echo anotherone > another/nested/tree/1
 echo whee2 > another/whee
 # FIXME - remove grep for .
 find | grep -v '^\.$' | ostree commit $ot_repo -b test2 -s "From find" --from-stdin
-echo "ok commit stdin"
-ostree checkout $ot_repo test2 $test_tmpdir/checkout3-head
-cd $test_tmpdir/checkout3-head
+echo "ok stdin commit"
+
+cd ${test_tmpdir}
+ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-3
+cd checkout-test2-3
 assert_has_file a/nested/2
 assert_file_has_content a/nested/2 'two2'
 echo "ok stdin contents"
diff --git a/tests/t0004-checkout-test1.sh b/tests/t0001-archive.sh
similarity index 78%
rename from tests/t0004-checkout-test1.sh
rename to tests/t0001-archive.sh
index 7d2cb3d..39fb14f 100755
--- a/tests/t0004-checkout-test1.sh
+++ b/tests/t0001-archive.sh
@@ -24,13 +24,15 @@ set -e
 
 echo '1..3'
 
-setup_test_repository1
-echo 'ok setup'
-ostree checkout $ot_repo test $test_tmpdir/checkout1-head
-echo 'ok checkout cmd'
-cd $test_tmpdir/checkout1-head
-assert_has_file firstfile
-assert_has_file secondfile
-echo 'ok checkout verify exists'
+setup_test_repository "archive"
+echo "ok setup"
 
+ostree checkout $ot_repo test2 checkout-test2
+echo "ok checkout"
 
+cd checkout-test2
+assert_has_file firstfile
+assert_has_file baz/cow
+assert_file_has_content baz/cow moo
+assert_has_file baz/deeper/ohyeah
+echo "ok content"
diff --git a/tests/t0008-log.sh b/tests/t0002-log.sh
similarity index 97%
rename from tests/t0008-log.sh
rename to tests/t0002-log.sh
index 1916542..b60af45 100755
--- a/tests/t0008-log.sh
+++ b/tests/t0002-log.sh
@@ -24,7 +24,7 @@ set -e
 
 echo "1..1"
 
-setup_test_repository2
+setup_test_repository "regular"
 ostree log $ot_repo test2 > $test_tmpdir/log.txt
 assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
 assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
diff --git a/tests/t0011-remote-add.sh b/tests/t0003-remote-add.sh
similarity index 96%
rename from tests/t0011-remote-add.sh
rename to tests/t0003-remote-add.sh
index 491b2b7..16093d7 100755
--- a/tests/t0011-remote-add.sh
+++ b/tests/t0003-remote-add.sh
@@ -24,7 +24,7 @@ set -e
 
 echo '1..2'
 
-setup_test_repository2
+setup_test_repository "regular"
 ostree remote add $ot_repo origin http://example.com/ostree/gnome
 echo "ok remote add"
 assert_file_has_content $test_tmpdir/repo/config "example.com"
diff --git a/tests/t0012-pull.sh b/tests/t0004-pull.sh
similarity index 100%
rename from tests/t0012-pull.sh
rename to tests/t0004-pull.sh



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]