* fix and improve build test:
- use 'tmp' as output dir in build test - also test the case where build no does not increment - do not assume that another case ran first - clean output packages first * fix: check output dir, non-recursively, and correctly
This commit is contained in:
+19
-25
@@ -637,39 +637,33 @@ class Builder:
|
|||||||
|
|
||||||
def calc_build_no(self, package_name):
|
def calc_build_no(self, package_name):
|
||||||
"""Calculate build number"""
|
"""Calculate build number"""
|
||||||
|
|
||||||
# find previous build in packages dir
|
# find previous build in packages dir
|
||||||
found = []
|
found = []
|
||||||
def locate_package_names(files):
|
def locate_old_package(old_package_fn):
|
||||||
for fn in files:
|
if util.is_package_name(os.path.basename(old_package_fn), package_name):
|
||||||
#print 'looking', fn
|
try:
|
||||||
if util.is_package_name(fn, package_name):
|
old_pkg = Package(old_package_fn, 'r')
|
||||||
old_package_fn = util.join_path(root, fn)
|
old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
|
||||||
try:
|
ctx.ui.info(_('(found old version %s)') % old_package_fn)
|
||||||
old_pkg = Package(old_package_fn, 'r')
|
if str(old_pkg.metadata.package.name) != package_name:
|
||||||
old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
|
ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
|
||||||
ctx.ui.info(_('(found old version %s)') % old_package_fn)
|
old_package_fn)
|
||||||
if str(old_pkg.metadata.package.name) != package_name:
|
return
|
||||||
ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
|
old_build = old_pkg.metadata.package.build
|
||||||
old_package_fn)
|
found.append( (old_package_fn, old_build) )
|
||||||
continue
|
except:
|
||||||
old_build = old_pkg.metadata.package.build
|
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
|
||||||
found.append( (old_package_fn, old_build) )
|
|
||||||
except:
|
|
||||||
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
|
|
||||||
continue
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(ctx.config.packages_dir()):
|
for root, dirs, files in os.walk(ctx.config.packages_dir()):
|
||||||
locate_package_names(files)
|
for file in files:
|
||||||
|
locate_old_package(join(root,file))
|
||||||
|
|
||||||
outdir=ctx.get_option('output_dir')
|
outdir=ctx.get_option('output_dir')
|
||||||
if not outdir:
|
if not outdir:
|
||||||
outdir = '.'
|
outdir = '.'
|
||||||
files = [join(outdir,entry) for entry in os.listdir(outdir)
|
for file in [join(outdir,entry) for entry in os.listdir(outdir)]:
|
||||||
if os.path.isfile(entry)]
|
if os.path.isfile(file):
|
||||||
#print os.listdir(outdir)
|
locate_old_package(file)
|
||||||
#print files
|
|
||||||
locate_package_names(files)
|
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
return (1, None)
|
return (1, None)
|
||||||
|
|||||||
+20
-11
@@ -11,14 +11,23 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import shutil
|
import shutil
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
import testcase
|
import testcase
|
||||||
from pisi.build import *
|
from pisi.build import *
|
||||||
|
|
||||||
class BuildTestCase(testcase.TestCase):
|
class BuildTestCase(testcase.TestCase):
|
||||||
|
|
||||||
|
def cleanOutput(self):
|
||||||
|
for x in glob.glob('tmp/a*.pisi'):
|
||||||
|
os.unlink(x)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
options = pisi.config.Options()
|
options = pisi.config.Options()
|
||||||
options.ignore_build_no = False
|
options.ignore_build_no = False
|
||||||
|
options.output_dir = 'tmp'
|
||||||
|
self.cleanOutput()
|
||||||
testcase.TestCase.setUp(self, options = options)
|
testcase.TestCase.setUp(self, options = options)
|
||||||
pisi.context.config.values.build.buildno = True
|
pisi.context.config.values.build.buildno = True
|
||||||
|
|
||||||
@@ -27,23 +36,23 @@ class BuildTestCase(testcase.TestCase):
|
|||||||
pspec = 'tests/buildtests/a/pspec.xml'
|
pspec = 'tests/buildtests/a/pspec.xml'
|
||||||
pb = Builder(pspec, None)
|
pb = Builder(pspec, None)
|
||||||
pb.build()
|
pb.build()
|
||||||
self.assertEqual(os.path.exists('a-1.0-1-1.pisi'), True)
|
self.assert_(os.path.exists('tmp/a-1.0-1-1.pisi'))
|
||||||
shutil.move('a-1.0-1-1.pisi', 'tests/buildtests/a/a-1.0-1-1.pisi')
|
|
||||||
|
|
||||||
def testBuildNumber(self):
|
def testBuildNumber(self):
|
||||||
|
self.cleanOutput()
|
||||||
|
self.testBasicBuild()
|
||||||
|
|
||||||
pspec = 'tests/buildtests/a/pspec.xml'
|
pspec = 'tests/buildtests/a/pspec.xml'
|
||||||
pb = Builder(pspec, None)
|
|
||||||
|
|
||||||
shutil.copy('tests/buildtests/a/actions.py-2', 'tests/buildtests/a/actions.py')
|
shutil.copy('tests/buildtests/a/actions.py-2', 'tests/buildtests/a/actions.py')
|
||||||
|
pb = Builder(pspec, None)
|
||||||
pb.build()
|
pb.build()
|
||||||
self.assertEqual(os.path.exists('a-1.0-1-2.pisi'), True)
|
self.assert_(os.path.exists('tmp/a-1.0-1-2.pisi'))
|
||||||
|
|
||||||
shutil.copy('tests/buildtests/a/actions.py-3', 'tests/buildtests/a/actions.py')
|
|
||||||
pb.build()
|
pb.build()
|
||||||
self.assertEqual(os.path.exists('a-1.0-1-3.pisi'), False)
|
# because nothing is changed
|
||||||
|
self.assert_(not os.path.exists('tmp/a-1.0-1-3.pisi'))
|
||||||
|
|
||||||
os.remove('tests/buildtests/a/actions.py')
|
os.remove('tests/buildtests/a/actions.py')
|
||||||
os.remove('a-1.0-1-2.pisi')
|
os.remove('tmp/a-1.0-1-2.pisi')
|
||||||
os.remove('tests/buildtests/a/a-1.0-1-1.pisi')
|
|
||||||
|
|
||||||
suite = unittest.makeSuite(BuildTestCase)
|
suite = unittest.makeSuite(BuildTestCase)
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright 2005 TUBITAK/UEKAE
|
|
||||||
# Licensed under the GNU General Public License, version 2.
|
|
||||||
# See the file http://www.gnu.org/copyleft/gpl.txt.
|
|
||||||
#
|
|
||||||
# A. Murat Eren <meren at uludag.org.tr>
|
|
||||||
|
|
||||||
from pisi.actionsapi import pisitools
|
|
||||||
|
|
||||||
WorkDir = "merhaba-pisi-1.0"
|
|
||||||
|
|
||||||
def install():
|
|
||||||
pisitools.dobin("merhaba-pisi.py")
|
|
||||||
|
|
||||||
pisitools.rename("/usr/bin/merhaba-pisi.py", "merhaba-pisi")
|
|
||||||
|
|
||||||
pisitools.dosym("./merhaba-pisi", "/usr/bin/justasysmlink")
|
|
||||||
pisitools.dosym("/thre/is/no/such", "/usr/bin/justabrokensymlink")
|
|
||||||
|
|
||||||
pisitools.dodir("/usr/lib")
|
|
||||||
Reference in New Issue
Block a user