diff options
author | Jim Meyering <meyering@redhat.com> | 2011-08-04 19:31:50 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-08-08 10:12:38 +0200 |
commit | 70555790672b5465b4f4167b85c9015d5be1f2fd (patch) | |
tree | 5b8bd13e7496bb13cb69c6e0a2b2bf9c97cf8a53 /tests/misc/join | |
parent | 005534907cdc7ff0a4c7908631ff596c4b07ba56 (diff) | |
download | coreutils-70555790672b5465b4f4167b85c9015d5be1f2fd.tar.xz |
join: with --check-order print offending file name, line number and data
* src/join (g_names): New global (was main's "names").
(main): Update all uses of "names".
(line_no[2]): New globals.
(get_line): Increment after reading each line.
(check_order): Print the standard "file name:line_no: " prefix
as well as the offending line when reporting disorder.
Here is a sample old/new comparison:
-join: file 1 is not in sorted order
+join: in:4: is not sorted: contents-of-line-4
* tests/misc/join: Change the two affected tests to expect
the new diagnostic.
Add new tests for more coverage: mismatch in file 2,
two diagnostics, zero-length out-of-order line.
* NEWS (Improvements): Mention it.
Suggested by David Gast in http://debbugs.gnu.org/9236
Diffstat (limited to 'tests/misc/join')
-rwxr-xr-x | tests/misc/join | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/misc/join b/tests/misc/join index eae3f18a8..a892a10d2 100755 --- a/tests/misc/join +++ b/tests/misc/join @@ -196,7 +196,29 @@ my @tv = ( # With check, both inputs out of order (in fact, in reverse order) ['chkodr-5', '--check-order', [" b 1\n a 2\n", " b Y\n a Z\n"], "", 1, - "$prog: file 1 is not in sorted order\n"], + "$prog: chkodr-5.1:2: is not sorted: a 2\n"], + +# Similar, but with only file 2 not sorted. +['chkodr-5b', '--check-order', + [" a 2\n b 1\n", " b Y\n a Z\n"], "", 1, + "$prog: chkodr-5b.2:2: is not sorted: a Z\n"], + +# Similar, but with the offending line having length 0 (excluding newline). +['chkodr-5c', '--check-order', + [" a 2\n b 1\n", " b Y\n\n"], "", 1, + "$prog: chkodr-5c.2:2: is not sorted: \n"], + +# Similar, but elicit a warning for each input file (without --check-order). +['chkodr-5d', '', + ["a\nx\n\n", "b\ny\n\n"], "", 1, + "$prog: chkodr-5d.1:3: is not sorted: \n" . + "$prog: chkodr-5d.2:3: is not sorted: \n"], + +# Similar, but make it so each offending line has no newline. +['chkodr-5e', '', + ["a\nx\no", "b\ny\np"], "", 1, + "$prog: chkodr-5e.1:3: is not sorted: o\n" . + "$prog: chkodr-5e.2:3: is not sorted: p\n"], # Without order check, both inputs out of order and some lines # unpairable. This is NOT supported by the GNU extension. All that @@ -229,7 +251,7 @@ my @tv = ( # actual data out-of-order. This join should fail. ['header-3', '--header --check-order', ["ID Name\n2 B\n1 A\n", "ID Color\n2 blue\n"], "ID Name Color\n", 1, - "$prog: file 1 is not in sorted order\n"], + "$prog: header-3.1:3: is not sorted: 1 A\n"], # '--header' with specific output format '-o'. # output header line should respect the requested format |