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.
This commit is contained in:
Colin Walters 2011-10-31 22:42:14 -04:00
parent 8769f4afd8
commit c910f29c00
15 changed files with 60 additions and 399 deletions

View File

@ -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() {

View File

@ -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"

View File

@ -1,45 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -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"

View File

@ -1,37 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -1,40 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -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"

View File

@ -1,41 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -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"

View File

@ -1,41 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -1,40 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'

View File

@ -1,35 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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"

View File

@ -1,37 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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"

View File

@ -1,42 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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 <walters@verbum.org>
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'