Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F595695
CustomTestEngine.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
joshuaspence
Jul 7 2015, 1:31 PM
2015-07-07 13:31:31 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
CustomTestEngine.php
View Options
<?php
/**
* A custom unit test engine for Arcanist.
*
* This unit test engine provides a mechanism for combining multiple Arcanist
* unit test engines into a single "proxy" engine. This give us a much greater
* level of control over the behavior of `arc unit` until
* [[https://secure.phabricator.com/T5568 | T5568: Support `.arcunit`, similar
* to `.arclint`]] is resolved upstream.
*/
final
class
CustomTestEngine
extends
ArcanistUnitTestEngine
{
protected
function
supportsRunAllTests
()
{
return
true
;
}
public
function
run
()
{
$paths
=
$this
->
getPaths
();
// If we are running with `--everything` then `$paths` will be `null`.
if
(!
$paths
)
{
$paths
=
array
();
}
$engines
=
array
();
$results
=
array
();
$exceptions
=
array
();
$engines
[]
=
$this
->
getPhpunitEngine
(
preg_grep
(
'(some_regex)'
,
$paths
));
$engines
[]
=
$this
->
getPhutilEngine
(
preg_grep
(
'(some_regex)'
,
$paths
));
foreach
(
$engines
as
$engine
)
{
$engine
->
setWorkingCopy
(
$this
->
getWorkingCopy
())
->
setEnableAsyncTests
(
$this
->
getEnableAsyncTests
())
->
setEnableCoverage
(
$this
->
getEnableCoverage
());
if
(
$engine
->
supportsRunAllTests
())
{
$engine
->
setRunAllTests
(
$this
->
getRunAllTests
());
}
try
{
$results
[]
=
$engine
->
run
();
}
catch
(
ArcanistNoEffectException
$ex
)
{
$exceptions
[]
=
$ex
;
}
}
if
(!
$results
)
{
// If all engines throw an `ArcanistNoEffectException`, then we should
// preserve this behavior.
throw
new
ArcanistNoEffectException
(
pht
(
'No tests to run.'
));
}
return
array_mergev
(
$results
);
}
private
function
getPhpunitEngine
(
array
$paths
)
{
return
id
(
new
CustomPhpunitTestEngine
())
->
setConfigurationManager
(
$configuration_manager
)
->
setPaths
(
$paths
);
}
private
function
getPhutilEngine
(
array
$paths
)
{
return
id
(
new
PhutilUnitTestEngine
())
->
setConfigurationManager
(
$this
->
getConfigurationManager
())
->
setPaths
(
$paths
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/7i/ad/zi4owu4cwr6rbeng
Default Alt Text
CustomTestEngine.php (1 KB)
Attached To
Mode
P1818 CustomTestEngine.php
Attached
Detach File
Event Timeline
Log In to Comment