Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
tor-browser-bundle-testsuite
Commits
2ae36ba0
Unverified
Commit
2ae36ba0
authored
Mar 04, 2014
by
boklm
Browse files
run_test: save result in a json file if SELENIUM_TEST_RESULT_FILE is set
parent
dab869b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
selenium-tests/run_test
View file @
2ae36ba0
#!/usr/bin/python
import
unittest
,
time
,
re
import
sys
import
json
import
os
def
save_result
(
testres
):
if
not
os
.
environ
.
get
(
'SELENIUM_TEST_RESULT_FILE'
):
return
res
=
{}
res
[
'success'
]
=
testres
.
wasSuccessful
()
res
[
'total_tests'
]
=
testres
.
testsRun
res
[
'failed'
]
=
[]
failures
=
testres
.
failures
+
testres
.
errors
for
f
in
failures
:
r
=
{}
r
[
'id'
]
=
f
[
0
].
id
()
r
[
'error'
]
=
f
[
1
]
res
[
'failed'
].
append
(
r
)
output
=
open
(
os
.
environ
.
get
(
'SELENIUM_TEST_RESULT_FILE'
),
'w'
)
output
.
write
(
json
.
dumps
(
res
))
output
.
close
()
if
len
(
sys
.
argv
)
!=
2
:
sys
.
exit
(
'Usage: run_test <test_name>'
)
...
...
@@ -8,3 +28,4 @@ if len(sys.argv) != 2:
t
=
__import__
(
'test_%s'
%
sys
.
argv
[
1
])
suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
t
.
Test
)
res
=
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
suite
)
save_result
(
res
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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