-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathprofile-stage.feature
More file actions
196 lines (174 loc) · 6.19 KB
/
profile-stage.feature
File metadata and controls
196 lines (174 loc) · 6.19 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Feature: Profile the template render stage
Scenario: Profiler loads a summary table
Given a WP install
When I run `wp profile stage --fields=stage`
Then STDOUT should be a table containing rows:
| stage |
| bootstrap |
| main_query |
| template |
Scenario: Profiler loads a table with the correct hooks
Given a WP install
When I run `wp profile stage bootstrap --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| muplugins_loaded:before |
| muplugins_loaded |
| plugins_loaded:before |
| plugins_loaded |
| setup_theme:before |
| setup_theme |
| after_setup_theme:before |
| after_setup_theme |
| init:before |
| init |
| wp_loaded:before |
| wp_loaded |
| wp_loaded:after |
When I run `wp profile stage main_query --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| parse_request:before |
| parse_request |
| send_headers:before |
| send_headers |
| pre_get_posts:before |
| pre_get_posts |
| the_posts:before |
| the_posts |
| wp:before |
| wp |
| wp:after |
When I run `wp profile stage template --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| template_redirect:before |
| template_redirect |
| template_include:before |
| template_include |
| wp_head:before |
| wp_head |
| loop_start:before |
| loop_start |
| loop_end:before |
| loop_end |
| wp_footer:before |
| wp_footer |
| wp_footer:after |
When I run `wp profile stage template --fields=hook --orderby=hook --order=DESC`
Then STDOUT should be a table containing rows:
| hook |
| wp_head:before |
| wp_head |
| wp_footer:before |
| wp_footer:after |
| wp_footer |
| template_redirect:before |
| template_redirect |
| template_include:before |
| template_include |
| loop_start:before |
| loop_start |
| loop_end:before |
| loop_end |
Scenario: Use --all flag to profile all stages
Given a WP install
When I run `wp profile stage --all --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| muplugins_loaded:before |
| muplugins_loaded |
| plugins_loaded:before |
| plugins_loaded |
| setup_theme:before |
| setup_theme |
| after_setup_theme:before |
| after_setup_theme |
| init:before |
| init |
| wp_loaded:before |
| wp_loaded |
| parse_request:before |
| parse_request |
| send_headers:before |
| send_headers |
| pre_get_posts:before |
| pre_get_posts |
| the_posts:before |
| the_posts |
| wp:before |
| wp |
| template_redirect:before |
| template_redirect |
| template_include:before |
| template_include |
| wp_head:before |
| wp_head |
| loop_start:before |
| loop_start |
| loop_end:before |
| loop_end |
| wp_footer:before |
| wp_footer |
| wp_footer:after |
| total (35) |
Scenario: Invalid stage specified
Given a WP install
When I try `wp profile stage foo_bar`
Then STDERR should be:
"""
Error: Invalid stage. Must be one of bootstrap, main_query, template, or use --all.
"""
Scenario: Invalid field name supplied to --fields
Given a WP install
When I try `wp profile stage template --fields=test`
Then STDERR should contain:
"""
Invalid field(s): test
"""
And the return code should be 1
Scenario: Identify callback_count for each hook
Given a WP install
When I run `wp profile stage bootstrap --fields=hook,callback_count`
Then STDOUT should be a table containing rows:
| hook | callback_count |
| muplugins_loaded | 2 |
Scenario: Use spotlight mode to filter out the zero-ish values
Given a WP install
When I run `wp profile stage bootstrap --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| init |
| wp_loaded:before |
| wp_loaded |
| wp_loaded:after |
When I run `wp profile stage bootstrap --fields=hook --spotlight`
Then STDOUT should be a table containing rows:
| hook |
| init |
| wp_loaded:after |
@require-wp-4.0
Scenario: Admin URL runs as a backend request and skips frontend stages
Given a WP install
When I run `wp profile stage --url=example.com/wp-admin/ --context=admin --fields=stage`
Then STDOUT should be a table containing rows:
| stage |
| bootstrap |
And STDOUT should not contain:
"""
main_query
"""
And STDOUT should not contain:
"""
template
"""
And STDERR should be empty
@require-wp-4.0
Scenario: Admin URL without --context=admin emits an error
Given a WP install
When I try `wp profile stage --url=example.com/wp-admin/ --fields=stage`
Then STDERR should contain:
"""
Profiling an admin URL requires --context=admin.
"""
And the return code should be 1