forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.xml
176 lines (160 loc) · 7.34 KB
/
tests.xml
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
<project name="tests" default="tests:all">
<target name="tests" depends="tests:all" description="Runs all tests, including Behat, PHPUnit, and Security Update check."/>
<target name="test" depends="tests" hidden="true"/>
<target name="tests:all" depends="tests:security-updates, tests:phpunit, tests:behat" hidden="true"/>
<!-- If you experience 'Maximum function nesting level' errors in your PHP
error log, set 'xdebug.max_nesting_level=1000' in php.ini. -->
<target name="tests:behat" depends="setup:behat, tests:run-server, tests:selenium:launch" description="Executes Behat all behat tests in behat.paths.">
<mkdir dir="${reports.localDir}/behat"/>
<foreach list="${behat.paths}" target="tests:behat:execute" param="behat.path"/>
<phingcall target="tests:selenium:kill"/>
</target>
<target name="tests:behat:execute" description="Executes behat tests against specific path." hidden="true">
<!-- Check to see if any behat tests exist in this directory. If not,
behat will throw fatal error. -->
<if>
<not><contains string="${behat.path}" substring=".feature"/></not>
<then>
<exec command="find ${behat.path} -name *.feature -print -quit" logoutput="true" outputProperty="behat.tests.found" level="${blt.exec_level}"/>
</then>
</if>
<if>
<istrue value="${behat.tests.found}"/>
<then>
<!-- Run behat. Any settings in behat.yml or local.yml will be used. -->
<behat executable="${composer.bin}/behat"
config="${behat.config}"
profile="${behat.profile}"
verbose="${behat.verbose}"
strict="${behat.strict}"
haltonerror="${behat.haltonerror}"
returnProperty="behatPass"
out="std,${reports.localDir}"
format="pretty,junit"
path="${behat.path}"
tags="${behat.tags}"
/>
<if>
<!-- A non-zero returns status indicates failure. -->
<not><equals arg1="${behatPass}" arg2="0"/></not>
<then>
<phingcall target="tests:selenium:kill"/>
<fail message="One ore more Behat tests failed." />
</then>
<else>
<echo>All Behat tests in ${behat.path} have passed.</echo>
</else>
</if>
</then>
<else>
<echo message="No Behat tests were found in ${behat.path}"/>
</else>
</if>
</target>
<target name="tests:selenium:launch"
description="Launches Selenium standalone server."
hidden="true">
<if>
<equals arg1="${behat.launch-selenium}" arg2="true"/>
<then>
<phingcall target="tests:selenium:kill"/>
<echo message="Launching Selenium standalone server." />
<touch file="${repo.root}/reports/selenium2.log"/>
<property name="reports.selenium2" value="${reports.localDir}/selenium2.log"/>
<exec command="${composer.bin}/selenium-server-standalone -port 4444 -log ${reports.selenium2}"
dir="${repo.root}"
passthru="true"
spawn="true"
checkreturn="true"
level="${blt.exec_level}"
logoutput="false"/>
<echo>Selenium2 logs are being written to ${reports.selenium2}.</echo>
<echo message="Waiting 10 seconds for Selenium standalone server (http://127.0.0.1:4444) to become available."/>
<waitfor maxwait="10" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="selenium.timedout">
<http url="http://127.0.0.1:4444/wd/hub"/>
</waitfor>
<if>
<equals arg1="${selenium.timedout}" arg2="true"/>
<then>
<fail>
Unable to start Selenium2 standalone server on http://127.0.0.1:4444/wd/hub.
</fail>
</then>
</if>
</then>
<else>
<echo>Not starting Selenium2 standalone server. Hope that you have something else setup!</echo>
</else>
</if>
</target>
<target name="tests:selenium:kill"
description="Kills Selenium standalone server process and any process running on port 4444." hidden="true">
<exec command="lsof -ti tcp:4444 | xargs kill" logoutput="false" level="${blt.exec_level}" passthru="true" checkreturn="false" />
<exec command="pgrep selenium | xargs kill" logoutput="false" level="${blt.exec_level}" passthru="true" checkreturn="false" />
</target>
<!-- Execute PHPUnit tests. -->
<target name="tests:phpunit" description="Executes PHPUnit tests against custom code.">
<delete dir="${reports.localDir}/phpunit" quiet="true"/>
<mkdir dir="${reports.localDir}/phpunit"/>
<phpunit printsummary="true" failureproperty="phpunit.failures" errorproperty="phpunit.errors">
<formatter type="plain" usefile="false"/>
<formatter type="xml" todir="${reports.localDir}/phpunit"/>
<batchtest>
<fileset dir="${repo.root}/tests/phpunit">
<include name="**/*Test*.php"/>
</fileset>
<fileset dir="${blt.root}/tests/phpunit/BltProject"/>
</batchtest>
</phpunit>
<phpunitreport infile="${reports.localDir}/phpunit/testsuites.xml" format="noframes" todir="${reports.localDir}/phpunit" />
<property name="reports.phpunit.file" value="${reports.localDir}/phpunit/phpunit-noframes.html"/>
<echo>PHPUnit Report is available at ${reports.phpunit.file}</echo>
<if>
<or>
<equals arg1="${phpunit.failures}" arg2="true"/>
<equals arg1="${phpunit.errors}" arg2="true"/>
</or>
<then>
<fail message="PHPUnit Failed. See report for details."/>
</then>
</if>
</target>
<!-- Optionally run tests against internal PHP server. -->
<target name="tests:run-server" hidden="true">
<if>
<equals arg1="${behat.run-server}" arg2="true"/>
<then>
<echo message="Using 'drush runserver' for tests." />
<echo message="Running server at ${behat.server-url}"/>
<exec command="pkill -f runserver" logoutput="true" level="${blt.exec_level}" passthru="true"/>
<exec executable="${drush.bin}" dir="${docroot}" spawn="true" level="${blt.exec_level}">
<arg line="runserver ${behat.server-url} -l ${multisite.name}"/>
</exec>
<echo message="Waiting 10 seconds for ${behat.server-url} to become available."/>
<waitfor maxwait="10" maxwaitunit="second" checkevery="1" checkeveryunit="second">
<http url="${behat.server-url}"/>
</waitfor>
</then>
<else>
<echo message="NOT using `drush runserver' for tests." />
</else>
</if>
</target>
<!-- Ensure Drupal doesn't have any modules requiring security updates. -->
<target name="tests:security-updates"
description="Check local Drupal installation for security updates.">
<exec dir="${docroot}"
command="! ${drush.cmd} -n ups --check-disabled --security-only 2>/dev/null | grep 'SECURITY UPDATE'"
checkreturn="true" level="${blt.exec_level}"
logoutput="true"
returnProperty="securityPass"
passthru="true"/>
<!-- Output message on failure. -->
<if>
<not><equals arg1="${securityPass}" arg2="0"/></not>
<then>
<echo>One or more of your dependency has an outstanding security update. Please apply update(s) immediately. Failing build.</echo>
</then>
</if>
</target>
</project>