1 # jhbuild - a build script for GNOME 1.x and 2.x
2 # Copyright (C) 2001-2006 James Henstridge
3 # Copyright (C) 2007-2008 Frederic Peters
5 # mock.py: mock objects for unit testing
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 import jhbuild
.frontends
.buildscript
24 import jhbuild
.versioncontrol
28 class Config(jhbuild
.config
.Config
):
30 builddir_pattern
= '%s'
44 makecheck_advisory
= False
48 module_autogenargs
= {}
52 build_targets
= ['install']
65 def __init__(self
, uptodate
= False):
66 self
.force_uptodate
= uptodate
69 def check(self
, package
, version
=None):
70 if self
.force_uptodate
:
71 return self
.force_uptodate
72 return self
.db
.get(package
, ('_none_'))[0] == version
74 def add(self
, package
, version
):
75 self
.db
[package
] = (version
, time
.time()+self
.time_delta
)
77 def remove(self
, package
):
80 def installdate(self
, package
):
81 return self
.db
.get(package
, ('_none_'))[1]
84 class BuildScript(jhbuild
.frontends
.buildscript
.BuildScript
):
85 execute_is_failure
= False
87 def __init__(self
, config
, module_list
):
89 self
.modulelist
= module_list
90 self
.packagedb
= PackageDB()
93 def set_action(self
, action
, module
, module_num
=-1, action_target
=None):
94 self
.actions
.append('%s:%s' % (module
.name
, action
))
96 def execute(self
, command
, hint
=None, cwd
=None, extra_env
=None):
97 if self
.execute_is_failure
:
98 raise jhbuild
.errors
.CommandError('Mock command asked to fail')
100 def message(self
, msg
, module_num
= -1):
103 def handle_error(self
, module
, state
, nextstate
, error
, altstates
):
104 self
.actions
[-1] = self
.actions
[-1] + ' [error]'
107 class Branch(jhbuild
.versioncontrol
.Branch
):
113 srcdir
= property(srcdir
)
115 def checkout(self
, buildscript
):
121 def raise_command_error(*args
):
122 raise jhbuild
.errors
.CommandError('Mock Command Error Exception')