Skip to content

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Nov 24, 2025

Summary:

Add comprehensive fixture files for sort --debug key annotation output, including locale-specific expectations.
Refactor tests to share a helper and split locale-aware coverage, matching GNU sort’s behavior.
Ensure “no match for key” annotations render identically to the reference shell script.

related
#9127

mattsu2020 and others added 3 commits November 20, 2025 21:22
Replaced direct length checks with filtered counts excluding b'\0' in debug underline
and indentation output to prevent misalignment from embedded NUL characters, which
are often stripped during inspection. Added comprehensive tests for various sort
modes and inputs, including NUL byte scenarios, to verify correct debug annotations.
Split the existing `test_debug_key_annotations` into two tests: one for basic functionality and another for locale-specific behavior to handle conditional execution based on environment variables. Extracted a new helper function `debug_key_annotation_output` to generate debug output, improving test modularity and reducing code duplication. This enhances test coverage for debug key annotations in different numeric locales.
@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

…ut for efficiency

Rework the `number` helper function to use a mutable String buffer with `writeln!` macro
instead of collecting intermediary vectors with `map` and `collect`. This reduces allocations
and improves performance in test output generation, building the numbered output directly
without extra string concatenations.
- Reformatted command-line arguments in test_debug_key_annotations_locale to fit on fewer lines
- Wrapped run_sort calls in debug_key_annotation_output for better code structure
- Minor reordering of output.push_str blocks for consistency and clarity
Replace fixture file reads with inline constants in test functions for
debug key annotations and locale variants. This makes the tests more
self-contained by removing dependencies on external fixture files.
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

// via `tr -d '\0'`) before inspection.
let select = &line[..selection.start];
write!(writer, "{}", " ".repeat(select.len()))?;
let indent = select.iter().filter(|&&c| c != b'\0').count();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please create a function for the filter
something like

fn count_non_null_bytes(bytes: &[u8]) -> usize {
    bytes.iter().filter(|&&c| c != b'\0').count()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Add a helper function `count_non_null_bytes` to count bytes in a slice while ignoring embedded NULs. This improves code reusability and is used in debug underline output to ensure proper alignment by filtering NUL characters that may be present in selection strings. Replaces inline counting logic in two locations within the `Line` implementation.
@github-actions
Copy link

github-actions bot commented Dec 6, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@sylvestre sylvestre merged commit 502f3b1 into uutils:main Dec 24, 2025
127 checks passed
@mattsu2020 mattsu2020 deleted the sort-debug-keys branch December 24, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants