Age | Commit message (Collapse) | Author |
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1716978
Change-Id: I2fdc020178077e2a94b42d8ae2632ebf86b11100
|
|
This adds support for the cmpopts package, which is required by the new
protobuf API. It also includes the tests so that they get run.
Change-Id: Ib020b6ce4cccc1ec0a60c5d89193ca437ddcc1a6
|
|
Rename the shadowed variable i to j for better readability.
|
|
Address some minor issues flagged by staticcheck.
None of these affect the correctness of the package.
|
|
2edf3ba00c am: 3c08d93f9d am: a627337043
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1719333
Change-Id: Ia13d4112eee5f58866bdbea5cf649c98d1d9c3d5
|
|
2edf3ba00c am: 3c08d93f9d
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1719333
Change-Id: I6565661ee60ce37fecae923fbb4426dc6f54c60c
|
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1719333
Change-Id: Ic5124e94f1a33c104d69d88215ec4a57c2710a76
|
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1719333
Change-Id: Ia25cc737edbc7a47010362473a6286e7bd316b49
|
|
Added SPDX-license-identifier-BSD to:
Android.bp
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: I986cbf13affb6752d52e3002bc01d37e32d3b52c
|
|
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/go-cmp/+/14735751
Change-Id: I1de483b7150dff9a7e8ae08f7c6d3f575130bb41
|
|
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/go-cmp/+/14735751
Change-Id: I0d87e8f8f9a048db2f44898c327049e9b8711896
|
|
Added SPDX-license-identifier-BSD to:
Android.bp
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ia15c0733793a7619c617c746a0c4e24d739d45f5
|
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1712605
Change-Id: Id511fce83de15f590e6102179878a208428bbae4
|
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1327476
Change-Id: I1b0ffa29cd77a579ca4e88366c9a5198bdde5b1d
|
|
Original change: https://android-review.googlesource.com/c/platform/external/go-cmp/+/1327475
Change-Id: I9bb13705cff688a5f4b6ecdf12f2a9a374880b7d
|
|
The previous heuristic of treating strings as binary data
if it contains any invalid UTF-8 was too strict.
Loosen the heuristic to check if most of the characters
are printable text.
Fixes #257
|
|
Avoid diffing by lines if it turns out to be significantly less
efficient than diffing by bytes.
Before this change:
(
"""
- d5c14bdf6bac81c27afc5429500ed750
- 25483503b557c606dad4f144d27ae10b
- 90bdbcdbb6ea7156068e3dcfb7459244
- 978f480a6e3cced51e297fbff9a506b7
+ Xd5c14bdf6bac81c27afc5429500ed750
+ X25483503b557c606dad4f144d27ae10b
+ X90bdbcdbb6ea7156068e3dcfb7459244
+ X978f480a6e3cced51e297fbff9a506b7
"""
)
After this change:
strings.Join({
+ "X",
"d5c14bdf6bac81c27afc5429500ed750\n",
+ "X",
"25483503b557c606dad4f144d27ae10b\n",
+ "X",
"90bdbcdbb6ea7156068e3dcfb7459244\n",
+ "X",
"978f480a6e3cced51e297fbff9a506b7\n",
}, "")
|
|
Even with an optimal diffing algoritm, coalescing adjacent edit groups
may cause the corresponding pair of strings for an edit group to have
leading or trailing spans of equal elements.
While this is technically a correct representation of a diff,
it is a suboptimal outcome. As such, scan through all unequal groups and
move leading/trailing equal spans to the preceding/succeeding equal group.
Before this change:
strings.Join({
"org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=aa",
- ",#=_value _value=2 ",
+ " _value=2 ",
`11 org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=bb`,
- ",#=_value _value=2 2",
+ " _value=2 2",
`1 org-4747474747474747,bucket-4242424242424242:m,tag1=b,tag2=cc`,
- ",#=_value",
` _value=1 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
"=a,tag2",
- "=dd,#=_value",
+ "=dd",
` _value=3 31 org-4747474747474747,bucket-4242424242424242:m,tag1`,
- "=c,#=_value",
+ "=c",
` _value=4 41 `,
}, "")
After this change:
strings.Join({
"org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=aa",
- ",#=_value",
` _value=2 11 org-4747474747474747,bucket-4242424242424242:m,tag1`,
"=a,tag2=bb",
- ",#=_value",
` _value=2 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
"=b,tag2=cc",
- ",#=_value",
` _value=1 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
"=a,tag2=dd",
- ",#=_value",
` _value=3 31 org-4747474747474747,bucket-4242424242424242:m,tag1`,
"=c",
- ",#=_value",
` _value=4 41 `,
}, "")
|
|
Change-Id: Ic01ac28abadcda509aab67e4da9c0e0ea83769f5
|
|
s/seperate/separate/
|
|
FormatDiff should only set the verbosity to 3 if the current verbosity
is lower than 3. Otherwise, it may remove an intended higher verbosity
setting causing the reporter output to not differentiate between
two large values that are different at the end.
While we are at it, increase the maxVerbosityPreset to 6.
|
|
Specialized diffing strings and slices should occur for
interface types where both values have the same concrete type.
This is especially relevant for protocmp.Transform,
which transforms every proto.Message as a map[string]interface{}.
|
|
Add Go 1.16 to the GitHub actions test coverage matrix.
Also switch the gofmt check to only run on Go 1.16, i.e. the latest
supported version.
|
|
Use the standard definition of errors.Is to implement compareErrors with
≥go1.13. Retain the implementation using golang.org/x/xerrors for versions <go1.13.
This will allow packages using newer Go versions and already relying on
the errors package to get rid of the transitive dependency on
golang.org/x/xerrors.
|
|
Map keys should have a sensible verbosity limit imposed,
otherwise the reporter can end up printing a massive data structure
that cannot reasonably fit in memory.
|
|
A previous attempt to add non-determinism to the diffing algorithm
unfortunately broke the algorithm for half the cases.
This change modifies the algorithm to truly switch between starting
with a forward search versus a reverse search.
The main for-loop of Difference would switch repeatedly between
performing a forward search, then a reverse search, and vice-versa.
Since we can't jump into the middle of a for-loop to start with the
reverse search first, we use a series of labels and goto statements
to accomplish the same effect.
Fixes #238
|
|
Use a GitHub action to run test on each push and pull request.
We test across a matrix covering Linux and MacOSX, and Go 1.8 to 1.15.
|
|
The description inaccurately describes the operation of Diff,
which is y - x, where a '+' prefix denotes elements added from y
and a '-' prefix denotes elements removed from x.
For example:
// Consider this call to Diff and its result.
x y
cmp.Diff({b:2, c:3}, {a:1, b:2}) => {+a:1, b:2, -c:3}
// Consider the same in mathematical notation.
y - x
{a:1, b:2} - {b:2, c:3} = {+a:1, b:2, -c:3}
|
|
This reverts commit ab46b8bd0abd4c4557cc4709ad7ae12d47570603.
The upstream change in Go1.16 has been rolled back.
See golang/go#42123
|
|
In Go1.16, the reflect.Type.NumMethod method will no longer report
unexported fields, matching the documented behavior on the method.
This means that t.NumMethod() == 0 is no longer a reliable means
to detect whether an interface type is the empty interface or not.
Fix the code to check whether the empty interface itself implements
the target type.
|
|
Add an example for IgnoreFields. This resuses the test data from the example
in the cmp package to provide consistency between examples.
|
|
There is no LICENSE.md file, but there is a LICENSE file.
|
|
If cmp panics because it is trying to access an unexported field,
specially suggest the use of cmpopts.EquateErrors if the parent type
implements the error interface.
Fixes #233
|
|
|
|
Fix the documentation on Diff. It was mentioning the plus or minus sign being printed if the field was added to y or removed from y, but both are the same. Fix it so that it properly mentions the use of a minus sign for elements removed from x.
|
|
For strings, []bytes containing text data, Error method output, and
String method output, use the triple-quoted syntax.
This improves readability by presenting the data more naturally
compared to a single-line quoted string with many escaped characters.
|
|
Adjust the panic message to be more specific about what the user should do, and reduces the need for the user to look at the source code.
|
|
If a panic occurs while calling String or Error,
the reporter recovers from it and ignores it, proceeding with
its usual functionality for formatting a value.
|
|
Previously, the reporter could handle formatting values with cycles
in that it did not crash with a stack overflow. However, the output
was not particularly understandable as it did not surface to the user
why a particular value was truncated, and if it was truncated due
to a cyclic reference, what was the referent.
This change annotates the reporter tree with pointer information
so that a later pass can inject reference information if it is needed
to produce more understandable output.
Consider the following example:
map[string]*cmp_test.CycleAlpha{
"Foo": &⟪ref#0⟫{
Name: "Foo",
Bravos: map[string]*cmp_test.CycleBravo{
"FooBravo": &{
- ID: 101,
+ ID: 0,
Name: "FooBravo",
Mods: 100,
Alphas: {"Foo": &⟪ref#0⟫(...)},
},
},
},
}
This graph contains a cycle. To ensure that a graph can be formatted,
the cycle is truncated as indicated with: &⟪ref#0⟫(...).
The referent was identified earlier with: &⟪ref#0⟫{...}.
|
|
Provide a unique name for every test case.
Provide a reason for every test case.
The purpose of a unique name is so that insertion/removal of a
case does not cause all subsequent names to suddenly shift,
causing a larger number of differences in testdata/diffs.
|
|
The function now handles unexported fields since #203.
|
|
The reporter tries to aggresively elide data that is not interesting
to the user. However, doing so many result in an output that does not
visually indicate the difference between semantically different objects.
This CL modifies the reporter to try increasingly verbose presets until
two different objects are formatted differently.
This CL includes a custom implementation of reflect.Type.String that
can print the type with fully qualified names to disambiguate types
that happen to have the same base package name.
Fixes #194
|
|
A common complaint is that the reporter it prints out too much
irrelevant information, resulting in a low signal-to-noise ratio.
Improve this metric by imposing a verbosity limit. For nodes that
are equal, we set the verbosity level is a lower value than when
the nodes are inequal.
Other minor changes:
* Adjust heuristic for triple-quote usage to operate on more cases.
* Elide type more aggressively for equal nodes.
* Printing the address for a slice includes the length and capacity.
* The pointed-at value for map keys are printed.
|
|
For large slices, arrays, and maps, the reporter can be unreadable
if there are many differences. Limit the number of results to some
reasonable maximum.
|
|
The reporter output is documented as unstable.
The API for custom reporters also specifies that the diffing of
slices is unstable.
Introduce deliberate instability to the diffing algorithm so that
we have the flexibility to improve it in the future.
The current algorithm optimizes for speed, rather than optimality,
so there is much room for improvement.
|
|
Using strings.Join to denote differences in a multi-line string is
visually noisy due to extensive use of quotes and escape sequences.
Add a custom triple-quote syntax that unambiguously shows line
differences with less visual noise.
If the triple-quote syntax cannot unmabiguously show differences,
then the reporter falls back on using the strings.Join format,
which is never ambiguous.
Fixes #195
|
|
|
|
For correctness, cmp checks applicability of the options for every
element in a slice. For large []byte, this is a significant performance
detriment. The workaround is to specify Comparer(bytes.Equal).
However, we would still like to have the batched diffing if the
slices are different. Specialize for this situation.
|
|
Rather than having a single element on each line,
which hurts readability due to the need for scrolling quite a bit.
Batch multiple elements for simple lists to be on a single line.
Fixes #170
|
|
Specify the exact minimumally supported version of Go required
in order to address certain TODOs. This makes it easier to filter
out inactionable TODOs.
|