forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_snippets.py
More file actions
55 lines (47 loc) · 1.65 KB
/
run_snippets.py
File metadata and controls
55 lines (47 loc) · 1.65 KB
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
# Copyright (c) 2018 CEF Python, see the Authors file.
# All rights reserved. Licensed under BSD 3-clause license.
# Project website: https://github.com/cztomczak/cefpython
"""
Run all snippets from the examples/snippets/ directory
and display a summary at the end.
"""
from common import *
import glob
import os
import subprocess
import sys
def main():
# Iterate over all snippets
snippets_iter = glob.glob(os.path.join(SNIPPETS_DIR, "*.py"))
succeeded = []
failed = []
for snippet in snippets_iter:
print("[run_snippets.py] Running '{snippet}'..."
.format(snippet=os.path.basename(snippet)))
retcode = subprocess.call([sys.executable, snippet])
if retcode == 0:
succeeded.append(os.path.basename(snippet))
else:
print("[run_snippets.py] ERROR while running snippet: {snippet}"
.format(snippet=snippet))
failed.append(os.path.basename(snippet))
# Print summary
summary = ""
for snippet in succeeded:
summary += " OK {snippet}{nl}"\
.format(snippet=snippet, nl=os.linesep)
for snippet in failed:
summary += " ERROR {snippet}{nl}"\
.format(snippet=snippet, nl=os.linesep)
summary = summary[:-(len(os.linesep))]
print("[run_snippets.py] SUMMARY:")
print(summary.format())
if len(failed):
print("[run_snippets.py] ERRORS ({failed}) while running snippets"
.format(failed=len(failed)))
sys.exit(1)
else:
print("[run_snippets.py] OK ({succeeded})"
.format(succeeded=len(succeeded)))
if __name__ == "__main__":
main()