Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F150984
TestResultsSampeler.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
avivey
May 7 2014, 12:11 AM
2014-05-07 00:11:28 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
TestResultsSampeler.php
View Options
<?php
/**
* Reduces tests results sets for brevity and reducing number of conduit calls needed.
* Ignores coverage data.
*/
final
class
TestResultsSampeler
{
private
$sample_size
=
6
;
private
$extra_test_coverage
=
null
;
private
$extra_test_uri
=
null
;
private
$extra_test_status
=
null
;
private
$extra_test_text
=
''
;
public
function
sampelize
(
$results
)
{
$grouped
=
mgroup
(
$results
,
'getResult'
);
$counts
=
array
();
$sampled
=
array
();
foreach
(
$grouped
as
$status
=>
$tests
)
{
$to_show
=
$status
==
ArcanistUnitTestResult
::
RESULT_PASS
?
0
:
$this
->
sample_size
;
$counts
[
$status
]
=
count
(
$tests
)
-
$to_show
;
$sampled
[
$status
]
=
array_slice
(
$tests
,
0
,
$to_show
);
}
$sampled
=
array_mergev
(
$sampled
);
$text_order
=
array
(
ArcanistUnitTestResult
::
RESULT_BROKEN
,
ArcanistUnitTestResult
::
RESULT_FAIL
,
ArcanistUnitTestResult
::
RESULT_SKIP
,
ArcanistUnitTestResult
::
RESULT_UNSOUND
,
ArcanistUnitTestResult
::
RESULT_POSTPONED
,
ArcanistUnitTestResult
::
RESULT_PASS
);
$extra_text
=
$this
->
extra_test_text
;
$extra_test_status
=
$this
->
extra_test_status
;
foreach
(
$text_order
as
$status
)
{
$count
=
idx
(
$counts
,
$status
,
0
);
if
(
$count
<=
0
)
continue
;
$extra_text
.=
"$count more tests $status. "
;
if
(
$extra_test_status
==
null
)
$extra_test_status
=
$status
;
}
if
(!
$extra_text
)
{
$extra_text
=
'Click for full report.'
;
}
if
(
$extra_test_status
==
null
)
{
$extra_test_status
=
ArcanistUnitTestResult
::
RESULT_PASS
;
}
$extra_test
=
id
(
new
ArcanistUnitTestResult
())
->
setName
(
$extra_text
)
->
setResult
(
$extra_test_status
)
->
setDuration
(
0
)
->
setCoverage
(
$this
->
extra_test_coverage
)
->
setLink
(
$this
->
extra_test_uri
);
return
array
(
'sampled'
=>
$sampled
,
'extra test'
=>
$extra_test
,
);
}
public
function
setExtraTestCoverage
(
$coverage
)
{
$this
->
extra_test_coverage
=
$coverage
;
}
public
function
setExtraTestLink
(
$uri
)
{
$this
->
extra_test_uri
=
$uri
;
}
public
function
setExtraTestStatus
(
$status
)
{
$this
->
extra_test_status
=
$status
;
}
public
function
setExtraTestText
(
$text
)
{
$this
->
extra_test_text
=
$text
;
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/zi/uf/po2edsbsk7c5667e
Default Alt Text
TestResultsSampeler.php (2 KB)
Attached To
Mode
P1134 TestResultsSampeler.php
Attached
Detach File
Event Timeline
Log In to Comment