Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
infra
bots
infra_tests.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
#
3
# Copyright 2016 Google Inc.
4
#
5
# Use of this source code is governed by a BSD-style license that can be
6
# found in the LICENSE file.
7
8
9
"""Run all infrastructure-related tests."""
10
11
12
import
os
13
import
subprocess
14
import
sys
15
16
17
INFRA_BOTS_DIR = os.path.dirname(os.path.realpath(__file__))
18
SKIA_DIR = os.path.abspath(os.path.join(INFRA_BOTS_DIR, os.pardir, os.pardir))
19
20
21
def
test
(cmd, cwd):
22
try
:
23
subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT, encoding=
'utf-8'
)
24
except
subprocess.CalledProcessError
as
e:
25
return
e.output
26
27
28
def
python_unit_tests
(train):
29
if
train:
30
return
None
31
return
test
(
32
[sys.executable,
'-u'
,
'-m'
,
'unittest'
,
'discover'
,
'-s'
,
'.'
,
'-p'
,
33
'*_test.py'
],
34
INFRA_BOTS_DIR)
35
36
37
def
recipe_test
(train):
38
cmd = [
39
sys.executable,
'-u'
, os.path.join(INFRA_BOTS_DIR,
'recipes.py'
),
'test'
]
40
if
train:
41
cmd.append(
'train'
)
42
else
:
43
cmd.append(
'run'
)
44
return
test
(cmd, SKIA_DIR)
45
46
47
def
gen_tasks_test
(train):
48
cmd = [
'go'
,
'run'
,
'gen_tasks.go'
]
49
if
not
train:
50
cmd.append(
'--test'
)
51
try
:
52
output =
test
(cmd, INFRA_BOTS_DIR)
53
except
OSError:
54
return
(
'Failed to run "%s"; do you have Go installed on your machine?'
55
%
' '
.join(cmd))
56
return
output
57
58
59
def
main
():
60
train =
False
61
if
'--train'
in
sys.argv:
62
train =
True
63
64
tests = (
65
python_unit_tests,
66
recipe_test,
67
gen_tasks_test,
68
)
69
errs = []
70
for
t
in
tests:
71
err = t(train)
72
if
err:
73
errs.append(err)
74
75
if
len(errs) > 0:
76
print
(
'Test failures:\n'
, file=sys.stderr)
77
for
err
in
errs:
78
print
(
'=============================='
, file=sys.stderr)
79
print
(err, file=sys.stderr)
80
print
(
'=============================='
, file=sys.stderr)
81
sys.exit(1)
82
83
if
train:
84
print
(
'Trained tests successfully.'
)
85
else
:
86
print
(
'All tests passed!'
)
87
88
89
if
__name__ ==
'__main__'
:
90
main
()
print
void print(void *str)
Definition
bridge.cpp:126
infra_tests.python_unit_tests
python_unit_tests(train)
Definition
infra_tests.py:28
infra_tests.recipe_test
recipe_test(train)
Definition
infra_tests.py:37
infra_tests.main
main()
Definition
infra_tests.py:59
infra_tests.gen_tasks_test
gen_tasks_test(train)
Definition
infra_tests.py:47
main
Definition
main.py:1
test
Generated on Fri Apr 26 2024 06:16:15 for Flutter Engine by
1.9.8