-
Notifications
You must be signed in to change notification settings - Fork 1
/
flumotion-trial
executable file
·87 lines (69 loc) · 2.98 KB
/
flumotion-trial
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/python
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
# Flumotion - a streaming media server
# Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L.
# Copyright (C) 2010,2011 Flumotion Services, S.A.
# All rights reserved.
#
# This file may be distributed and/or modified under the terms of
# the GNU Lesser General Public License version 2.1 as published by
# the Free Software Foundation.
# This file is distributed without any warranty; without even the implied
# warranty of merchantability or fitness for a particular purpose.
# See "LICENSE.LGPL" in the source distribution for more information.
#
# Headers in this file shall remain intact.
# This is a trial replacement with support for storing the
# intermediate coverage results in a file. Useful for running trial a
# couple of times with different reactors and building up the final
# coverage.
import os
import sys
from optparse import OptionParser
from twisted.python import usage
import twisted.scripts.trial
# Store the class we'll be overriding in local namespace
_Options = twisted.scripts.trial.Options
class FOptions(_Options):
optFlags = [
['skip-slow', None,
"Skip slow test cases (marked with a 'slow = True' attribute)."]]
optParameters = [['saved-coverage', None, None,
'Filename to store coverage results.'
' Can only be used with --coverage.']]
def postOptions(self):
_Options.postOptions(self)
if self['saved-coverage'] and not self.tracer:
raise usage.UsageError(
"Cannot specify --saved-coverage without --coverage")
if self['saved-coverage'] and self.tracer:
# need to replace the tracer with one using our saved-coverage file
print 'Saving coverage in', self['saved-coverage']
import trace
self.tracer = trace.Trace(count=1, trace=0,
infile=self['saved-coverage'],
outfile=self['saved-coverage'])
sys.settrace(self.tracer.globaltrace)
# make options available to flumotion.testsuite
def getConfig():
return dict(self)
twisted.scripts.trial.getConfig = getConfig
twisted.scripts.trial.Options = FOptions
# without this snippet, copied from twisted's trial, for some reason
# this script misses modules it should get coverage data for,
# like flumotion.extern.log
### Twisted Preamble
# This makes sure that users don't have to set up their environment
# specially in order to run these programs from bin/.
import sys, os, string
if string.find(os.path.abspath(sys.argv[0]), os.sep+'Twisted') != -1:
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)))
if hasattr(os, "getuid") and os.getuid() != 0:
sys.path.insert(0, os.curdir)
### end of preamble
# begin chdir armor
sys.path[:] = map(os.path.abspath, sys.path)
# end chdir armor
from twisted.scripts.trial import run
run()