101 Commits

Author SHA1 Message Date
Jim Meyering
cc41598038 tests: avoid large-subopt XPASS on systems without perl
* tests/large-subopt: Use $PERL, rather than hard-coding "perl".
* bootstrap.conf (gnulib_modules): Add "perl" to the list.
Reported by Bruno Haible in
https://lists.gnu.org/r/diffutils-devel/2023-01/msg00000.html
2023-01-05 22:44:07 -08:00
Bruno Haible
f5f2a237b2 tests: avoid a test failure when using Solaris 11.4's old grep
* tests/colors (nanosecond_zeros): Use a dumbed-down grep '\.'
in place of "grep -F ." to accommodate Solaris 11.4's old versions
of grep in the default PATH. Reported here:
https://lists.gnu.org/r/diffutils-devel/2023-01/msg00001.html
2023-01-05 22:13:47 -08:00
Jim Meyering
47a1f46f08 maint: update copyright dates 2023-01-01 17:19:37 -08:00
Jim Meyering
231f879462 tests: fix false-failure on systems without valgrind
* tests/init.cfg (require_valgrind_): Use exit status of subshell,
not that of the "local" declaration.
2022-01-24 17:31:06 +01:00
Jim Meyering
aec523d3a4 maint: make update-copyright 2022-01-03 11:49:11 -08:00
Jim Meyering
dabf2c747d build: update gnulib to latest; also bootstrap and init.sh 2022-01-03 11:45:59 -08:00
Paul Eggert
074cbe590b diff: fix timezone bug on Solaris
Problem reported by Vladimir Marek (bug#51228).
* NEWS: Mention this.
* src/context.c (print_context_label): Pass localtz to nstrftime,
instead of always passing 0.
* src/diff.c (main) [!HAVE_TM_GMTOFF]:
Initialize localtz if time_format uses %z.
* src/diff.h (localtz): New decl.
* tests/Makefile.am (TESTS): Add timezone.
* tests/timezone: New test.
2021-10-15 18:54:49 -07:00
Paul Eggert
a3188d9e98 tests: port to valgrind 3.16.0 + GCC 11.2
* tests/init.cfg (stderr_fileno_): Reject valgrind if it reports a
"Serious error" on a trival use of ‘diff’.  Without this patch, on
RHEL 8.4 when I compile diffutils with a GCC 11.2.0 that I built
myself, ‘valgrind diff’ spits out messages like WARNING: Serious
error when reading debug info / When reading debug info from diff:
Ignoring non-Dwarf2/3/4 block in .debug_info’ and this causes the
strip-trailing-cr test to fail.  I guess valgrind complains
because the valgrind version 3.16.0 that came with RHEL 8.4 cannot
grok the debug entries generated by GCC 11.2.0.
2021-08-01 23:05:12 -07:00
Jim Meyering
22fb055cca maint: update all copyright year number ranges
Run "make update-copyright" and then...
* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
2021-01-01 17:37:49 -08:00
Jim Meyering
351f87d0c4 maint: update all copyright year number ranges
Run "make update-copyright" and then...
* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
2020-01-01 09:33:03 -08:00
Jim Meyering
98f55d7bf2 build: update gnulib to latest
* gnulib: Update submodule to latest.
* bootstrap: Copy from gnulib.
* tests/init.sh: Likewise.
2019-12-23 12:15:37 -08:00
Dave Odell
ee869b17b1 cmp: add test case for Bug#37558
* tests/cmp: New test case (Bug#37558).
Copyright-paperwork-exempt: yes
2019-10-01 11:15:38 -07:00
KO Myung-Hun
1d19852975 tests: init.cfg: use $PATH_SEPARATOR not ':'
On OS/2, a path separator is semi-colon ';' not colon ':'.
* tests/init.cfg: Replace ':' with $PATH_SEPARATOR.
2019-05-24 13:36:51 -07:00
Paul Eggert
2c9d956aac diff: remove unportable ‘diff -N - f <&-’ feature
* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add stdopen.
* doc/diffutils.texi (Comparing Directories):
Do not document behavior if stdin is closed.
* src/diff.c: Include stdopen.h.
(main): Call stdopen early.
(compare_files) [__hpux]: Remove recently-introduced
special case for HP-UX exec with stdin closed.
* tests/new-file: Remove tests of the removed feature.
2019-01-05 19:20:36 -08:00
Jim Meyering
197d7d492f maint: update all copyright dates via "make update-copyright"
* gnulib: Also update submodule for its copyright updates.
2019-01-01 19:02:28 -08:00
Jim Meyering
04c64737c5 maint: distribute new file, init.cfg
Otherwise, strip-trailing-cr would fail on a system without valgrind.
* tests/Makefile.am (EXTRA_DIST): Include init.cfg.
2018-12-31 17:56:23 -08:00
Dennis Lambe Jr
aaf0efa70d diff: adjust ANSI escapes for compatibility with less -R
GNU less can display ANSI-colored text with the -R flag, but this
support has some limitations. One of them is that if an escape
sequence starts on one line and ends on a different line, only the
first line will be colored in less.

As a result, when diff creates colored output with multi-line deletes
or adds, less will only color the first line.

This change resets ANSI color to the default at the end of
each line and restarts it at the beginning of the next. It patches
normal and context mode. Side-by-side already worked in my testing.
* src/context.c (print_context_label, pr_context_hunk): As above.
(pr_unidiff_hunk, print_context_header): Likewise.
* src/normal.c (print_normal_hunk): Likewise.
* tests/colors: Adjust existing tests to accommodate this.
* NEWS (Improvements): Mention it.
Proposed in http://bugs.gnu.org/31105
2018-12-30 22:22:10 -08:00
Jim Meyering
b9e2f4f3b3 tests: fix colors test on systems lacking fractional timestamp support
* tests/colors: The .NNNNNNNNN suffix is not printed on some systems.
Adapt the test to accommodate those systems.
2018-12-29 12:18:31 -08:00
Jim Meyering
b33a919934 tests: strip-trailing-cr: avoid failure with ASAN
Valgrind cannot operate on an ASAN-compiled binary.
* tests/strip-trailing-cr (valgrind): Define as no-op when diff
was compiled with sanitizer support.
2018-12-29 08:14:03 -08:00
Jim Meyering
c7a4eacac9 tests: add test for --strip-trailing-cr UMR bug
* tests/strip-trailing-cr: New file. Test for today's bug fix.
* tests/Makefile.am (TESTS): Add it.
2018-12-28 20:54:08 -08:00
Jim Meyering
a28327bd77 tests: import test infrastructure from coreutils
* tests/init.cfg: New file, for require_valgrind_ definition (from coreutils).
* tests/Makefile.am (PATH): Don't set stderr_fileno_ here, since it is
now initialized in init.cfg.
2018-12-28 20:35:35 -08:00
Bruno Haible
15668f2c54 tests: colors: avoid test failure on AIX 7
* tests/colors: Splice the argument into the printf format string.
2018-12-28 09:02:07 -08:00
Jim Meyering
93a1e963e1 build: update gnulib to latest; and bootstrap and init.sh 2018-12-23 17:24:49 -08:00
Paul Eggert
ffd63aedad cmp: fix bug in -b diagnostic
Problem reported by mancha (Bug#32249).
* src/cmp.c (count_newlines): Restore old value of sentinel.
* tests/cmp: Test for the bug.
2018-07-24 10:18:54 -07:00
Jim Meyering
5dc851ad24 tests: fix quoting error in previous change
* tests/colors: Double-quote $PATH.
2018-01-14 17:16:50 -08:00
Jim Meyering
915003de19 tests: port tests/colors to some env-munging shell
* tests/colors: Also set PATH="$PATH" in env invocation.
2018-01-06 21:20:48 -08:00
Jim Meyering
4a38f715f1 maint: update gnulib and copyright dates for 2018
* gnulib: Update to latest.
* all files: Run "make update-copyright".
* bootstrap: Update from gnulib.
2018-01-06 16:51:19 -08:00
Jim Meyering
b50ab11f23 tests: add expected-failing test for minor subopimality
In some unusual cases, diff -u prints suboptimal output.
* tests/large-subopt: New test script.
* tests/Makefile.am (TESTS): Add it.
(XFAIL_TESTS): Add it here, too, to record that this test is
currently expected to fail.
* tests/large-subopt.in1, tests/large-subopt.in2: Inputs derived from
those in http://bugs.gnu.org/28796
2017-10-22 13:03:58 -07:00
Jim Meyering
20b31314c3 tests: new-file: closed-stdin: also ensure stdout was empty
* tests/new-file: Also require that "out" be empty.
2017-05-09 11:55:46 -07:00
Paul Eggert
ac05c6d549 cmp: improve EOF diagnostic
This improves on yesterday's change, following up on a
remark by Jim Meyering (Bug#22816#21).
* doc/diffutils.texi (Invoking cmp, cmp Options): Follow POSIX more
closely in the documentation of the information appended to the EOF
diagnostic.
* src/cmp.c (cmp): Be more specific about the shorter file's length
and fix some off-by-1 issues in reporting line counts.
* tests/cmp: Adjust to match new behavior.
Don't assume internal details about stdio buffering.
2017-05-05 07:57:05 -07:00
Paul Eggert
1b1526b4f5 cmp: report prefix length when one file is shorter
Requested by Dan Jacobson (Bug#22816).
* NEWS:
* doc/diffutils.texi (Invoking cmp, cmp Options): Document this.
* src/cmp.c (cmp): Implement it.
* tests/Makefile.am (TESTS): Add cmp.
* tests/cmp: New file.
2017-05-04 17:54:46 -07:00
Jim Meyering
4e40686e23 tests: add test for latest fix
* NEWS (Bug fixes): Describe it.
* tests/invalid-re: New test for just-fixed bug.
* tests/Makefile.am (TESTS): Add it.
2017-05-02 20:00:50 -07:00
julama
7c636563c2 tests: avoid false failure for unreadable /proc/cmdline
* tests/brief-vs-stat-zero-kernel-lies: Use "test -r" rather than
just "test -f".  This avoids a false test failure on a linux system
with grsecurity and its GRKERNSEC_PROC_USER option enabled, for which
/proc/cmdline is unreadable.  Reported in https://bugs.gnu.org/26155
2017-03-24 12:43:18 -07:00
Jim Meyering
198c55a645 tests: avoid false failure with some shells on debian, freebsd
* tests/colors: Move the TERM=dumb setting into the code run by
"returns_", since some shells do not propagate envvar setting through
to a use of a function like this.  That would cause this test to fail
because results were colorized when they should not have been.
Reported by Nelson Beebe.
2017-02-01 23:06:29 -08:00
Jim Meyering
8420aff7e0 gnulib: update to latest; and update bootstrap and init.sh 2017-01-31 10:45:20 -08:00
Jim Meyering
90106d33ab maint: update gnulib and copyright dates for 2017
* gnulib: Update to latest.
* all files: Run "make update-copyright".
2017-01-01 03:22:44 -08:00
Jim Meyering
a9cc55101c tests: use "returns_" rather than explicit comparison with "$?"
* tests/colors: Use "returns_ 1" rather than testing $? = 1
* tests/basic: Likewise.
* tests/binary: Likewise.
* tests/filename-quoting: Likewise.
* tests/function-line-vs-leading-space: Likewise.
* tests/ignore-matching-lines: Likewise.
* tests/label-vs-func: Likewise.
* tests/new-file: Likewise.
* tests/no-dereference: Likewise.
* tests/no-newline-at-eof: Likewise.
* tests/stdin: Likewise.
2016-11-08 18:28:04 -08:00
Jim Meyering
c61efccd23 tests: diff3: work around missing seq on some systems
* tests/diff3 (seq): Provide a seq replacement function,
since at least AIX, SunOS 5.10, OpenBSD-5.8 lack it.
Reported by Assaf Gordon in https://bugs.gnu.org/24227#8
2016-08-14 22:25:49 -07:00
Jim Meyering
edd942ca27 diff3: fix leaks, for real
* src/diff3.c (struct diff_block)[lint]: Add member, n2.
(free_diff_block, next_to_n2): New functions.
* tests/diff3: Add more test coverage.
2016-08-13 21:56:39 -07:00
Bastian Beischer
1a0df4396e diff3: fix heap use-after-free; add minimal diff3 test coverage
Commit v3.3-42-g3b74a90, "FIXME: src/diff3: plug a leak" added an
invalid use of free, leading to use-after-free in nearly any invocation
of diff3.  Revert that commit.
* NEWS (Bug fixes): Mention it.
* tests/diff3: New file, to add minimal test coverage.
* tests/Makefile.am (TESTS): Add it.
Reported by Bastian Beischer in http://bugs.gnu.org/24210
2016-08-13 21:56:14 -07:00
Jim Meyering
697c1f4fa9 diff: disable colorization for TERM=dumb
* src/diff.c (main): With --color or --color=auto, when TERM is
"dumb", disable colorization.  Suggested by Daniel Colascione.
* NEWS (Bug fixes): Mention it.
* tests/colors: Add a test that would fail without this change,
yet passes with it.
2016-08-08 18:53:32 -07:00
Jim Meyering
91d2340886 tests: tweak built_programs definition
* tests/Makefile.am (built_programs): Adjust to work around what
may be a problem due to interaction between Solaris 10's /bin/sh
and an old version of GNU make. Reported by Dagobert Michelsen
in https https://bugs.gnu.org/24137.
2016-08-06 11:19:07 -07:00
Jim Meyering
38e3a1dd49 tests: skip a /proc/self-dependent test on the Hurd
* tests/brief-vs-stat-zero-kernel-lies: The Hurd's /proc/self
is not useful, so detect that and skip the test that requires it.
Reported by Assaf Gordon in https://debbugs.gnu.org/24121#29
2016-08-02 09:30:06 -07:00
Jim Meyering
df14e616b3 tests/colors: fix portability problem with touch --date
* tests/colors (epoch): Don't use GNU touch's --date=$epoch option.
Use the portable -t 197001010000.00.
Reported by Assaf Gordon in https://debbugs.gnu.org/24121#8
2016-08-01 09:23:03 -07:00
Jim Meyering
b43e6fed25 test: improve test infrastructure
* tests/envvar-check: New file, copied from grep, with the addition
of the EDITOR and GREP_OPTIONS envvar names.
* tests/Makefile.am (EXTRA_DIST): Add it.
(TESTS_ENVIRONMENT): Revamp, to be more like that of grep.
2016-08-01 08:27:32 -07:00
Jim Meyering
55596fcd48 tests: colors: fix a portability problem and work around a shell bug
* tests/colors (e): Fix a portability bug: use printf '\033'
rather than '\e' to generate the required byte sequence, since
for some shells (at least dash 0.5.8), the latter doesn't work.
Work around a shell bug whereby "local tab=$(printf '\t')"
would result in an empty value for "$tab": hoist each "tab"
definition up/out of its function to global scope.
Reported by Assaf Gordon in http://debbugs.gnu.org/24116#8
2016-07-31 17:38:43 -07:00
Jim Meyering
0353af91a0 gnulib: update to latest; and tests/init.sh
* gnulib: Update to latest.
* init.sh: Update from gnulib.
2016-07-23 16:37:40 -07:00
Giuseppe Scrivano
17e2698bcb diff: --color: fix an infinite recursion bug
* src/diff.h (presume_output_tty): New extern variable.
* src/diff.c (PRESUME_OUTPUT_TTY_OPTION): New enum.
(group_format_option): Add '-presume-output-tty'.
(main): Handle PRESUME_OUTPUT_TTY_OPTION.
* src/util.c: New variable `presume_output_tty'.
(check_color_output): Handle presume_output_tty.
(set_color_context): Call process_signals only when color_context is
not RESET_CONTEXT.
* tests/colors: Check that diff doesn't crash when interrupted
in the middle of a color sequence.

Reported by Gisle Vanem in http://debbugs.gnu.org/22067
2016-03-06 12:13:32 -08:00
Jim Meyering
7346a03010 maint: update copyright year, bootstrap, init.sh
Run "make update-copyright" and then...

* gnulib: Update to latest.
* tests/init.sh: Update from gnulib.
* bootstrap: Likewise.
2016-01-01 18:00:08 -08:00
Jim Meyering
a3ea9cd5cb diff --brief no longer mistakenly reports diff. with 0-sized /proc/ files
Normally, it is safe to assume two regular files are different when
their st_size values are different.  However, that assumption may
be invalid if either value is zero, as happens with files on Linux
/proc and /sys file systems. Since skipping this optimization will
usually cost very little (one read syscall, to read zero bytes),
it is fine to accommodate those unusual files.
* src/analyze.c (diff_2_files): Do not assume regular files differ
just because their st_size values differ when one or more is 0.
* src/diff.c (compare_files): Likewise.
* tests/brief-vs-proc-stat-zero: New test.
* tests/Makefile.am: Add it.
* NEWS (Bug fixes): Describe it.
Reported by Stephan Müller in http://debbugs.gnu.org/21942
2015-12-06 11:37:44 -08:00