chiark / gitweb /
adt-run: Make --quiet really work (Closes: #637350)
[autopkgtest.git] / runner / adt-run
index 955097b897546666b34a88078ca3b41e8c6e168b..626e5ad08ff0a38fb80542cef906540e6ad1a583 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/python2.6
 #
 # adt-run is part of autopkgtest
 # autopkgtest is a tool for testing Debian binary packages
@@ -261,7 +261,7 @@ class AutoFile:
        xtra = ''
        if p.spec is not None:
                xtra = ' spec[%s]=%s' % (p.spec, getattr(p,'spec_tb',None))
-       raise ("internal error: %s (%s)" % (how, str(p)))
+       raise Exception("internal error: %s (%s)" % (how, str(p)))
 
  def _ensure_path(p, tbp):
        if p.path[tbp] is None:
@@ -595,7 +595,7 @@ def parse_args():
                help='run tests as USER (needs root on testbed)')
        pa('','--gain-root',            type='string', dest='gainroot',
                help='prefix debian/rules binary with GAINROOT')
-       pa('-q', '--quiet', action='store_false', dest='quiet', default=False);
+       pa('-q', '--quiet', action='store_true', dest='quiet', default=False);
        pa('-d', '--debug', action='count', dest='debuglevel', default=0);
        pa('','--gnupg-home',           type='string', dest='gnupghome',
                default='~/.autopkgtest/gpg',
@@ -644,7 +644,7 @@ def parse_args():
                elif type(act) == str:
                        act = (act,act)
                else:
-                       raise ("unknown action in list `%s' having"
+                       raise Exception("unknown action in list `%s' having"
                              " type `%s'" % (act, type(act)))
                (pathstr, kindpath) = act
 
@@ -1013,11 +1013,12 @@ class Restriction:
  def __init__(r,rname,base): pass
 
 class Restriction_rw_build_tree(Restriction): pass
+class Restriction_build_neeeded(Restriction): pass
 class Restriction_breaks_testbed(Restriction):
  def __init__(r, rname, base):
-       if 'revert' not in testbed.caps:
+       if 'revert-full-system' not in testbed.caps:
                raise Unsupported(f.lno,
-                       'Test breaks testbed but testbed cannot revert')
+       'Test breaks testbed but testbed does not advertise revert-full-system')
 class Restriction_needs_root(Restriction):
  def __init__(r, rname, base):
        if 'root-on-testbed' not in testbed.caps:
@@ -1203,19 +1204,22 @@ def read_control(act, tree, control_override):
                return []
 
        lno = 0
-       def badctrl(m): act.bomb('tests/control line %d: %s' % (lno, m))
-       stz = None      # stz[field_name][index] = (lno, value)
+       def badctrl(m): testbed.bomb('tests/control line %d: %s' % (lno, m))
+       stz = { }       # stz[field_name][index] = (lno, value)
                        # special field names:
                        # stz[' lno'] = number
                        # stz[' tests'] = list of Test objects
+                       # empty dictionary means we're between stanzas
+       def in_stanza(stz):
+               return stz.has_key(' lno')
        def end_stanza(stz):
-               if stz is None: return
+               if not in_stanza(stz): return
                stz[' errs'] = 0
-               stanzas.append(stz)
-               stz = None
+               stanzas.append(stz.copy())
+               stz.clear()
                hcurrent = None
 
-       initre = regexp.compile('([A-Z][-0-9a-z]*)\s*\:\s*(.*)$')
+       initre = regexp.compile('([A-Z][-0-9a-zA-Z]*)\s*\:\s*(.*)$')
        while 1:
                l = control.readline()
                if not l: break
@@ -1227,7 +1231,7 @@ def read_control(act, tree, control_override):
                if initmat:
                        (fname, l) = initmat.groups()
                        fname = string.capwords(fname)
-                       if stz is None:
+                       if not in_stanza(stz):
                                stz = { ' lno': lno, ' tests': [] }
                        if not stz.has_key(fname): stz[fname] = [ ]
                        hcurrent = stz[fname]
@@ -1664,12 +1668,8 @@ def build_source(act, control_override):
                stanzas = read_control(act, result_pwd_af, control_override)
                for stanza in stanzas:
                        for t in stanza[' tests']:
-                               if 'build-needed' not in t.restriction_names:
+                               if 'build-needed' in t.restriction_names:
                                        build_needed('test %s' % t.tname)
-                               for d in t.depends:
-                                       if '@' in d:
-                                               build_needed('test %s '
-                                                'dependency %s' % (t.tname,d))
 
                debug_b('build not needed')
                built = False