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

* 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
 
üst d54105a1
......@@ -637,39 +637,33 @@ class Builder:
def calc_build_no(self, package_name):
"""Calculate build number"""
# find previous build in packages dir
found = []
def locate_package_names(files):
for fn in files:
#print 'looking', fn
if util.is_package_name(fn, package_name):
old_package_fn = util.join_path(root, fn)
try:
old_pkg = Package(old_package_fn, 'r')
old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
ctx.ui.info(_('(found old version %s)') % old_package_fn)
if str(old_pkg.metadata.package.name) != package_name:
ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
old_package_fn)
continue
old_build = old_pkg.metadata.package.build
found.append( (old_package_fn, old_build) )
except:
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
continue
def locate_old_package(old_package_fn):
if util.is_package_name(os.path.basename(old_package_fn), package_name):
try:
old_pkg = Package(old_package_fn, 'r')
old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
ctx.ui.info(_('(found old version %s)') % old_package_fn)
if str(old_pkg.metadata.package.name) != package_name:
ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
old_package_fn)
return
old_build = old_pkg.metadata.package.build
found.append( (old_package_fn, old_build) )
except:
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
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')
if not outdir:
outdir = '.'
files = [join(outdir,entry) for entry in os.listdir(outdir)
if os.path.isfile(entry)]
#print os.listdir(outdir)
#print files
locate_package_names(files)
for file in [join(outdir,entry) for entry in os.listdir(outdir)]:
if os.path.isfile(file):
locate_old_package(file)
if not found:
return (1, None)
......
......@@ -11,14 +11,23 @@
import unittest
import shutil
import glob
import os
import testcase
from pisi.build import *
class BuildTestCase(testcase.TestCase):
def cleanOutput(self):
for x in glob.glob('tmp/a*.pisi'):
os.unlink(x)
def setUp(self):
options = pisi.config.Options()
options.ignore_build_no = False
options.output_dir = 'tmp'
self.cleanOutput()
testcase.TestCase.setUp(self, options = options)
pisi.context.config.values.build.buildno = True
......@@ -27,23 +36,23 @@ class BuildTestCase(testcase.TestCase):
pspec = 'tests/buildtests/a/pspec.xml'
pb = Builder(pspec, None)
pb.build()
self.assertEqual(os.path.exists('a-1.0-1-1.pisi'), True)
shutil.move('a-1.0-1-1.pisi', 'tests/buildtests/a/a-1.0-1-1.pisi')
self.assert_(os.path.exists('tmp/a-1.0-1-1.pisi'))
def testBuildNumber(self):
self.cleanOutput()
self.testBasicBuild()
pspec = 'tests/buildtests/a/pspec.xml'
pb = Builder(pspec, None)
shutil.copy('tests/buildtests/a/actions.py-2', 'tests/buildtests/a/actions.py')
pb = Builder(pspec, None)
pb.build()
self.assertEqual(os.path.exists('a-1.0-1-2.pisi'), True)
shutil.copy('tests/buildtests/a/actions.py-3', 'tests/buildtests/a/actions.py')
self.assert_(os.path.exists('tmp/a-1.0-1-2.pisi'))
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('a-1.0-1-2.pisi')
os.remove('tests/buildtests/a/a-1.0-1-1.pisi')
os.remove('tmp/a-1.0-1-2.pisi')
suite = unittest.makeSuite(BuildTestCase)
#!/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")
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