forked from stb-tester/stb-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stbt-run
executable file
·36 lines (31 loc) · 1.25 KB
/
stbt-run
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
#!/usr/bin/env python
import sys
import traceback
import stbt
parser = stbt.argparser()
parser.prog = 'stbt run'
parser.description = 'Run an stb-tester test script'
parser.add_argument('script',
help='The test script to run (default: %(default)s)')
parser.set_defaults(**stbt.load_defaults('run'))
args = parser.parse_args(sys.argv[1:])
stbt.debug("Arguments:\n" + "\n".join([
"%s: %s" % (k, v) for k, v in args.__dict__.items()]))
stbt.init_run(args.source_pipeline, args.sink_pipeline, args.control)
from stbt import press, press_until_match, wait_for_match, wait_for_motion, \
detect_match, MatchResult, Position, detect_motion, MotionResult, \
save_frame, get_frame, debug, \
UITestError, UITestFailure, MatchTimeout, MotionTimeout, ConfigurationError
try:
execfile(args.script)
except Exception as e:
traceback.print_tb(sys.exc_traceback)
if isinstance(e, stbt.MatchTimeout):
print ("FAIL: %s: Didn't find match for '%s' after %d seconds." % (
args.script, e.expected, e.timeout_secs))
if hasattr(e, "screenshot") and e.screenshot:
stbt.save_frame(e.screenshot, "screenshot.png")
print ("Saved screenshot to '%s'." % ("screenshot.png"))
sys.exit(1)
finally:
stbt.teardown_run()