Merged from trunk 5549:5565
authorFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 22:43:47 +0000 (22:43 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 22:43:47 +0000 (22:43 -0000)
continue is only for loops (genone)

Make FEATURES=test imply USE=test (genone)

Add note that any value enables EPAUSE_IGNORE (genone)

Use isinstance(foo, basestring) so that it can work with unicode strings
too.

Use dict.get() to prevent a potential (bug unlikely) KeyError.

add support for user-customizable compression #9870 (SpankMan)

docs for grabdict (WarnerBro)

Commit unit tests, hey look THEY ARE BROKEN (WarnerBro)

get_operator tests (WarnerBro)

add some invalid operators to the test to denote that get_operator
doesn't validate them, also make sure some common mis-typed things are
tested (=> instead of >= fex) (WarnerBro)

take some advice and use AssertEqual/NotEqual (WarnerBro)

I owed brian harring 3.50, for th previous advice about
assertEqual/NotEqual, oh, add dep_getcpv tests too (WarnerBro)

getslot tests (WarnerBro)

elaborate a bit on isjustname() (WarnerBro)

isjustname tests (WarnerBro)

For bug #50738, inform the user about the location of the timestamp file
and that it can be removed to force sync.

svn path=/main/branches/prefix/; revision=5617

27 files changed:
bin/dodoc
bin/doinfo
bin/ecompress [new file with mode: 0755]
bin/ecompressdir [new file with mode: 0755]
bin/emerge
bin/misc-functions.sh
bin/prepalldocs
bin/prepallinfo
bin/prepallman
bin/prepinfo
bin/prepman
man/make.conf.5
pym/portage.py
pym/portage_dep.py
pym/portage_exception.py
pym/portage_util.py
tests/portage_dep/test_dep_getcpv.py [new file with mode: 0644]
tests/portage_dep/test_dep_getslot.py [new file with mode: 0644]
tests/portage_dep/test_get_operator.py [new file with mode: 0644]
tests/portage_dep/test_isjustname.py [new file with mode: 0644]
tests/portage_dep/test_isvalidatom.py [new file with mode: 0644]
tests/portage_dep/test_match_from_list.py
tests/portage_util/test_grabdict.py [new file with mode: 0644]
tests/portage_util/test_normalizedPath.py
tests/portage_util/test_stackDictList.py
tests/portage_util/test_stackDicts.py
tests/portage_util/test_stackLists.py

index adbf612df2059daf5c2c9fa76645e0038b265113..b26a7659da0e725ee3ab29ea951650b8acccd653 100755 (executable)
--- a/bin/dodoc
+++ b/bin/dodoc
@@ -1,9 +1,10 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
+# $Id$
 
 if [ $# -lt 1 ] ; then
-       echo "$0: at least one argument needed" 1>&2
+       vecho "${0##*/}: at least one argument needed" 1>&2
        exit 1  
 fi
 
@@ -16,7 +17,7 @@ ret=0
 for x in "$@" ; do
        if [ -s "${x}" ] ; then
                install -m0644 "${x}" "${dir}"
-               gzip -f -9 "${dir}/${x##*/}"
+               ecompress "${dir}/${x##*/}"
        elif [ ! -e "${x}" ] ; then
                echo "dodoc: ${x} does not exist" 1>&2
                ((++ret))
index 0607e8c82ba16e7d5caa764089676b956c28dd16..d38de9be065592469f4ab21aad6e48f29bdccc6a 100755 (executable)
@@ -1,21 +1,15 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/doinfo,v 1.7 2004/10/04 13:56:50 vapier Exp $
 
-if [ ${#} -lt 1 ] ; then
-       echo "doinfo: at least one argument needed"
+if [[ -z $1 ]] ; then
+       vecho "${0##*/}: at least one argument needed"
        exit 1  
 fi
-if [ ! -d "${ED}/usr/share/info" ] ; then
-       install -d "${ED}/usr/share/info"
+
+if [[ ! -d ${ED}usr/share/info ]] ; then
+       install -d "${ED}usr/share/info" || exit 1
 fi
 
-for x in "$@" ; do
-       if [ -e "${x}" ] ; then
-               install -m 0644 "${x}" "${ED}/usr/share/info"
-               gzip -f -9 "${ED}/usr/share/info/${x##*/}"
-       else
-               echo "doinfo: ${x} does not exist"
-       fi
-done
+exec install -m0644 "$@" "${ED}usr/share/info"
diff --git a/bin/ecompress b/bin/ecompress
new file mode 100755 (executable)
index 0000000..9117217
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: prepman 5507 2007-01-10 04:22:27Z zmedico $
+
+if [[ -z $1 ]] ; then
+       echo "${0##*/}: at least one argument needed" 1>&2
+       exit 1
+fi
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+# setup compression stuff
+PORTAGE_COMPRESS=${PORTAGE_COMPRESS:-bzip2}
+if [[ -z ${PORTAGE_COMPRESS_FLAGS} ]] ; then
+       case ${PORTAGE_COMPRESS} in
+               bzip2|gzip)  PORTAGE_COMPRESS_FLAGS="-9";;
+       esac
+fi
+
+case $1 in
+       --suffix)
+               set -e
+               tmpdir="${T}"/.ecompress$$.${RANDOM}
+               mkdir "${tmpdir}"
+               cd "${tmpdir}"
+               # we have to fill the file enough so that there is something
+               # to compress as some programs will refuse to do compression
+               # if it cannot actually compress the file
+               echo {0..1000} > compressme
+               ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme
+               suffix=$(ls compressme*)
+               suffix=${suffix#compressme}
+               cd /
+               rm -rf "${tmpdir}"
+               echo "${suffix}"
+               ;;
+       --bin)
+               echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
+               ;;
+       *)
+               exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
+               ;;
+esac
diff --git a/bin/ecompressdir b/bin/ecompressdir
new file mode 100755 (executable)
index 0000000..405f8e2
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: prepalldocs 3483 2006-06-10 21:40:40Z genone $
+
+if [[ -z $1 ]] ; then
+       echo "${0##*/}: at least one argument needed" 1>&2
+       exit 1
+fi
+
+# figure out the new suffix
+suffix=$(ecompress --suffix)
+[[ -z ${suffix} ]] && exit 0
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+ret=0
+
+for dir in "$@" ; do
+       dir="${D}${dir}"
+       if [[ ! -d ${dir} ]] ; then
+               vecho "${0##*/}: ${dir#${D}} does not exist!"
+               continue
+       else
+               vecho "${0##*/}: $(ecompress --bin) ${dir#${D}}"
+       fi
+
+       find "${dir}" -type f -print0 | xargs -0 ecompress
+       ((ret+=$?))
+       find -L "${dir}" -type l | \
+       while read brokenlink ; do
+               olddest=$(readlink "${brokenlink}")
+               newdest="${olddest}${suffix}"
+               if [[ -e ${newdest} ]] ; then
+                       ln -snf "${newdest}" "${brokenlink}"
+                       ((ret+=$?))
+               else
+                       vecho "ecompressdir: unknown broken symlink: ${brokenlink}"
+                       ((++ret))
+               fi
+       done
+done
+
+exit ${ret}
index c4234c2b01042cc1c3eac113bbd2cec300a1f2ea..75d4cb7214c6e253884d4c65d24478fb45ff9bbe 100755 (executable)
@@ -3858,6 +3858,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                        print ">>> Timestamps on the server and in the local repository are the same."
                                        print ">>> Cancelling all further sync action. You are already up to date."
                                        print ">>>"
+                                       print ">>> In order to force sync, remove '%s'." % tmpservertimestampfile
+                                       print ">>>"
                                        print
                                        sys.exit(0)
                                elif (servertimestamp != 0) and (servertimestamp < mytimestamp):
@@ -3867,6 +3869,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                        print ">>>"
                                        print ">>> SERVER OUT OF DATE: %s" % dosyncuri
                                        print ">>>"
+                                       print ">>> In order to force sync, remove '%s'." % tmpservertimestampfile
+                                       print ">>>"
                                        print
                                elif (servertimestamp == 0) or (servertimestamp > mytimestamp):
                                        # actual sync
index f2f54f6bad3c9f68d87a027bebd064e6b2ceb32c..cdc2eb7a391c6aa531a2ec9cd0f058bb2d8eb16d 100644 (file)
@@ -365,9 +365,7 @@ install_qa_check() {
        fi
 
        # Portage regenerates this on the installed system.
-       if [[ -f ${ED}/usr/share/info/dir.gz ]] ; then
-               rm -f "${ED}"/usr/share/info/dir.gz
-       fi
+       rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2}
 
        if hasq multilib-strict ${FEATURES} && \
           [[ -x ${EPREFIX}/usr/bin/file && -x ${EPREFIX}/usr/bin/find ]] && \
index b592058f64de09d8e2f3c7e09de24e36b119263c..3b830b0654619450a9f1730cf6cbf0bbc5898ecc 100755 (executable)
@@ -1,33 +1,25 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/prepalldocs,v 1.6 2004/10/04 13:56:50 vapier Exp $
 
-z="`find "${ED}"/usr/share/doc \( -type f -or -type l \) -not -name "*.gz" -not -name "*.js" 2>/dev/null`"
+if [[ -n $1 ]] ; then
+       vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
+fi
 
-for y in ${z} ; do
-       if [ -L "${y}" ] ; then
-               # Symlink ...
-               mylink="${y}"
-               linkto="`readlink "${y}"`"
+cd "${ED}"
+[[ -d usr/share/doc ]] || exit 0
 
-               if [ "${linkto##*.}" != "gz" ] ; then
-                       linkto="${linkto}.gz"
-               fi
-               if [ "${mylink##*.}" != "gz" ] ; then
-                       mylink="${mylink}.gz"
-               fi
+# we dont want to compress the html subdir
+if [[ -d ${ED}usr/share/doc/${PF}/html ]] ; then
+       mv "${ED}"usr/share/doc/${PF}/html "${T}"/ecompressdir-html-backup || exit 1
+fi
 
-               echo "fixing doc symlink: ${mylink##*/}"
-               ln -snf "${linkto}" "${mylink}"
-               if [ "${y}" != "${mylink}" ] ; then
-                       echo "removing old symlink: ${y##*/}"
-                       rm -f "${y}"
-               fi
-       else
-               if [ "${y##*.}" != "gz" ] ; then
-                       echo "gzipping doc: ${y##*/}"
-                       gzip -f -9 "${y}"
-               fi
-       fi      
-done
+ecompressdir /usr/share/doc
+ret=$?
+
+if [[ -d ${T}/ecompressdir-html-backup ]] ; then
+       mv "${T}"/html "${ED}"/usr/share/doc/${PF}/html
+fi
+
+exit ${ret}
index 01e022d8e8808e6098d77f2bc7a1b6b14c28832b..f5ec97f42312be910e359dce1bab80d8477c6792 100755 (executable)
@@ -3,7 +3,6 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/prepallinfo,v 1.6 2004/10/04 13:56:50 vapier Exp $
 
-[[ ! -d ${ED}/usr/share/info ]] && exit 0
+[[ ! -d ${ED}usr/share/info ]] && exit 0
 
-echo "info:"
 exec prepinfo
index cfbd076194a6b94b6e405b98f258c21d9572449d..9c59d1c6fd2459f319bc41359cbf4de7dd453d83 100755 (executable)
@@ -1,18 +1,15 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/prepallman,v 1.10 2004/10/04 13:56:50 vapier Exp $
 
 ret=0
 
-echo "man:"
-for x in "${ED}"/opt/*/man "${ED}"/usr/share/man "${ED}"/usr/local/man "${ED}"/usr/X11R6/man ; do
-       if [[ -d ${x} ]] ; then
-               x=${x#${ED}}
-               x=${x%/man}
-               prepman "${x}"
-               ((ret+=$?))
-       fi
-done
+find "${ED}" -type d -name man > "${T}"/prepallman.filelist
+while read mandir ; do
+       mandir=${mandir#${ED}}
+       prepman "${mandir%/man}"
+       ((ret+=$?))
+done < "${T}"/prepallman.filelist
 
 exit ${ret}
index b203eaa5173b818206b2178772b817e095a4c761..9e0ff58ff5c576acb4e8dd7a6759cc85e43c5363 100755 (executable)
@@ -1,45 +1,27 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/prepinfo,v 1.6.2.1 2005/05/29 12:40:08 jstubbs Exp $
 
-if [ -z "$1" ] ; then
-       z="${ED}/usr/share/info"
+if [[ -z $1 ]] ; then
+       infodir="${EPREFIX}/usr/share/info"
 else
-       if [ -d "${ED}$1/share/info" ] ; then
-               z="${ED}$1/share/info"
+       if [[ -d ${ED}$1/share/info ]] ; then
+               infodir="${EPREFIX}$1/share/info"
        else
-               z="${ED}$1/info"
+               infodir="${EPREFIX}$1/info"
        fi
 fi
 
-[ ! -d "${z}" ] && exit 0
-
-rm -f "${z}"/{dir,dir.info,dir.info.gz}
-
-for x in `find "${z}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) 2>/dev/null` ; do
-       if [ -L "${x}" ] ; then
-               # Symlink ...
-               mylink="${x}"
-               linkto="`readlink "${x}"`"
-
-               if [ "${linkto##*.}" != "gz" ] ; then
-                       linkto="${linkto}.gz"
-               fi
-               if [ "${mylink##*.}" != "gz" ] ; then
-                       mylink="${mylink}.gz"
-               fi
-
-               echo "fixing GNU info symlink: ${mylink##*/}"
-               ln -snf "${linkto}" "${mylink}"
-               if [ "${x}" != "${mylink}" ] ; then
-                       echo "removing old symlink: ${x##*/}"
-                       rm -f "${x}"
-               fi
+if [[ ! -d ${ED}${infodir} ]] ; then
+       if [[ -n $1 ]] ; then
+               vecho "${0##*/}: '${infodir}' does not exist!"
+               exit 1
        else
-               if [ "${x##*.}" != "gz" ] ; then
-                       echo "gzipping GNU info page: ${x##*/}"
-                       gzip -f -9 "${x}"
-               fi
+               exit 0
        fi
-done
+fi
+
+rm -f "${ED}${infodir}"/dir{,.info}{,.gz,.bz2}
+
+exec ecompressdir "${infodir}"
index 0ba2bd35bd45c2f3269d05e8009c4bcb342f128d..8588b8d25d0e9191ca0898845540950c7b608889 100755 (executable)
@@ -1,49 +1,28 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/prepman,v 1.10.2.3 2005/05/29 12:40:08 jstubbs Exp $
 
 if [[ -z $1 ]] ; then 
-       z="${ED}/usr/share/man"
+       mandir="${ED}usr/share/man"
 else
-       z="${ED}$1/man"
+       mandir="${ED}$1/man"
 fi
 
-if [[ ! -d ${z} ]] ; then
-       eqawarn "QA Notice: prepman called with non-existent dir '${z#${ED}}'"
+if [[ ! -d ${mandir} ]] ; then
+       eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${ED}}'"
        exit 0
 fi
 
-for x in $(find "${z}"/ -type d 2>/dev/null) ; do
-       for y in $(find "${x}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) ! -name '.keep_*' 2>/dev/null) ; do
-               if [[ -L ${y} ]] ; then
-                       # Symlink ...
-                       mylink=${y}
-                       linkto=$(readlink "${y}")
-                       
-                       # Do NOT change links to directories
-                       if [[ -d ${z}/${linkto} ]] ; then
-                               continue
-                       fi
+shopt -s nullglob
 
-                       if [[ ${linkto##*.} != "gz" ]] && [[ ${linkto##*.} != "bz2" ]] ; then
-                               linkto="${linkto}.gz"
-                       fi
-                       if [[ ${mylink##*.} != "gz" ]] && [[ ${mylink##*.} != "bz2" ]] ; then
-                               mylink="${mylink}.gz"
-                       fi
+ret=0
 
-                       echo "fixing man page symlink: ${mylink##*/}"
-                       ln -snf "${linkto}" "${mylink}"
-                       if [[ ${y} != "${mylink}" ]] ; then
-                               echo "removing old symlink: ${y##*/}"
-                               rm -f "${y}"
-                       fi
-               else
-                       if [[ ${y##*.} != "gz" ]] && [[ ${y##*.} != "bz2" ]] && [[ ! -d ${y} ]] ; then
-                               echo "gzipping man page: ${y##*/}"
-                               gzip -f -9 "${y}"
-                       fi
-               fi      
-       done
+# compress and fixup links in each dir
+for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
+       [[ -d ${subdir} ]] || continue # ignore files named 'man*'
+       ecompressdir "/${subdir#${ED}}"
+       ((ret+=$?))
 done
+
+exit ${ret}
index a7823cac62aa7bdb7cb4e65bde844b8b6eca2661..39351fd62598491ff36fe4e93240634e93a7137b 100644 (file)
@@ -110,6 +110,7 @@ is specified.
 .B EPAUSE_IGNORE
 Defines whether or not to ignore short pauses that occur when displaying
 important informational messages.  This variable is unset by default.
+If it is set to any value pauses are ignored.
 .TP
 \fBFEATURES\fR = \fI"sandbox ccache"\fR
 Defines actions portage takes by default.  These options should
index 7283286ebcec8f3ab40b6a5a0d9c8fb46189cf06..5416f924f1805f5bbd8f765cc303eabf79c71031 100644 (file)
@@ -1888,8 +1888,13 @@ class config:
                myflags = set(myflags)
                myflags.update(self.useforce)
 
+               # FEATURES=test should imply USE=test
+               if "test" in self.configlist[-1].get("FEATURES","").split():
+                       myflags.add("test")
+
                usesplit = [ x for x in myflags if \
                        x not in self.usemask]
+
                usesplit.sort()
 
                # Use the calculated USE flags to regenerate the USE_EXPAND flags so
index c8074bb5530b0f4d8e64bcd2e0cbe70959b83ea3..545884409f46fea2e982a160768d5d7953a83093 100644 (file)
@@ -382,7 +382,7 @@ def isvalidatom(atom, allow_blockers=False):
 
 def isjustname(mypkg):
        """
-       Checks to see if the depstring is only the package name
+       Checks to see if the depstring is only the package name (no version parts)
 
        Example usage:
                >>> isjustname('media-libs/test-3.0')
index 0a9d8d130573d15e53c38efe26282a606cf4a0b6..95e03640d7a7689bd78615a019b78e3a88cf4cfc 100644 (file)
@@ -8,7 +8,7 @@ class PortageException(Exception):
        def __init__(self,value):
                self.value = value[:]
        def __str__(self):
-               if isinstance(self.value, str):
+               if isinstance(self.value, basestring):
                        return self.value
                else:
                        return repr(self.value)
index 34c4d6588710a8e68d900ea9c27cec708153bfa1..374d9061689545ce48ceb5a3dd07458adba2a8f1 100644 (file)
@@ -178,7 +178,27 @@ def stack_lists(lists, incremental=1):
        return new_list.keys()
 
 def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
-       """This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary"""
+       """
+       This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary
+       
+       @param myfilename: file to process
+       @type myfilename: string (path)
+       @param juststrings: only return strings
+       @type juststrings: Boolean (integer)
+       @param empty: Ignore certain lines
+       @type empty: Boolean (integer)
+       @param recursive: Recursively grab ( support for /etc/portage/package.keywords/* and friends )
+       @type recursive: Boolean (integer)
+       @param incremental: Append to the return list, don't overwrite
+       @type incremental: Boolean (integer)
+       @rtype: Dictionary
+       @returns:
+       1.  Returns the lines in a file in a dictionary, for example:
+               'sys-apps/portage x86 amd64 ppc'
+               would return
+               { "sys-apps/portage" : [ 'x86', 'amd64', 'ppc' ]
+               the line syntax is key : [list of values]
+       """
        newdict={}
        for x in grablines(myfilename, recursive):
                #the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
@@ -229,7 +249,7 @@ def grablines(myfilename,recursive=0):
        mylines=[]
        if recursive and os.path.isdir(myfilename):
                if myfilename in ["RCS", "CVS", "SCCS"]:
-                       continue
+                       return mylines
                dirlist = os.listdir(myfilename)
                dirlist.sort()
                for f in dirlist:
diff --git a/tests/portage_dep/test_dep_getcpv.py b/tests/portage_dep/test_dep_getcpv.py
new file mode 100644 (file)
index 0000000..6928794
--- /dev/null
@@ -0,0 +1,25 @@
+# test_dep_getcpv.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+
+from unittest import TestCase
+from portage_dep import dep_getcpv
+
+class DepGetCPV(TestCase):
+        """ A simple testcase for isvalidatom
+        """
+
+        def testDepGetCPV(self):
+               
+               prefix_ops = ["<", ">", "=", "~", "!", "<=", 
+                             ">=", "!=", "!<", "!>", "!~",""]
+               postfix_ops = [ "*", "" ]
+
+               cpvs = ["sys-apps/portage"]
+
+               for cpv in cpvs:
+                       for prefix in prefix_ops:
+                               for postfix in postfix_ops:
+                                       self.assertEqual( dep_getcpv( 
+                                               prefix + cpv + postfix ), cpv )
diff --git a/tests/portage_dep/test_dep_getslot.py b/tests/portage_dep/test_dep_getslot.py
new file mode 100644 (file)
index 0000000..5e18d7c
--- /dev/null
@@ -0,0 +1,27 @@
+# test_dep_getslot.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+
+from unittest import TestCase
+from portage_dep import dep_getslot
+
+class DepGetSlot(TestCase):
+        """ A simple testcase for isvalidatom
+        """
+
+        def testDepGetSlot(self):
+               
+               slot_char = ":"
+               slots = ( "a", "1.2", "1", "IloveVapier", None )
+               cpvs = ["sys-apps/portage"]
+
+               for cpv in cpvs:
+                       for slot in slots:
+                               if slot:
+                                       self.assertEqual( dep_getslot( 
+                                                cpv + slot_char + slot ), slot )
+                               else:
+                                       self.assertEqual( dep_getslot( cpv ), slot )
+
+               self.assertEqual( dep_getslot( "sys-apps/portage:"), "" )
diff --git a/tests/portage_dep/test_get_operator.py b/tests/portage_dep/test_get_operator.py
new file mode 100644 (file)
index 0000000..ec052d9
--- /dev/null
@@ -0,0 +1,26 @@
+# test_match_from_list.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+
+from unittest import TestCase
+from portage_dep import get_operator
+
+class GetOperator(TestCase):
+
+       def testGetOperator(self):
+
+               # get_operator does not validate operators
+               tests = [ ( "~", "~" ), ( "=", "=" ), ( ">", ">" ),
+                         ( ">=", ">=" ), ( "<=", "<=" ) , ( "", None ),
+                         ( ">~", ">" ), ("~<", "~"), ( "=~", "=" ),
+                         ( "=>", "=" ), ("=<", "=") ]
+
+               testCP = "sys-apps/portage"
+
+               for test in tests:
+                       result = get_operator( test[0] + testCP )
+                       self.assertEqual( result, test[1] )
+
+               result = get_operator( "=sys-apps/portage*" )
+               self.assertEqual( result , "=*" )
diff --git a/tests/portage_dep/test_isjustname.py b/tests/portage_dep/test_isjustname.py
new file mode 100644 (file)
index 0000000..a8a4e24
--- /dev/null
@@ -0,0 +1,25 @@
+# test_isjustname.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+
+from unittest import TestCase
+from portage_dep import isjustname
+
+class IsJustName(TestCase):
+
+        def testIsJustName(self):
+
+               cats = ( "", "sys-apps/", "foo/", "virtual/" )
+               pkgs = ( "portage", "paludis", "pkgcore", "notARealPkg" )
+               vers = ( "", "-2.0-r3", "-1.0_pre2", "-3.1b" )
+
+               for pkg in pkgs:
+                       for cat in cats:
+                               for ver in vers:
+                                       if len(ver):
+                                               self.assertFalse( isjustname( cat + pkg + ver ),
+                                               msg="isjustname(%s) is True!" % (cat + pkg + ver) )
+                                       else:
+                                               self.assertTrue( isjustname( cat + pkg + ver ),
+                                               msg="isjustname(%s) is False!" % (cat + pkg + ver) )
diff --git a/tests/portage_dep/test_isvalidatom.py b/tests/portage_dep/test_isvalidatom.py
new file mode 100644 (file)
index 0000000..84225fa
--- /dev/null
@@ -0,0 +1,36 @@
+# test_isvalidatom.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+
+from unittest import TestCase
+from portage_dep import isvalidatom
+
+class IsValidAtom(TestCase):
+        """ A simple testcase for isvalidatom
+        """
+
+        def testIsValidAtom(self):
+               
+               tests = [ ( "sys-apps/portage", True ),
+                         ( "=sys-apps/portage-2.1", True ),
+                         ( "=sys-apps/portage-2.1*", True ),
+                         ( ">=sys-apps/portage-2.1", True ),
+                         ( "<=sys-apps/portage-2.1", True ),
+                         ( ">sys-apps/portage-2.1", True ),
+                         ( "<sys-apps/portage-2.1", True ),
+                         ( "~sys-apps/portage-2.1", True ),
+                         ( ">~cate-gory/foo-1.0", False ),
+                         ( ">~category/foo-1.0", False ),
+                         ( "<~category/foo-1.0", False ),
+                         ( "###cat/foo-1.0", False ),
+                         ( "~sys-apps/portage", False ),
+                         ( "portage", False ) ]
+
+               for test in tests:
+                       if test[1]:
+                               atom_type = "valid"
+                       else:
+                               atom_type = "invalid"
+
+                       self.assertEqual( bool(isvalidatom( test[0] )), test[1] )
index 7afe51c5effed5e9eaa1a4ca4653d88689713f38..4526d4e312677a87981aae691d2fd08bd288231a 100644 (file)
@@ -19,15 +19,13 @@ class AtomCmpEqualGlob(TestCase):
 #                         ("=sys-fs/udev_cvs*","sys-fs/udev_cvs_pre4" ) ]
 
                 for test in tests:
-                        self.failIf( len(match_from_list( test[0], [test[1]] )) != 1,
-                                msg="%s should match %s!" % (test[0], test[1]) )
+                        self.assertEqual( len(match_from_list( test[0], [test[1]] )), 1 )
 
         def testEqualGlobFail(self):
                 tests = [ ("=sys-apps/portage-2*", "sys-apps/portage-2.1" ),
                           ("=sys-apps/portage-2.1*", "sys-apps/portage-2.1.2" ) ]
                 for test in tests:
                         try:
-                                self.failIf( len( match_from_list( test[0], [test[1]] ) ) != 1,
-                                        msg="%s shouldn't match %s!" % (test[0], test[1]) )
+                                self.assertEqual( len( match_from_list( test[0], [test[1]] ) ), 1 )
                         except TypeError: # failure is ok here
                                 pass
diff --git a/tests/portage_util/test_grabdict.py b/tests/portage_util/test_grabdict.py
new file mode 100644 (file)
index 0000000..74b28ca
--- /dev/null
@@ -0,0 +1,12 @@
+# test_grabDict.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+
+from unittest import TestCase, TestLoader
+from portage_util import grabdict
+
+class GrabDictTestCase(TestCase):
+       
+       def testGrabDictPass(self):
+               pass
index 9f9a60597362de7a758b6f4b6bf77c4257d957fb..3354e254e9f41b5f1eef7f6157e65e94ae6866ea 100644 (file)
@@ -12,5 +12,4 @@ class NormalizePathTestCase(TestCase):
                from portage_util import normalize_path
                path = "///foo/bar/baz"
                good = "/foo/bar/baz"
-               self.failUnless(normalize_path(path) == good, msg="NormalizePath(%s) failed to produce %s" % (path, good))
-
+               self.assertEqual(normalize_path(path), good)
index e6442ce43a60b85aac681c4743de685f1a12de24..02284e8f4400ad5c5ca2f73d02fe98293177e432 100644 (file)
@@ -14,6 +14,5 @@ class StackDictListTestCase(TestCase):
                tests.append(( {'KEYWORDS':['alpha','x86']},{'KEYWORDS':['-*']},True,{} ))
                tests.append(( {'KEYWORDS':['alpha','x86']},{'KEYWORDS':['-x86']},True,{'KEYWORDS':['alpha']} ))
                for test in tests:
-                       self.failUnless(stack_dictlist([test[0],test[1]],incremental=test[2]) == test[3],
-                               msg="%s and %s combined, was expecting: %s and got: %s" % (test[0],test[1],test[3],
-                               stack_dictlist([test[0],test[1]],incremental=test[2])) )
+                       self.assertEqual(
+                       stack_dictlist([test[0],test[1]],incremental=test[2]), test[3] )
index ac0e67ef81f6ca4861d62a9b79ca7860d09e1375..98467b5a56a4d7b517f32c45471c8d72ee0452cf 100644 (file)
@@ -25,8 +25,7 @@ class StackDictsTestCase(TestCase):
 
                for test in tests:
                        result = stack_dicts( test[0], test[2], test[3], test[4] )
-                       self.failIf( result != test[1], msg="Expected %s = %s" \
-                               % ( result, test[1] ) )
+                       self.assertEqual( result, test[1] )
        
        def testStackDictsFail(self):
                
@@ -35,5 +34,4 @@ class StackDictsTestCase(TestCase):
                                False, [], False ) ]
                for test in tests:
                        result = stack_dicts( test[0], test[2], test[3], test[4] )
-                       self.failIf( result == test[1], msg="Expected %s != %s, got \
-                               %s == %s!" % (result, test[1], result, test[1]) )
+                       self.assertNotEqual( result , test[1] )
index c691392865859e6915540669b38e2364b4d3d726..c4e1e005627bdb81ec0cc569e44381a73bd0d45c 100644 (file)
@@ -17,6 +17,4 @@ class StackListsTestCase(TestCase):
 
                for test in tests:
                        result = stack_lists( test[0], test[2] )
-                       self.failIf( result != test[1],
-                               msg="Got %s != %s from stack_lists( %s, %s )" \
-                               % ( result, test[1], test[0], test[2] ) )
+                       self.assertEqual( result , test[1] )