Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1818
CustomTestEngine.php
Active
Public
Actions
Authored by
joshuaspence
on Jul 7 2015, 1:31 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
Arcanist
Referenced Files
F595695: CustomTestEngine.php
Jul 7 2015, 1:31 PM
2015-07-07 13:31:31 (UTC+0)
Subscribers
None
<?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
);
}
}
Event Timeline
joshuaspence
edited the content of this paste.
(Show Details)
Jul 7 2015, 1:31 PM
2015-07-07 13:31:31 (UTC+0)
joshuaspence
changed the title of this paste from untitled to
CustomTestEngine.php
.
joshuaspence
updated the paste's language from
autodetect
to
autodetect
.
joshuaspence
added a project:
Arcanist
.
Log In to Comment