diff --git a/tests/libtest.sh b/tests/libtest.sh index 9601ec27..cbd3ea62 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -51,47 +51,43 @@ assert_file_has_content () { fi } -setup_test_repository1 () { +setup_test_repository () { + mode=$1 + shift + + oldpwd=`pwd` + mkdir files cd files - ht_files=`pwd` - export ht_files - echo first > firstfile - echo second > secondfile - - 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 -} - -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 ce5a48cc..57315de4 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/t0000-init-link-files-fsck.sh b/tests/t0000-init-link-files-fsck.sh deleted file mode 100755 index b035045f..00000000 --- a/tests/t0000-init-link-files-fsck.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..5' - -mkdir files -files=`pwd`/files -touch files/foo -echo moo > files/cow - -mkdir repo -cd repo -ostree init -echo 'ok init' -ostree fsck -q -echo 'ok fsck' -ostree link-file $files/foo -echo 'ok link' -ostree fsck -q -echo 'ok link-fsk' -ostree link-file $files/cow -ostree fsck -q -echo 'ok link-fsk2' - 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 7d2cb3dd..39fb14f3 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 +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 secondfile -echo 'ok checkout verify exists' - - +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/t0001-init-out-of-tree.sh b/tests/t0001-init-out-of-tree.sh deleted file mode 100755 index 7ab50798..00000000 --- a/tests/t0001-init-out-of-tree.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..3' - -mkdir files -cd files -echo hello > yy - -mkdir ../repo -ostree init --repo=../repo -echo 'ok init' -ostree fsck --repo=../repo -q -echo 'ok fsck' -ostree link-file --repo=../repo yy -echo 'ok link' diff --git a/tests/t0002-commit-one.sh b/tests/t0002-commit-one.sh deleted file mode 100755 index 5f181594..00000000 --- a/tests/t0002-commit-one.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..4' - -mkdir files -cd files -echo hello > yy - -mkdir ../repo -repo="--repo=../repo" -ostree init $repo -echo 'ok init' -ostree commit $repo -b test -s "Test Commit" -m "Commit body" --add=yy -echo 'ok commit' -ostree fsck -q $repo -echo 'ok fsck' -ostree rev-parse $repo test -echo 'ok rev-parse' 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 1916542f..b60af455 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/t0003-commit-multiple.sh b/tests/t0003-commit-multiple.sh deleted file mode 100755 index 74f8de6d..00000000 --- a/tests/t0003-commit-multiple.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..4' - -mkdir files -cd files -echo first > firstfile -echo second > secondfile - -mkdir ../repo -repo="--repo=../repo" -ostree init $repo -echo 'ok init' -ostree commit $repo -b test -s "Test Commit 1" -m "Commit body first" --add=firstfile -echo 'ok commit 1' -ostree commit $repo -b test -s "Test Commit 2" -m "Commit body first" --add=secondfile -echo 'ok commit 2' -ostree fsck -q $repo -echo 'ok fsck' 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 491b2b75..16093d75 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 diff --git a/tests/t0005-nested-tree.sh b/tests/t0005-nested-tree.sh deleted file mode 100755 index 239a60ee..00000000 --- a/tests/t0005-nested-tree.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..5' - -setup_test_repository2 -echo 'ok setup' -ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head -echo 'ok checkout cmd' -cd $test_tmpdir/checkout2-head -assert_has_file firstfile -echo 'ok checkout firstfile' -assert_has_file baz/cow -assert_has_file baz/saucer -echo 'ok checkout baz (2)' -assert_has_file baz/deeper/ohyeah -assert_has_file baz/another/y -echo 'ok checkout verify exists' - - diff --git a/tests/t0006-removal.sh b/tests/t0006-removal.sh deleted file mode 100755 index 4b2d4319..00000000 --- a/tests/t0006-removal.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..4' - -setup_test_repository2 -ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head -echo 'ok setup' -cd $test_tmpdir/checkout2-head -ostree commit $ot_repo -b test2 -s delete -r firstfile -echo 'ok rm firstfile' -assert_has_file firstfile # It should still exist in this checkout -cd $test_tmpdir -ostree checkout $ot_repo test2 $test_tmpdir/checkout3-head -echo 'ok checkout 3' -cd $test_tmpdir/checkout3-head -assert_not_has_file firstfile -assert_has_file baz/saucer -echo 'ok removal full' diff --git a/tests/t0009-commit-symlink.sh b/tests/t0009-commit-symlink.sh deleted file mode 100755 index ad9ad98f..00000000 --- a/tests/t0009-commit-symlink.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo "1..2" - -setup_test_repository2 - -ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head -cd $ht_files -ln -s foo bar -ostree commit $ot_repo -b test2 -s "Add a symlink" -m "To test it" --add=bar -echo "ok commit symlink" -ostree fsck $ot_repo -echo "ok fsck" diff --git a/tests/t0010-multiple-branches.sh b/tests/t0010-multiple-branches.sh deleted file mode 100755 index fc94baa1..00000000 --- a/tests/t0010-multiple-branches.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..3' - -setup_test_repository2 -ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head -cd $test_tmpdir/checkout2-head -echo test3file > test3file -ostree commit $ot_repo -s 'Add test3file' -b test3 -p test2 --add test3file -echo "ok commit test3 branch" -ostree checkout $ot_repo test3 $test_tmpdir/checkout3-head -echo "ok checkout test3 branch" -cd $test_tmpdir/checkout3-head -assert_has_file test3file -echo "ok checkout test3file" diff --git a/tests/t0013-commit-archive.sh b/tests/t0013-commit-archive.sh deleted file mode 100755 index 7f6ffc9b..00000000 --- a/tests/t0013-commit-archive.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2011 Colin Walters -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Author: Colin Walters - -set -e - -. libtest.sh - -echo '1..4' - -mkdir files -cd files -echo first > firstfile -echo second > secondfile -ln -s foo bar - -mkdir ../repo -repo="--repo=../repo" -ostree init --archive $repo -echo 'ok init' -ostree commit $repo -b test -s "Test Commit 1" -m "Commit body first" --add=firstfile -echo 'ok commit 1' -ostree commit $repo -b test -s "Test Commit 2" -m "Commit body first" --add=secondfile --add=bar -echo 'ok commit 2' -ostree fsck -q $repo -echo 'ok fsck'