summaryrefslogtreecommitdiff
path: root/usr.bin/diff/tests
Commit message (Collapse)AuthorAgeFilesLines
* diff: fix side_by_side after r363679Kyle Evans2020-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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
* diff: restore compatibility with GNU diff regarding -N optionBaptiste Daroussin2020-06-011-0/+11
| | | | | | | | | | | | | 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
* Restore compatibility with GNU diff regarding --labelBaptiste Daroussin2020-06-011-0/+13
| | | | | | | | | | | | | | | | 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
* diff(1): don't reject specifying the same format multiple timesKyle Evans2020-04-281-1/+8
| | | | | | | | | | | | | | | | | | | | | 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
* diff(1): reject conflicting formatting optionsKyle Evans2020-04-201-2/+16
| | | | | | | | | | | | | | | | | | | 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
* diff: fix segfault with --tabsize and no/malformed argumentKyle Evans2020-02-131-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | --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
* diff: implement -y (--side-by-side) along with -W and --suppress-common-linesBaptiste Daroussin2020-02-071-2/+0
| | | | | | | | | PR: 219933 Submitted by: fehmi noyan isi <fnoyanisi@yahoo.com> MFC after: 3 weeks Notes: svn path=/head/; revision=357648
* diff(1): Implement -B/--ignore-blank-linesKyle Evans2018-08-195-0/+28
| | | | | | | | | | | | | | | | 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
* Improve --strip-trailing-cr handling:Xin LI2018-07-271-0/+11
| | | | | | | | | | | | | | | - 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
* DIRDEPS_BUILD: Connect new directories.Bryan Drewery2017-10-311-0/+11
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325187
* Use more flexible expression for replacing t_diff inEnji Cooper2017-07-191-1/+1
| | | | | | | | | | | 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
* Add tests that exercise -q, like -rq and add tests that test -q like -NrqEnji Cooper2017-07-171-2/+15
| | | | | | | | MFC after: 2 months MFC with: r321076, r321077, r321078 Notes: svn path=/head/; revision=321079
* Add some tests for brief (--brief/-q) formatEnji Cooper2017-07-171-0/+19
| | | | | | | | MFC after: 2 months MFC with: r321076 Notes: svn path=/head/; revision=321077
* Add some testcases for `diff --side-by-side` supportEnji Cooper2017-06-121-0/+22
| | | | | | | | | | | | | 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
* Implement a basic --changed-group-formatBaptiste Daroussin2017-04-203-1/+40
| | | | | | | | | | | | | 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
* Add a regression test for diff -DBaptiste Daroussin2017-04-203-1/+37
| | | | Notes: svn path=/head/; revision=317187
* diff: Show nanoseconds in -u/-c header line.Jilles Tjoelker2017-03-263-1/+19
| | | | | | | | | | | | | | | 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
* diff: Fix mtime of file1 in -u/-c header line.Jilles Tjoelker2017-03-263-1/+19
| | | | | | | | | PR: 218018 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10140 Notes: svn path=/head/; revision=315985
* Rename tests from <foo> to <foo>_test to match the FreeBSD test suiteEnji Cooper2017-03-232-3/+4
| | | | | | | | | | | | | 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
* Integrate contrib/netbsd-tests/usr.bin/diff/t_diff.sh in asEnji Cooper2017-03-151-0/+10
| | | | | | | | | | | | | | .../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
* Import diff from OpenBSD and remove GNU diffBaptiste Daroussin2017-03-1117-0/+262
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