Kaydet (Commit) 8a4a47ac authored tarafından Eray Özkural's avatar Eray Özkural

* distinguish String and Text types for autoxml

* start working on specfilenew again
* make test suite smarter. by definition of a test suite, they can be
run out of order.
* change the behavior of first running and then reporting all errors. 
 now we see where the error belongs to clearly. better in the cases 
 with several errors.
üst d0a2d7a2
......@@ -35,12 +35,10 @@ _ = __trans.ugettext
import pisi
from pisi.xmlext import *
from pisi.xmlfile import XmlFile
import pisi.xmlfile as xmlfile
from pisi.dependency import DepInfo
from pisi.util import Checks
#class Packager:
# __metaclass__ = xmlfile.autoxml
class PackagerInfo:
def __init__(self, node = None):
if node:
......
......@@ -33,12 +33,12 @@ __metaclass__ = xmlfile.autoxml
class Packager:
t_Name = [types.StringType, xmlfile.mandatory]
t_Email = [types.StringType, xmlfile.mandatory]
t_Name = [xmlfile.String, xmlfile.mandatory]
t_Email = [xmlfile.String, xmlfile.mandatory]
def __str__(self):
s = "%s <%s>" % (self.name, self.email)
return s
class AdditionalFileInfo:
s_Filename = xmlfile.mandatory
......
......@@ -51,11 +51,14 @@ import pisi.util as util
class Error(pisi.Error):
pass
# requirement specs
mandatory, optional = range(2) # poor man's enum
# basic types
Text = types.StringType
String = types.StringType
Text = types.UnicodeType
Integer = types.IntType
#class datatype(type):
......@@ -602,6 +605,7 @@ class autoxml(type):
basic_cons_map = {
types.StringType : str,
types.UnicodeType : unicode,
types.IntType : int
}
......
......@@ -18,58 +18,33 @@ import locale
sys.path.append('.')
sys.path.append('..')
runTestSuite = lambda(x): unittest.TextTestRunner(verbosity=2).run(x)
def run_test_suite(testsuite):
unittest.TextTestRunner(verbosity=2).run(testsuite)
def run_all():
import utiltests
import xmlfiletests
import specfiletests
import metadatatests
import constantstests
import fetchertests
import archivetests
import installdbtests
import sourcedbtests
import packagedbtests
import actionsapitests
import graphtests
import versiontests
import configfiletests
import packagetests
import dependency
print '** Running all tests'
#testsuite = unittest.TestSuite()
for root, dirs, files in os.walk('tests'):
testsources = filter(lambda x:x.endswith('tests.py'), files)
for testsource in testsources:
module = __import__(testsource[:len(testsource)-3])
#testsuite.add(module.suite)
print '\n* Running tests in', testsource
run_test_suite(module.suite)
alltests = unittest.TestSuite((
utiltests.suite,
xmlfiletests.suite,
specfiletests.suite,
metadatatests.suite,
constantstests.suite,
fetchertests.suite,
archivetests.suite,
installdbtests.suite,
sourcedbtests.suite,
packagedbtests.suite,
# FIXME: actionsapitests requires tester to run a specific command first.
# actionsapitests.suite,
graphtests.suite,
versiontests.suite,
configfiletests.suite,
packagetests.suite,
dependencytests.suite
))
runTestSuite(alltests)
#run_test_suite(unittest.TestSuite(tests))
if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '')
args = sys.argv
if len(args) > 1: # run modules given from the command line
tests = sys.argv[1:]
for test in tests:
module = __import__(test + 'tests')
print "\nRunning tests in '%s'...\n" % (test)
runTestSuite(module.suite)
test += 'tests'
module = __import__(test)
print "* Running tests in '%s'" % (test)
run_test_suite(module.suite)
else: # run all tests
print "\nRunning all tests in order...\n"
run_all()
# Copyright (C) 2005, TUBITAK/UEKAE
#
# 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.
#
# Please read the COPYING file.
#
import unittest
import os
from pisi import specfile
from pisi.config import config
import pisi.util as util
class SpecFileTestCase(unittest.TestCase):
def setUp(self):
self.spec = specfile.SpecFile()
self.spec.read("tests/popt/pspec.xml")
def testReadSpec(self):
self.assertEqual(self.spec.source.name, "popt")
self.assertEqual(self.spec.source.version, "1.7")
self.assertEqual(self.spec.source.release, "3")
self.assertEqual(self.spec.source.archiveSHA1,
"66f3c77b87a160951b180447f4a6dce68ad2f71b")
patches = self.spec.source.patches
self.assertEqual(len(patches), 1)
patch = patches[0] #get first and the only patch
self.assertEqual(patch.filename, "popt-1.7-uclibc.patch.gz")
self.assertEqual(patch.compressionType, "gz")
packages = self.spec.packages
self.assertEqual(len(packages), 1)
package = packages[0] # get the first and the only package
self.assertEqual(package.name, "popt-libs")
# search for a path in package.paths
pn = "/usr/lib"
matched = [p for p in package.paths if p.pathname == pn]
if not matched:
self.fail("Failed to match pathname: %s" %pn)
def testIsAPartOf(self):
# test existence in Source
if not "library:util:optparser" in self.spec.source.isa:
self.fail("Failed to match IsA in Source")
if not isinstance(self.spec.source.isa, list):
self.fail("source.isa is not a list, but it must be...")
if "rpm:archive" != self.spec.source.partof:
self.fail("Failed to match PartOf in Source")
# test existence in Package
pkg = self.spec.packages[0]
if not "library:util:optparser" in pkg.isa:
self.fail("Failed to match IsA in Package")
if not isinstance(pkg.isa, list):
self.fail("source.isa is not a list, but it must be...")
if "rpm:archive" != pkg.partof:
self.fail("Failed to match PartOf in Package")
def testVerify(self):
if self.spec.has_errors():
self.fail("Failed to verify specfile")
def testCopy(self):
util.check_dir(config.tmp_dir())
self.spec.read("tests/popt/pspec.xml")
self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec.xml'))
suite = unittest.makeSuite(SpecFileTestCase)
......@@ -32,3 +32,4 @@ class UtilTestCase(unittest.TestCase):
suite = unittest.makeSuite(UtilTestCase)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment