xbps-checkvers: more fixes and new test cases.

- This now checks for vars that have refs to other vars:

	pkgname=${_myvar}

- This now checks for unwanted garbage before assignment:

	. ./source/file
	pkgname=${_myvar}

- Misc tweaks to use my coding style.
This commit is contained in:
Juan RP
2015-02-17 10:20:59 +01:00
parent 7cdba2ed14
commit 38e71e8e1c
2 changed files with 177 additions and 68 deletions
+96 -5
View File
@@ -27,6 +27,35 @@ EOF
atf_check_equal "$out" ""
}
atf_test_case srcpkg_older_with_refs
srcpkg_older_with_refs_head() {
atf_set "descr" "xbps-checkvers(8): test when srcpkg contains an older version with refs"
}
srcpkg_older_with_refs_body() {
mkdir -p some_repo pkg_A void-packages/srcpkgs/A
touch pkg_A/file00
cat > void-packages/srcpkgs/A/template <<EOF
_mypkgname=A
_myversion=1
pkgname=\${_mypkgname}
version=\${_myversion}.0
revision=1
do_install() {
:
}
EOF
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
out=`xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages`
atf_check_equal $? 0
atf_check_equal "$out" ""
}
atf_test_case srcpkg_newer
srcpkg_newer_head() {
@@ -54,6 +83,65 @@ EOF
atf_check_equal "$out" "pkgname: A repover: 1.0_1 srcpkgver: 1.1_1"
}
atf_test_case srcpkg_newer_with_refs
srcpkg_newer_with_refs_head() {
atf_set "descr" "xbps-checkvers(8): test when srcpkg contains a newer version with refs"
}
srcpkg_newer_with_refs_body() {
mkdir -p some_repo pkg_A void-packages/srcpkgs/A
touch pkg_A/file00
cat > void-packages/srcpkgs/A/template <<EOF
_mypkgname="A"
_myversion="1"
pkgname=\${_mypkgname}
version=\${_myversion}.1
revision=1
do_install() {
:
}
EOF
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
out=`xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages`
atf_check_equal $? 0
atf_check_equal "$out" "pkgname: A repover: 1.0_1 srcpkgver: 1.1_1"
}
atf_test_case srcpkg_newer_with_refs_and_source
srcpkg_newer_with_refs_and_source_head() {
atf_set "descr" "xbps-checkvers(8): test when srcpkg contains a newer version with refs and file sourcing"
}
srcpkg_newer_with_refs_and_source_body() {
mkdir -p some_repo pkg_A void-packages/srcpkgs/A
touch pkg_A/file00
cat > void-packages/srcpkgs/A/template <<EOF
. ./source/a/file
_mypkgname="A"
_myversion="1"
pkgname=\${_mypkgname}
version=\${_myversion}.1
revision=1
do_install() {
:
}
EOF
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
out=`xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages`
atf_check_equal $? 0
atf_check_equal "$out" "pkgname: A repover: 1.0_1 srcpkgver: 1.1_1"
}
atf_test_case srcpkg_missing_pkgname
srcpkg_missing_pkgname_head() {
@@ -77,7 +165,7 @@ EOF
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages 2>out
atf_check_equal $? 1
atf_check_equal "$(cat out)" "ERROR: 'srcpkgs/A/template': missing pkgname variable!"
atf_check_equal "$(cat out)" "ERROR: 'A/template': missing pkgname variable!"
}
atf_test_case srcpkg_missing_version
@@ -103,7 +191,7 @@ EOF
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages 2>out
atf_check_equal $? 1
atf_check_equal "$(cat out)" "ERROR: 'srcpkgs/A/template': missing version variable!"
atf_check_equal "$(cat out)" "ERROR: 'A/template': missing version variable!"
}
atf_test_case srcpkg_missing_revision
@@ -129,7 +217,7 @@ EOF
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages 2>out
atf_check_equal $? 1
atf_check_equal "$(cat out)" "ERROR: 'srcpkgs/A/template': missing revision variable!"
atf_check_equal "$(cat out)" "ERROR: 'A/template': missing revision variable!"
}
atf_test_case srcpkg_missing_pkgver
@@ -155,7 +243,7 @@ EOF
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages 2>out
atf_check_equal $? 1
atf_check_equal "$(cat out)" "ERROR: 'srcpkgs/A/template': missing pkgname variable!"
atf_check_equal "$(cat out)" "ERROR: 'A/template': missing pkgname variable!"
}
atf_test_case srcpkg_missing_pkgverrev
@@ -181,7 +269,7 @@ EOF
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages 2>out
atf_check_equal $? 1
atf_check_equal "$(cat out)" "ERROR: 'srcpkgs/A/template': missing pkgname variable!"
atf_check_equal "$(cat out)" "ERROR: 'A/template': missing pkgname variable!"
}
atf_test_case reverts
@@ -215,7 +303,10 @@ EOF
atf_init_test_cases() {
atf_add_test_case srcpkg_newer
atf_add_test_case srcpkg_newer_with_refs
atf_add_test_case srcpkg_newer_with_refs_and_source
atf_add_test_case srcpkg_older
atf_add_test_case srcpkg_older_with_refs
atf_add_test_case srcpkg_missing_pkgname
atf_add_test_case srcpkg_missing_version
atf_add_test_case srcpkg_missing_revision