Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite - base
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Production Test Suite - base
Commits
a45c6e33
Commit
a45c6e33
authored
May 19, 2011
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tps: factor out run_test
parent
2ca0cfca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
33 deletions
+41
-33
tps.py
tps.py
+41
-33
No files found.
tps.py
View file @
a45c6e33
...
...
@@ -14,6 +14,19 @@ from tpsexcept import *
default_config_file
=
'default.cfg'
def
run_test
(
testname
,
logname
):
"""run test testname with output redirected to logname
"""
try
:
tmpout
=
sys
.
stdout
with
open
(
logname
,
'w'
)
as
sys
.
stdout
:
mod
=
__import__
(
testname
,
globals
(),
locals
(),
[
'main'
])
mod
.
main
()
except
:
raise
finally
:
sys
.
stdout
=
tmpout
class
Suite
(
object
):
def
__init__
(
self
,
cfgfilename
=
default_config_file
):
self
.
config
=
cfgfilename
...
...
@@ -43,21 +56,17 @@ class Suite(object):
def
run
(
self
):
ts
=
timestamp
()
serial
=
get_serial
()
test_glob
=
os
.
path
.
join
(
self
.
path
,
self
.
pattern
+
'.py'
)
sequence
=
glob
.
glob
(
test_glob
)
if
self
.
path
not
in
sys
.
path
:
sys
.
path
.
append
(
self
.
path
)
for
test
in
sequence
:
testname
,
ext
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
test
))
serial
=
get_serial
()
ts
=
timestamp
()
logname
=
os
.
path
.
join
(
self
.
logpath
,
self
.
log_pattern
%
dict
(
serial
=
serial
,
timestamp
=
ts
,
test
=
testname
))
tmpout
=
sys
.
stdout
with
open
(
logname
,
'w'
)
as
sys
.
stdout
:
try
:
mod
=
__import__
(
testname
,
globals
(),
locals
(),
[
'main'
])
mod
.
main
()
testname
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
test
))[
0
]
logname
=
self
.
log_pattern
%
dict
(
serial
=
serial
,
timestamp
=
ts
,
test
=
testname
)
logname
=
os
.
path
.
join
(
self
.
logpath
,
logname
)
run_test
(
testname
,
logname
)
except
TpsCritical
,
e
:
print
'Tps Critical error, aborting: [
%
s]'
%
e
.
message
break
...
...
@@ -80,7 +89,6 @@ class Suite(object):
finally
:
print
'ran test '
,
test
pass
sys
.
stdout
=
tmpout
def
write_config
(
self
):
config
=
ConfigParser
()
...
...
@@ -189,4 +197,4 @@ def main2():
cli
.
cmdloop
()
if
__name__
==
'__main__'
:
main
2
()
main
1
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment