FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
buck/docs/rule/python_test.soy at master · runningcode/buck · GitHub
runningcode
/
buck
Public
forked from
facebook/buck
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
buck
/
docs
/
rule
/
python_test.soy
Copy path
More file actions
More file actions
Latest commit
History
History
History
178 lines (152 loc) · 4.51 KB
Breadcrumbs
buck
/
docs
/
rule
/
python_test.soy
Copy path
File metadata and controls
178 lines (152 loc) · 4.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
namespace
python_test
}
/***/
{
template
.soyweb
}
{
call
buck.page
}
{
param
title:
'python_test()'
/}
{
param
navid:
'rule_python_test'
/}
{
param
prettify:
true /}
{
param
description
}
A rule that is used to define a set of python files that contian tests
to run via the python unit testing framework.
{/
param
}
{
param
content
}
{
call
buck.rule
}
{
param
status:
'UNFROZEN'
/}
{
param
overview
}
A <
code
>python_test()</
code
> rule is used to define a set of <
code
>.py</
code
>{sp}
files that contain tests to run via the <
a
href
=
"
https://docs.python.org/2/library/unittest.html
"
>Python unit testing framework</
a
>.
{/
param
}
{
param
args
}
{
call
buck.arg
}
{
param
name:
'name'
/}
{
param
desc
}
The name of the rule.
{/
param
}
{/
call
}
{
call
python_common.srcs_arg
/}
{
call
python_common.platform_srcs_arg
/}
{
call
python_common.resources_arg
/}
{
call
python_common.platform_resources_arg
/}
{
call
python_common.base_module_arg
/}
{
call
python_common.exclude_deps_from_merged_linking_arg
/}
{
call
buck.arg
}
{
param
name:
'main_module'
/}
{
param
default :
'None'
/}
{
param
desc
}
The main module used to run the tests.
This parameter is normally not needed, as Buck will provide a default main
module that runs all tests. However, you can override this with your own
module to perform custom initialization or command line processing. Your
custom module can import the standard Buck test main
as <
code
>__test_main__</
code
>, and can invoke it's normal main function
as <
code
>__test_main__.main(sys.argv)</
code
>.
{/
param
}
{/
call
}
{
call
python_common.platform_arg
/}
{
call
buck.arg
}
{
param
name:
'env'
/}
{{
param
default :
'{}'
/}}
{
param
desc
}
A map of environment names and values to set when running the test.
<
br
><
br
>
It is also possible to expand references to other rules within the <
b
>values</
b
> of
these environment variables, using builtin {
call
buck.string_parameter_macros
/}:
<
dl
>
<
dt
><
code
>$(location /
&
#x2F
;
path/to:target)</
code
></
dt
>
<
dd
>Expands to the location of the output of the build rule. This
means that you can refer to these without needing to be aware of how
Buck is storing data on the disk mid-build.</
dd
>
</
dl
>
{/
param
}
{/
call
}
{
call
buck.arg
}
{
param
name:
'deps'
/}
{
param
default :
'[]'
/}
{
param
desc
}
{
call
buck.python_library
/} rules used by the tests in this rules sources.
{/
param
}
{/
call
}
{
call
buck.arg
}
{
param
name:
'labels'
/}
{
param
default:
'[]'
/}
{
param
desc
}
A list of labels to be applied to these tests. These labels are
arbitrary text strings and have no meaning within buck itself. They
can, however, have meaning for you as a test author
(e.g., <
code
>smoke</
code
> or <
code
>fast</
code
>). A label can be
used to filter or include a specific <
code
>python_test()</
code
> rule
when executing <
a
href
=
"
{ROOT}command/test.html
"
><
code
>buck
test</
code
></
a
>.
{/
param
}
{/
call
}
{
call
buck.test_rule_timeout_ms
/}
{
call
python_common.package_style_arg
/}
{
call
python_common.preload_deps_arg
/}
{
call
python_common.linker_flags_arg
/}
{/
param
} // close args
{
param
examples
}
{
literal
}<pre class="prettyprint lang-py">
# A rule that includes a single .py file containing tests.
python_test(
name = 'fileutil_test',
srcs = ['fileutil_tests.py'],
deps = [
':fileutil',
],
)
# A rule that uses glob() to include all sources in the directory which the
# rule is defined. It also lists a resource file that gets packaged with
# the sources in this rule.
python_library(
name = 'fileutil',
srcs = glob(['fileutil/**/*.py'],
resources = [
'testdata.dat',
],
)
</pre>{/
literal
}
<
p
>
Here is an example of using the `platform_srcs` and `platform_resources`
parameters to pull in sources/resources only when building for a specific
Python platform:
</
p
>
{
literal
}<pre class="prettyprint lang-ini">
; .buckconfig
[python#py2]
interpreter = /usr/bin/python2.7
[python#py3]
interpreter = /usr/bin/python3.4
</pre>{/
literal
}
{
literal
}<pre class="prettyprint lang-py">
# BUCK
python_test(
name = 'test',
platform_srcs = [
('py2', ['foo.py']),
('py3', ['bar.py']),
],
platform_resources = [
('py2', ['foo.dat']),
('py3', ['bar.dat']),
],
)
</pre>{/
literal
}
<
p
>
Here is an example of using the `platform` parameter to select the "py2"
Python platform as defined in `.buckconfig` above:
</
p
>
{
literal
}<pre class="prettyprint lang-py">
# BUCK
python_test(
name = 'bin',
platform = 'py2',
srcs = [
'foo.py',
],
)
</pre>{/
literal
}
{/
param
}
{/
call
} // close buck.rule
{/
param
}
{/
call
}
{
/template
}
Back
|
FazBrowse Home
|
New Git URL