Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22425580
ArcanistBundleTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
ArcanistBundleTestCase.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final
class
ArcanistBundleTestCase
extends
ArcanistPhutilTestCase
{
private
function
loadResource
(
$name
)
{
return
Filesystem
::
readFile
(
$this
->
getResourcePath
(
$name
));
}
private
function
getResourcePath
(
$name
)
{
return
dirname
(
__FILE__
).
'/bundle/'
.
$name
;
}
private
function
loadDiff
(
$old
,
$new
)
{
list
(
$err
,
$stdout
)
=
exec_manual
(
'diff --unified=65535 --label %s --label %s -- %s %s'
,
'file 9999-99-99'
,
'file 9999-99-99'
,
$this
->
getResourcePath
(
$old
),
$this
->
getResourcePath
(
$new
));
$this
->
assertEqual
(
1
,
$err
,
"Expect `diff` to find changes between '{$old}' and '{$new}'."
);
return
$stdout
;
}
private
function
loadOneChangeBundle
(
$old
,
$new
)
{
$diff
=
$this
->
loadDiff
(
$old
,
$new
);
return
ArcanistBundle
::
newFromDiff
(
$diff
);
}
public
function
testTrailingContext
()
{
// Diffs need to generate without extra trailing context, or 'patch' will
// choke on them.
$this
->
assertEqual
(
$this
->
loadResource
(
'trailing-context.diff'
),
$this
->
loadOneChangeBundle
(
'trailing-context.old'
,
'trailing-context.new'
)->
toUnifiedDiff
());
}
public
function
testDisjointHunks
()
{
// Diffs need to generate without overlapping hunks.
$this
->
assertEqual
(
$this
->
loadResource
(
'disjoint-hunks.diff'
),
$this
->
loadOneChangeBundle
(
'disjoint-hunks.old'
,
'disjoint-hunks.new'
)->
toUnifiedDiff
());
}
public
function
testNonlocalTrailingNewline
()
{
// Diffs without changes near the end of the file should not generate a
// bogus, change-free hunk if the file has no trailing newline.
$this
->
assertEqual
(
$this
->
loadResource
(
'trailing-newline.diff'
),
$this
->
loadOneChangeBundle
(
'trailing-newline.old'
,
'trailing-newline.new'
)->
toUnifiedDiff
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 28, 04:24 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1227435
Default Alt Text
ArcanistBundleTestCase.php (2 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline