summaryrefslogtreecommitdiff
path: root/usr.bin/diff/tests
AgeCommit message (Collapse)Author
2025-06-20diff: Detect loops when diffing directories.Dag-Erling Smørgrav
Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50936
2024-07-15Remove residual blank line at start of MakefileWarner Losh
This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
2024-05-20diff: Nits in tests.Dag-Erling Smørgrav
Sponsored by: Klara, Inc.
2024-05-17diff: honour -B flag with -qEd Maste
PR: 278988 Reviewed by: bapt Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45220
2024-03-27diff: Integrate libdiff from OpenBSD GoT.Dag-Erling Smørgrav
This adds support for two new diff algorithms, Myers diff and Patience diff. These algorithms perform a different form of search compared to the classic Stone algorithm and support escapes when worst case scenarios are encountered. Add the -A flag to allow selection of the algorithm, but default to using the new Myers diff implementation. The libdiff implementation currently only supports a subset of input and output options supported by diff. When these options are used, but the algorithm is not selected, automatically fallback to the classic Stone algorithm until support for these modes can be added. Based on work originally done by thj@ with contributions from kevans@. Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D44302
2023-08-16Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2022-12-13diff: fix side-by-side output with tabbed inputKyle Evans
The previous logic conflated some things... in this block: - j: input characters rendered so far - nc: number of characters in the line - col: columns rendered so far - hw: column width ((h)ard (w)idth?) Comparing j to hw or col to nc are naturally wrong, as col and hw are limits on their respective counters and nc is already brought down to hw if the input line should be truncated to start with. Right now, we end up easily truncating lines with tabs in them as we count each tab for $tabwidth lines in the input line, but we really should only be accounting for them in the column count. The problem is most easily demonstrated by the two input files added for the tests, the two tabbed lines lose at least a word or two even though there's plenty of space left in the row for each side. Reviewed by: bapt, pstef Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D37676
2022-04-18diff: tests: loosen up requirements for report_identicalKyle Evans
This test cannot run without an unprivileged_user being specified anyways, so just run as the unprivileged user. Revoking read permisions works just as well if you're guaranteed non-root. Reviewed by: pstef Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34950
2022-03-02Revert "Temporarily skip usr.bin.diff.diff_test.functionname in CI"Li-Wen Hsu
This reverts commit 85eeb6ea62d45c5df893a16b87969bd7313a3dbb. The issue has been fixed by 4be7d087c2b566f4910683836be279d55c1a81c6. PR: 262086
2022-02-21Temporarily skip usr.bin.diff.diff_test.functionname in CILi-Wen Hsu
PR: 262086 Sponsored by: The FreeBSD Foundation
2022-02-18diff: fix failed compare when ignoring file caseTom Jones
With --ignore-file-name-case we need to compare files regardless of case. We need to propigate both names down to diffit so we can look up the correct file when the names differ based on case, otherwise we try to look up the file using the case from the a tree which might not be discoverable if its case is different in the b tree. Reviewed by: bapt Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D34201
2022-02-18Remove surplus check for which diff is being testedTom Jones
Must have left this when I was testing the test invocation for 8f79bd9b85716c495c2741ac25db37e8d71f22f7 Pointy hat: thj Sponsored by: Klara Inc.
2022-02-18diff: add --no-dereference flagTom Jones
When diffing files and directories, don't follow symbolic links, instead compare where the links point to. Reviewed by: bapt Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D34203
2022-02-18diff: Detect Objective-C methodsTom Jones
When searching back for function definitions, consider lines starting with '+' and '-', this allows us to pick up Objective-C methods as well as C style function definitions. Reviewed by: bapt Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D34202
2021-08-23diff: read whole files to determine if they are ASCII textPiotr Pawel Stefaniak
Before this change, only the first BUFSIZE bytes were checked. Reviewed by: bapt (previous version) Differential Revision: https://reviews.freebsd.org/D31639
2021-08-23diff: don't output carriage returns that were stripped on inputPiotr Pawel Stefaniak
--strip-trailing-cr worked as intended for comparison between files, but the characters were still present in final output.
2021-06-21diff tests: Require root for report_identicalMark Johnston
This test switches users and either hangs or fails when run as an unprivileged user. MFC after: 1 week Sponsored by: The FreeBSD Foundation
2021-02-03diff: Use unprivileged_user with report_identical testOlivier Cochard
Approved by: bapt Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28466
2021-01-27diff: add a test case about the non regular file supportBaptiste Daroussin
2021-01-25diff: add a test case for failed -s optionBaptiste Daroussin
2021-01-09diff: honour flags with -qEd Maste
Previously -q (just print a line when files differ) ignored flags like -w (ignore whitespace). Avoid the D_BRIEF short-circuit when flags are in effect. PR: 252515 Reported by: Scott Aitken Reviewed by: kevans MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28064
2020-07-30diff: fix side_by_side after r363679Kyle Evans
It's currently unclear to me how this could have worked previously; \n here is not a literal newline but actual '\' 'n', and was getting passed to the underlying regex engine as such. regex(3) does not translate this to a newline, and this became an error because we don't really allow escaping of arbitrary ordinary characters anymore. Run the pattern strings through printf to make sure we're dealing with real newlines before passing them through to atf_check, which ultimately feeds them directly to regcomp(3). This fix is different than that will be needed for sed, in that this is the proper way to inject newlines into search strings as long as regex(3) won't combine \ + n as folks might expect. Reported by: Jenkins via lwhsu MFC after: 1 week Notes: svn path=/head/; revision=363692
2020-06-01diff: restore compatibility with GNU diff regarding -N optionBaptiste Daroussin
When -N is used the missing files are treated as empty. PR: 233402 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Roman Neuhauser <roman@sigpipe.cz> MFC after: 3 days Differential Revision: D25081 Notes: svn path=/head/; revision=361689
2020-06-01Restore compatibility with GNU diff regarding --labelBaptiste Daroussin
Various options to "diff(1)" show filenames, and traditionally make use of the "--label" parameter, if set. Restore this behaviour in BSD diff. While here add a regression test PR: 244533 Submitted by: Jamie Landeg-Jones <jamie@catflap.org> MFC after: 3 days Notes: svn path=/head/; revision=361688
2020-04-28diff(1): don't reject specifying the same format multiple timesKyle Evans
This may happen, for instance, if one happens to have an alias of diff to diff -up and attempts to specify the amount of context on top of that. Aliases like this may cause other problems, but if they're really not ever generating non-unified diffs then we should at least not break that use-case. In addition, we'll now pick up a format mismatch if -p is specified with !contextual && !unified && !unset. Fix up a small trailing whitespace nit in the tests while we're here, and add tests to make sure that we can double up all the formatting options. Reported by: jbeich MFC after: 3 days Notes: svn path=/head/; revision=360437
2020-04-20diff(1): reject conflicting formatting optionsKyle Evans
This matches GNU diff(1) behavior and, more importantly, eliminates any source of confusion if multiple formatting options are specified. Note that the committed diff differs slightly from the submitted: I've modified it so that we initialize diff_format to something that isn't an accepted format option so that we can also reject --normal -c and -c --normal, which would've otherwise been accepted because the default was --normal. After option parsing we default it to D_NORMAL if it's still unset. PR: 243975 Submitted by: fehmi noyan isi MFC after: 1 week Notes: svn path=/head/; revision=360125
2020-02-13diff: fix segfault with --tabsize and no/malformed argumentKyle Evans
--tabsize was previously listed as optional_argument, but didn't account for the optionality of it in the argument handling. This is irrelevant -- the manpage doesn't indicate that the argument is optional, and indeed there's no clear interpretation of omitting the argument because there's no other side effect of --tabsize. The "malformed" argument part of the header on this message is simply referring to usage like this: % diff --tabsize 4 A B With an optional_argument, the argument must be attached to the parameter directly (e.g. --tabsize=4), so the argument is effectively NULL with the above invocation as if no argument had been passed. PR: 243974 Submitted by: fehmi noyan isi <fnoyanisi yahoo com> (diff.c portion) MFC after: 3 days Notes: svn path=/head/; revision=357875
2020-02-07diff: implement -y (--side-by-side) along with -W and --suppress-common-linesBaptiste Daroussin
PR: 219933 Submitted by: fehmi noyan isi <fnoyanisi@yahoo.com> MFC after: 3 weeks Notes: svn path=/head/; revision=357648
2018-08-19diff(1): Implement -B/--ignore-blank-linesKyle Evans
As noted by cem in r338035, coccinelle invokes diff(1) with the -B flag. This was not previously implemented here, so one was forced to create a link for GNU diff to /usr/local/bin/diff Implement the -B flag and add some primitive tests for it. It is implemented in the same fashion that -I is implemented; each chunk's lines are scanned, and if a non-blank line is encountered then the chunk will be output. Otherwise, it's skipped. MFC after: 2 weeks Notes: svn path=/head/; revision=338039
2018-07-27Improve --strip-trailing-cr handling:Xin LI
- Advance ctold for f1 and ctnew for f2 - ungetc() if the character is unexpected - Don't break early when we hit the combination on one side PR: 230049 Reported by: maskray <emacsray gmail com> Reviewed by: bapt, maskray MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16451 Notes: svn path=/head/; revision=336754
2017-10-31DIRDEPS_BUILD: Connect new directories.Bryan Drewery
Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325187
2017-07-19Use more flexible expression for replacing t_diff inEnji Cooper
contrib/netbsd-tests/usr.bin/diff/t_diff.sh with the name of the script via `basename $0`. This was a change I forgot to port over from ^/head/gnu/usr.bin/diff/tests/Makefile@r272787. Notes: svn path=/head/; revision=321227
2017-07-17Add tests that exercise -q, like -rq and add tests that test -q like -NrqEnji Cooper
MFC after: 2 months MFC with: r321076, r321077, r321078 Notes: svn path=/head/; revision=321079
2017-07-17Add some tests for brief (--brief/-q) formatEnji Cooper
MFC after: 2 months MFC with: r321076 Notes: svn path=/head/; revision=321077
2017-06-12Add some testcases for `diff --side-by-side` supportEnji Cooper
These are were created proactively, in anticipation of the support being fully implemented sometime in the future. The tests currently fail on ^/head@r319845, however. Expect them to fail. PR: 219933 Tested with: gdiff Notes: svn path=/head/; revision=319847
2017-04-20Implement a basic --changed-group-formatBaptiste Daroussin
etcupdate(8) requires that option, while GNU diff supports many more variation of that options, their behaviour beside the simple verion implemented here are quite inconsistent as such I do not plan to implement those. The only special keyword supported by this implementation are: %< and %> %= is not implemented as the documentation of GNU diff says: common lines, but it actually when tested print the changes from the first file Notes: svn path=/head/; revision=317194
2017-04-20Add a regression test for diff -DBaptiste Daroussin
Notes: svn path=/head/; revision=317187
2017-03-26diff: Show nanoseconds in -u/-c header line.Jilles Tjoelker
Show nanoseconds in the -u/-c header line. The present portability conditionals cannot handle the POSIX standard st_mtim, so remove them and unconditionally use st_mtim. PR: 218018 Reported by: jbeich Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10145 Notes: svn path=/head/; revision=316002
2017-03-26diff: Fix mtime of file1 in -u/-c header line.Jilles Tjoelker
PR: 218018 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10140 Notes: svn path=/head/; revision=315985
2017-03-23Rename tests from <foo> to <foo>_test to match the FreeBSD test suiteEnji Cooper
naming scheme usr.bin/diff/diff_test was renamed to usr.bin/diff/netbsd_diff_test to avoid collisions with the renamed FreeBSD test. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315776
2017-03-15Integrate contrib/netbsd-tests/usr.bin/diff/t_diff.sh in asEnji Cooper
.../usr.bin/diff/diff_test Some minor adjustment needed to be done for :same as it currently has the test script hardcoded into the test, instead of using an idiom like $(dirname $0) MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315293
2017-03-11Import diff from OpenBSD and remove GNU diffBaptiste Daroussin
Some of the modifications from the previous summer of code has been integrated Modification for compatibility with GNU diff output has been added Main difference with OpenBSD: Implement multiple GNU diff options: * --ignore-file-name-case * --no-ignore-file-name-case * --normal * --tabsize * --strip-trailing-cr Make diff -p compatible with GNU diff Implement diff -l Make diff -r compatible with GNU diff Capsicumize diffing 2 regular files Add a simple test suite Approved by: AsiaBSDcon devsummit Obtained from: OpenBSD, GSoC Relnotes: yes Notes: svn path=/head/; revision=315051