* fix archivetests
This commit is contained in:
@@ -297,7 +297,8 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
|
|
||||||
# generate top-level helper functions
|
# generate top-level helper functions
|
||||||
cls.initializers = inits
|
cls.initializers = inits
|
||||||
def initialize(self, **args):
|
def initialize(self, uri = None, keepDoc = False, tmpDir = '/tmp',
|
||||||
|
**args):
|
||||||
if xmlfile_support:
|
if xmlfile_support:
|
||||||
# totally dailywtf
|
# totally dailywtf
|
||||||
#if args.has_key('tag'):
|
#if args.has_key('tag'):
|
||||||
@@ -317,6 +318,8 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
# init hook
|
# init hook
|
||||||
if hasattr(self, 'init'):
|
if hasattr(self, 'init'):
|
||||||
self.init(tag)
|
self.init(tag)
|
||||||
|
if uri:
|
||||||
|
self.read(uri, keepDoc, tmpDir)
|
||||||
|
|
||||||
cls.__init__ = initialize
|
cls.__init__ = initialize
|
||||||
|
|
||||||
|
|||||||
+21
-20
@@ -19,7 +19,8 @@ from pisi import archive
|
|||||||
from pisi import sourcearchive
|
from pisi import sourcearchive
|
||||||
from pisi import fetcher
|
from pisi import fetcher
|
||||||
from pisi import util
|
from pisi import util
|
||||||
from pisi.build import BuildContext
|
#from pisi.build import BuildContext
|
||||||
|
from pisi.specfile import SpecFile
|
||||||
from pisi import uri
|
from pisi import uri
|
||||||
|
|
||||||
import testcase
|
import testcase
|
||||||
@@ -27,11 +28,11 @@ import testcase
|
|||||||
class ArchiveFileTestCase(testcase.TestCase):
|
class ArchiveFileTestCase(testcase.TestCase):
|
||||||
|
|
||||||
def testUnpackTar(self):
|
def testUnpackTar(self):
|
||||||
bctx = BuildContext("tests/popt/pspec.xml")
|
spec = SpecFile("tests/popt/pspec.xml")
|
||||||
|
targetDir = '/tmp/pisitest'
|
||||||
achv = sourcearchive.SourceArchive(bctx)
|
achv = sourcearchive.SourceArchive(spec, targetDir)
|
||||||
|
|
||||||
assert bctx.spec.source.archive.type == "targz"
|
assert spec.source.archive.type == "targz"
|
||||||
|
|
||||||
# skip fetching and directly unpack the previously fetched (by
|
# skip fetching and directly unpack the previously fetched (by
|
||||||
# fetchertests) archive
|
# fetchertests) archive
|
||||||
@@ -39,7 +40,6 @@ class ArchiveFileTestCase(testcase.TestCase):
|
|||||||
achv.fetch(interactive=False)
|
achv.fetch(interactive=False)
|
||||||
achv.unpack()
|
achv.unpack()
|
||||||
|
|
||||||
targetDir = bctx.pkg_work_dir()
|
|
||||||
# but testing is hard
|
# but testing is hard
|
||||||
# "var/tmp/pisi/popt-1.7-3/work" (targetDir)
|
# "var/tmp/pisi/popt-1.7-3/work" (targetDir)
|
||||||
assert pathexists(targetDir + "/popt-1.7")
|
assert pathexists(targetDir + "/popt-1.7")
|
||||||
@@ -52,15 +52,15 @@ class ArchiveFileTestCase(testcase.TestCase):
|
|||||||
"5af9dd7d754f788cf511c57ce0af3d555fed009d")
|
"5af9dd7d754f788cf511c57ce0af3d555fed009d")
|
||||||
|
|
||||||
def testUnpackZip(self):
|
def testUnpackZip(self):
|
||||||
bctx = BuildContext("tests/pccts/pspec.xml")
|
spec = SpecFile("tests/pccts/pspec.xml")
|
||||||
|
targetDir = '/tmp/pisitest'
|
||||||
|
|
||||||
assert bctx.spec.source.archive.type == "zip"
|
assert spec.source.archive.type == "zip"
|
||||||
|
|
||||||
achv = sourcearchive.SourceArchive(bctx)
|
achv = sourcearchive.SourceArchive(spec, targetDir)
|
||||||
achv.fetch(interactive=False)
|
achv.fetch(interactive=False)
|
||||||
achv.unpack(clean_dir=True)
|
achv.unpack(clean_dir=True)
|
||||||
|
|
||||||
targetDir = bctx.pkg_work_dir()
|
|
||||||
assert pathexists(targetDir + "/pccts")
|
assert pathexists(targetDir + "/pccts")
|
||||||
|
|
||||||
testfile = targetDir + "/pccts/history.txt"
|
testfile = targetDir + "/pccts/history.txt"
|
||||||
@@ -78,9 +78,9 @@ class ArchiveFileTestCase(testcase.TestCase):
|
|||||||
|
|
||||||
def testMakeZip(self):
|
def testMakeZip(self):
|
||||||
# first unpack our dear sandbox.zip
|
# first unpack our dear sandbox.zip
|
||||||
bctx = BuildContext("tests/pccts/pspec.xml")
|
spec = SpecFile("tests/pccts/pspec.xml")
|
||||||
targetDir = bctx.pkg_work_dir()
|
targetDir = '/tmp/pisitest'
|
||||||
achv = sourcearchive.SourceArchive(bctx)
|
achv = sourcearchive.SourceArchive(spec, targetDir)
|
||||||
achv.fetch(interactive=False)
|
achv.fetch(interactive=False)
|
||||||
achv.unpack(clean_dir=True)
|
achv.unpack(clean_dir=True)
|
||||||
del achv
|
del achv
|
||||||
@@ -94,18 +94,19 @@ class ArchiveFileTestCase(testcase.TestCase):
|
|||||||
#TODO: do some more work to test the integrity of new zip file
|
#TODO: do some more work to test the integrity of new zip file
|
||||||
|
|
||||||
def testUnpackZipCond(self):
|
def testUnpackZipCond(self):
|
||||||
bctx = BuildContext("tests/pccts/pspec.xml")
|
spec = SpecFile("tests/pccts/pspec.xml")
|
||||||
url = uri.URI(bctx.spec.source.archive.uri)
|
targetDir = '/tmp'
|
||||||
targetDir = bctx.pkg_work_dir()
|
achv = sourcearchive.SourceArchive(spec, targetDir)
|
||||||
|
url = uri.URI(spec.source.archive.uri)
|
||||||
filePath = join(ctx.config.archives_dir(), url.filename())
|
filePath = join(ctx.config.archives_dir(), url.filename())
|
||||||
|
|
||||||
# check cached
|
# check cached
|
||||||
if util.sha1_file(filePath) != bctx.spec.source.archive.sha1sum:
|
if util.sha1_file(filePath) != spec.source.archive.sha1sum:
|
||||||
fetch = fetcher.Fetcher(bctx.spec.source.archive.uri, targetDir)
|
fetch = fetcher.Fetcher(spec.source.archive.uri, targetDir)
|
||||||
fetch.fetch()
|
fetch.fetch()
|
||||||
assert bctx.spec.source.archive.type == "zip"
|
assert spec.source.archive.type == "zip"
|
||||||
|
|
||||||
achv = archive.Archive(filePath, bctx.spec.source.archive.type)
|
achv = archive.Archive(filePath, spec.source.archive.type)
|
||||||
achv.unpack_files(["pccts/history.txt"], targetDir)
|
achv.unpack_files(["pccts/history.txt"], targetDir)
|
||||||
assert pathexists(targetDir + "/pccts")
|
assert pathexists(targetDir + "/pccts")
|
||||||
testfile = targetDir + "/pccts/history.txt"
|
testfile = targetDir + "/pccts/history.txt"
|
||||||
|
|||||||
Reference in New Issue
Block a user