jhbuild r1854 - in trunk: . jhbuild/modtypes tests
- From: fpeters svn gnome org
- To: svn-commits-list gnome org
- Subject: jhbuild r1854 - in trunk: . jhbuild/modtypes tests
- Date: Sat, 19 Jan 2008 16:32:29 +0000 (GMT)
Author: fpeters
Date: Sat Jan 19 16:32:29 2008
New Revision: 1854
URL: http://svn.gnome.org/viewvc/jhbuild?rev=1854&view=rev
Log:
* jhbuild/modtypes/__init__.py, jhbuild/modtypes/autotools.py,
jhbuild/modtypes/cmake.py, jhbuild/modtypes/distutils.py,
jhbuild/modtypes/linux.py, jhbuild/modtypes/mesa.py,
jhbuild/modtypes/mozillamodule.py, jhbuild/modtypes/perl.py,
jhbuild/modtypes/testmodule.py, jhbuild/modtypes/waf.py, tests/mock.py,
tests/tests.py: updated test module type to the new (but not recent)
system of method attributes to get next and error states (and killed
old code); appropriately skip modules according to build policy when
running with nonetwork set. (closes: #508653)
Modified:
trunk/ChangeLog
trunk/jhbuild/modtypes/__init__.py
trunk/jhbuild/modtypes/autotools.py
trunk/jhbuild/modtypes/cmake.py
trunk/jhbuild/modtypes/distutils.py
trunk/jhbuild/modtypes/linux.py
trunk/jhbuild/modtypes/mesa.py
trunk/jhbuild/modtypes/mozillamodule.py
trunk/jhbuild/modtypes/perl.py
trunk/jhbuild/modtypes/testmodule.py
trunk/jhbuild/modtypes/waf.py
trunk/tests/mock.py
trunk/tests/tests.py
Modified: trunk/jhbuild/modtypes/__init__.py
==============================================================================
--- trunk/jhbuild/modtypes/__init__.py (original)
+++ trunk/jhbuild/modtypes/__init__.py Sat Jan 19 16:32:29 2008
@@ -101,37 +101,6 @@
return repo.branch_from_xml(name, childnode, repositories, default_repo)
-def checkout(package, buildscript):
- srcdir = package.get_srcdir(buildscript)
- builddir = package.get_builddir(buildscript)
- buildscript.set_action('Checking out', package)
- package.branch.checkout(buildscript)
- # did the checkout succeed?
- if not os.path.exists(srcdir):
- raise BuildStateError('source directory %s was not created'
- % srcdir)
-
-def check_build_policy(package, buildscript):
- if buildscript.config.force_policy:
- return
- if buildscript.config.build_policy in ('updated', 'updated-deps'):
- # has this module been updated ?
- if buildscript.packagedb.check(package.name, package.get_revision() or ''):
- # module has not been updated
- if buildscript.config.build_policy == 'updated':
- buildscript.message('Skipping %s (not updated)' % package.name)
- raise SkipToState(Package.STATE_DONE)
- elif buildscript.config.build_policy == 'updated-deps':
- install_date = buildscript.packagedb.installdate(package.name)
- for dep in package.dependencies:
- install_date_dep = buildscript.packagedb.installdate(dep)
- if install_date_dep > install_date:
- break
- else:
- buildscript.message(
- 'Skipping %s (package and dependencies not updated)' % package.name)
- raise SkipToState(Package.STATE_DONE)
-
class SkipToState(Exception):
def __init__(self, state):
@@ -175,8 +144,9 @@
if state == self.STATE_DONE:
return state
do_method = getattr(self, 'do_' + state)
- if hasattr(self, 'skip_' + state):
- skip_method = getattr(self, 'skip_' + state)
+
+ skip_method = getattr(self, 'skip_' + state)
+ try:
if skip_method(buildscript, last_state):
state = do_method.next_state
assert state not in seen_states, (
@@ -184,9 +154,8 @@
'skipped states: %r' % (state, seen_states))
else:
return state
- else:
- # no skip rule
- return state
+ except SkipToState, e:
+ return e.state
def run_state(self, buildscript, state):
"""run a particular part of the build for this package.
@@ -195,20 +164,60 @@
(next-state, error-flag, [other-states])
"""
method = getattr(self, 'do_' + state)
- # has the state been updated to the new system?
- if hasattr(method, 'next_state'):
- try:
- method(buildscript)
- except SkipToState, e:
- return (e.state, None, None)
- except (CommandError, BuildStateError), e:
- return (self._next_state(buildscript, state),
- str(e), method.error_states)
- else:
- return (self._next_state(buildscript, state),
- None, None)
+ try:
+ method(buildscript)
+ except SkipToState, e:
+ return (e.state, None, None)
+ except (CommandError, BuildStateError), e:
+ return (self._next_state(buildscript, state),
+ str(e), method.error_states)
else:
- return method(buildscript)
+ return (self._next_state(buildscript, state), None, None)
+
+ def check_build_policy(self, buildscript):
+ if buildscript.config.force_policy:
+ return
+ if not buildscript.config.build_policy in ('updated', 'updated-deps'):
+ return
+ if not buildscript.packagedb.check(self.name, self.get_revision() or ''):
+ # package has not been updated
+ return
+
+ # module has not been updated
+ if buildscript.config.build_policy == 'updated':
+ buildscript.message('Skipping %s (not updated)' % self.name)
+ return self.STATE_DONE
+
+ if buildscript.config.build_policy == 'updated-deps':
+ install_date = buildscript.packagedb.installdate(self.name)
+ for dep in self.dependencies:
+ install_date_dep = buildscript.packagedb.installdate(dep)
+ if install_date_dep > install_date:
+ # a dependency has been updated
+ return None
+ else:
+ buildscript.message(
+ 'Skipping %s (package and dependencies not updated)' % self.name)
+ return self.STATE_DONE
+
+ def checkout(self, buildscript):
+ srcdir = self.get_srcdir(buildscript)
+ buildscript.set_action('Checking out', self)
+ self.branch.checkout(buildscript)
+ # did the checkout succeed?
+ if not os.path.exists(srcdir):
+ raise BuildStateError('source directory %s was not created' % srcdir)
+
+ if self.check_build_policy(buildscript) == self.STATE_DONE:
+ raise SkipToState(self.STATE_DONE)
+
+ def skip_checkout(self, buildscript, last_state):
+ # skip the checkout stage if the nonetwork flag is set
+ if buildscript.config.nonetwork:
+ if self.check_build_policy(buildscript) == self.STATE_DONE:
+ raise SkipToState(self.STATE_DONE)
+ return True
+ return False
class MetaModule(Package):
Modified: trunk/jhbuild/modtypes/autotools.py
==============================================================================
--- trunk/jhbuild/modtypes/autotools.py (original)
+++ trunk/jhbuild/modtypes/autotools.py Sat Jan 19 16:32:29 2008
@@ -24,8 +24,7 @@
from jhbuild.errors import FatalError, BuildStateError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type, \
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
__all__ = [ 'AutogenModule' ]
@@ -80,13 +79,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(buildscript)
do_checkout.next_state = STATE_CONFIGURE
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/cmake.py
==============================================================================
--- trunk/jhbuild/modtypes/cmake.py (original)
+++ trunk/jhbuild/modtypes/cmake.py Sat Jan 19 16:32:29 2008
@@ -23,8 +23,7 @@
from jhbuild.errors import BuildStateError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type, \
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
__all__ = [ 'CMakeModule' ]
@@ -61,13 +60,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(buildscript)
do_checkout.next_state = STATE_CONFIGURE
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/distutils.py
==============================================================================
--- trunk/jhbuild/modtypes/distutils.py (original)
+++ trunk/jhbuild/modtypes/distutils.py Sat Jan 19 16:32:29 2008
@@ -23,8 +23,7 @@
from jhbuild.errors import BuildStateError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type, \
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
__all__ = [ 'DistutilsModule' ]
@@ -64,13 +63,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(buildscript)
do_checkout.next_state = STATE_BUILD
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/linux.py
==============================================================================
--- trunk/jhbuild/modtypes/linux.py (original)
+++ trunk/jhbuild/modtypes/linux.py Sat Jan 19 16:32:29 2008
@@ -66,21 +66,17 @@
def skip_checkout(self, buildscript, last_state):
# skip the checkout stage if the nonetwork flag is set
+ # (can't just call Package.skip_checkout() as build policy won't work
+ # with kconfigs)
return buildscript.config.nonetwork
def do_checkout(self, buildscript):
buildscript.set_action('Checking out', self)
-
- self.branch.checkout(buildscript)
- # did the checkout succeed?
- if not os.path.exists(self.branch.srcdir):
- raise BuildStateError('source directory %s was not created' % self.branch.srcdir)
-
+ self.checkout(buildscript)
for kconfig in self.kconfigs:
kconfig.checkout(buildscript)
if not os.path.exists(kconfig.path):
raise BuildStateError('kconfig file %s was not created' % kconfig.path)
-
do_checkout.next_state = STATE_CONFIGURE
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/mesa.py
==============================================================================
--- trunk/jhbuild/modtypes/mesa.py (original)
+++ trunk/jhbuild/modtypes/mesa.py Sat Jan 19 16:32:29 2008
@@ -26,8 +26,7 @@
from jhbuild.errors import BuildStateError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type, \
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
__all__ = [ 'MesaModule' ]
@@ -78,13 +77,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(buildscript)
do_checkout.next_state = STATE_BUILD
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/mozillamodule.py
==============================================================================
--- trunk/jhbuild/modtypes/mozillamodule.py (original)
+++ trunk/jhbuild/modtypes/mozillamodule.py Sat Jan 19 16:32:29 2008
@@ -22,8 +22,7 @@
import os
-from jhbuild.modtypes import register_module_type, get_dependencies, \
- check_build_policy
+from jhbuild.modtypes import register_module_type, get_dependencies, SkipToState
from jhbuild.modtypes.autotools import AutogenModule
from jhbuild.versioncontrol import cvs
from jhbuild.errors import FatalError, BuildStateError
@@ -103,7 +102,9 @@
if not os.path.exists(checkoutdir):
raise BuildStateError('source directory %s was not created'
% checkoutdir)
- check_build_policy(self, buildscript)
+
+ if self.check_build_policy(buildscript):
+ raise SkipToState(self.STATE_DONE)
do_checkout.next_state = AutogenModule.STATE_CONFIGURE
do_checkout.error_states = [AutogenModule.STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/perl.py
==============================================================================
--- trunk/jhbuild/modtypes/perl.py (original)
+++ trunk/jhbuild/modtypes/perl.py Sat Jan 19 16:32:29 2008
@@ -24,8 +24,7 @@
from jhbuild.errors import BuildStateError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type, \
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
__all__ = [ 'PerlModule' ]
@@ -60,13 +59,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(buildscript)
do_checkout.next_state = STATE_BUILD
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/jhbuild/modtypes/testmodule.py
==============================================================================
--- trunk/jhbuild/modtypes/testmodule.py (original)
+++ trunk/jhbuild/modtypes/testmodule.py Sat Jan 19 16:32:29 2008
@@ -59,40 +59,20 @@
return self.branch.branchname
def do_start(self, buildscript):
- testdir = buildscript.config.buildroot
- if not buildscript.config.nonetwork: # normal start state
- return (self.STATE_CHECKOUT, None, None)
- else:
- return (self.STATE_TEST, None, None)
+ pass
+ do_start.next_state = STATE_CHECKOUT
+ do_start.error_states = []
def do_checkout(self, buildscript):
- srcdir = self.get_srcdir(buildscript)
- buildscript.set_action('Checking out', self)
- try:
- self.branch.checkout(buildscript)
- except CommandError:
- succeeded = False
- else:
- succeeded = True
-
- nextstate = self.STATE_TEST
- # did the checkout succeed?
- if succeeded and os.path.exists(srcdir):
- return (nextstate, None, None)
- else:
- return (nextstate, 'could not update module',
- [self.STATE_FORCE_CHECKOUT])
+ self.checkout(buildscript)
+ do_checkout.next_state = STATE_TEST
+ do_checkout.error_states = [STATE_FORCE_CHECKOUT]
def do_force_checkout(self, buildscript):
buildscript.set_action('Checking out', self)
- nextstate = self.STATE_TEST
- try:
- self.branch.force_checkout(buildscript)
- except CommandError:
- return (nextstate, 'could not checkout module',
- [self.STATE_FORCE_CHECKOUT])
- else:
- return (nextstate, None, None)
+ self.branch.force_checkout(buildscript)
+ do_force_checkout.next_state = STATE_TEST
+ do_force_checkout.error_states = [STATE_FORCE_CHECKOUT]
def _get_display(self):
# get free display
@@ -126,10 +106,10 @@
return ''
return new_xauth
- def do_test(self, buildscript):
- method = getattr(self, 'do_' + self.test_type + '_test')
- nextstate = self.STATE_DONE
+ def skip_test(self, buildscript, last_state):
+ return False
+ def do_test(self, buildscript):
buildscript.set_action('Testing', self)
if not buildscript.config.noxvfb:
# start Xvfb
@@ -137,27 +117,27 @@
old_xauth = os.environ.get('XAUTHORITY')
xvfb_pid = self._start_xvfb(buildscript.config.xvfbargs)
if xvfb_pid == -1:
- return (nextstate, 'Unable to start Xvfb', [])
+ raise BuildStateError('Unable to start Xvfb')
- status, error = method(buildscript)
-
- if not buildscript.config.noxvfb:
- # kill Xvfb if it has been started
- self._stop_xvfb(xvfb_pid)
- if old_display:
- os.environ['DISPLAY'] = old_display
- else:
- os.unsetenv('DISPLAY')
- if old_xauth:
- os.environ['XAUTHORITY'] = old_xauth
- else:
- os.unsetenv('XAUTHORITY')
+ # either do_ldtp_test or do_dogtail_test
+ method = getattr(self, 'do_' + self.test_type + '_test')
+ try:
+ method(buildscript)
+ finally:
+ if not buildscript.config.noxvfb:
+ # kill Xvfb if it has been started
+ self._stop_xvfb(xvfb_pid)
+ if old_display:
+ os.environ['DISPLAY'] = old_display
+ else:
+ os.unsetenv('DISPLAY')
+ if old_xauth:
+ os.environ['XAUTHORITY'] = old_xauth
+ else:
+ os.unsetenv('XAUTHORITY')
+ do_test.next_state = Package.STATE_DONE
+ do_test.error_states = []
- if status !=0:
- return (nextstate, error, [])
- buildscript.message(error)
- return (nextstate, None, None)
-
def get_ldtp_log_file(self, filename):
# <ldtp>
# |
@@ -310,7 +290,7 @@
ldtp_pid = self._start_ldtp()
if ldtp_pid == -1:
- return (ldtp_pid, 'Unable to start ldtp server')
+ raise BuildStateError('Unable to start ldtp server')
try:
if buildscript.config.noxvfb:
@@ -321,8 +301,8 @@
except CommandError, e:
os.kill(ldtp_pid, signal.SIGINT)
if e.returncode == 32512: # ldtprunner not installed
- return (e.returncode, 'ldtprunner not available')
- return (e.returncode, 'error during running of test')
+ raise BuildStateError('ldtprunner not available')
+ raise BuildStateError('error %s during test' % e.returncode)
os.kill(ldtp_pid, signal.SIGINT)
if old_debug != None:
@@ -330,15 +310,14 @@
log_file = self.get_ldtp_log_file(os.path.join (src_dir,'run.xml'))
if not log_file:
- return (-1, 'missing log file')
+ raise BuildStateError('missing log file')
try:
groups = self._check_ldtp_log_file(log_file)
flag, status = self.check_groups(groups)
if flag:
- return (-1, status)
+ raise BuildStateError(status)
except:
- return (-1, 'malformed log file')
- return (0, status)
+ raise BuildStateError('malformed log file')
def do_dogtail_test(self, buildscript):
src_dir = self.get_srcdir(buildscript)
@@ -356,11 +335,7 @@
cwd=src_dir, extra_env={'DISPLAY': ':%s' % self.screennum})
except CommandError, e:
if e.returncode != 0:
- status += '%s failed\n' % test_case
- failed = True
- if failed:
- return (-1, status)
- return (0, status)
+ raise BuildStateError('%s failed' % test_case)
def get_tested_packages(node):
Modified: trunk/jhbuild/modtypes/waf.py
==============================================================================
--- trunk/jhbuild/modtypes/waf.py (original)
+++ trunk/jhbuild/modtypes/waf.py Sat Jan 19 16:32:29 2008
@@ -25,8 +25,7 @@
from jhbuild.errors import FatalError, BuildStateError, CommandError
from jhbuild.modtypes import \
- Package, get_dependencies, get_branch, register_module_type,\
- checkout, check_build_policy
+ Package, get_dependencies, get_branch, register_module_type
from jhbuild.commands.sanitycheck import inpath
__all__ = [ 'WafModule' ]
@@ -64,13 +63,8 @@
do_start.next_state = STATE_CHECKOUT
do_start.error_states = []
- def skip_checkout(self, buildscript, last_state):
- # skip the checkout stage if the nonetwork flag is set
- return buildscript.config.nonetwork
-
def do_checkout(self, buildscript):
- checkout(self, buildscript)
- check_build_policy(self, buildscript)
+ self.checkout(self, buildscript)
do_checkout.next_state = STATE_CONFIGURE
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
Modified: trunk/tests/mock.py
==============================================================================
--- trunk/tests/mock.py (original)
+++ trunk/tests/mock.py Sat Jan 19 16:32:29 2008
@@ -26,9 +26,11 @@
class Config:
buildroot = '/tmp/'
builddir_pattern = '%s'
+ use_lib64 = False
+ noxvfb = True
+
force_policy = False
build_policy = 'all'
- use_lib64 = False
nonetwork = False
nobuild = False
Modified: trunk/tests/tests.py
==============================================================================
--- trunk/tests/tests.py (original)
+++ trunk/tests/tests.py Sat Jan 19 16:32:29 2008
@@ -150,6 +150,8 @@
class AutotoolsModTypeTestCase(ModTypeTestCase):
+ '''Autotools steps'''
+
def setUp(self):
ModTypeTestCase.setUp(self)
from jhbuild.modtypes.autotools import AutogenModule
@@ -181,6 +183,8 @@
class BuildPolicyTestCase(ModTypeTestCase):
+ '''Build Policy'''
+
def setUp(self):
ModTypeTestCase.setUp(self)
from jhbuild.modtypes.autotools import AutogenModule
@@ -197,6 +201,39 @@
self.config.build_policy = 'updated'
self.assertEqual(self.build(packagedb_params = {'uptodate': True}), ['Checking out'])
+ def test_policy_all_with_no_network(self):
+ '''Building an uptodate module with "all" policy, without network'''
+ self.config.build_policy = 'all'
+ self.assertEqual(self.build(
+ packagedb_params = {'uptodate': True},
+ nonetwork = True),
+ ['Configuring', 'Building', 'Installing'])
+
+ def test_policy_updated_with_no_network(self):
+ '''Building an uptodate module with "updated" policy, without network'''
+ self.config.build_policy = 'updated'
+ self.assertEqual(self.build(
+ packagedb_params = {'uptodate': True},
+ nonetwork = True), [])
+
+
+class TestModTypeTestCase(ModTypeTestCase):
+ '''Tests Module Steps'''
+
+ def setUp(self):
+ ModTypeTestCase.setUp(self)
+ from jhbuild.modtypes.testmodule import TestModule
+ self.module = TestModule('foo', self.branch, 'dogtail')
+
+ def test_run(self):
+ '''Running a test module'''
+ self.assertEqual(self.build(), ['Checking out', 'Testing'])
+
+ def test_build_no_network(self):
+ '''Running a test module, without network'''
+ self.assertEqual(self.build(nonetwork = True), ['Testing'])
+
+
if __name__ == '__main__':
unittest.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]