Skip to content

Conversation

@sylvestre
Copy link
Contributor

Should fix tests/misc/time-style.sh

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/misc/time-style is no longer failing!

Comment on lines 570 to 573
let mut scenario = new_ucmd!();

// Set a specific date format like in the GNU test
let output = scenario
Copy link
Contributor

Choose a reason for hiding this comment

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

A detail: I would omit the scenario variable as I don't see the benefit of it.

Suggested change
let mut scenario = new_ucmd!();
// Set a specific date format like in the GNU test
let output = scenario
// Set a specific date format like in the GNU test
let output = new_ucmd!()

/// Returns a five line header content if displaying header is not disabled by
/// using `NO_HEADER_TRAILER_OPTION` option.
fn header_content(options: &OutputOptions, page: usize) -> Vec<String> {
if options.display_header_and_trailer {
Copy link
Contributor

Choose a reason for hiding this comment

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

As you are rewriting this function anyway, it might make sense to do an early return if no header should be shown. It would allow you to get rid of an indentation level for the rest of the function.

let filename_len = filename.chars().count();
let page_len = page_part.chars().count();

let first_line = if date_len + filename_len + page_len + 2 < total_width {
Copy link
Contributor

Choose a reason for hiding this comment

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

first_line is misleading as it is the third line in the header. Maybe header_line, like in the test, would be a better name?

Comment on lines 1171 to 1176
let first_line = if date_len + filename_len + page_len + 2 < total_width {
// Check if we're using a custom date format that needs centered alignment
// This preserves backward compatibility while fixing the GNU time-style test
let needs_centering = date_part.starts_with('+');

if needs_centering {
Copy link
Contributor

@cakebaker cakebaker Nov 13, 2025

Choose a reason for hiding this comment

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

I would combine the two conditions. And either use

let first_line = if date_len + filename_len + page_len + 2 < total_width && date_part.starts_with('+') {

or use vars:

let first_line = {
    let fits = date_len + filename_len + page_len + 2 < total_width;
    let needs_centering = fits && date_part.starts_with('+');

It allows you to get rid of one of the (duplicate) else cases.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #9252 will degrade performances by 2.64%

Comparing sylvestre:pr-fix (fa82066) with main (ceeacf4)

Summary

❌ 1 regression
✅ 122 untouched
⏩ 5 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
du_wide_tree[(5000, 500)] 11.2 ms 11.5 ms -2.64%

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

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

@cakebaker cakebaker merged commit 49f82da into uutils:main Nov 14, 2025
165 of 167 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/misc/time-style is no longer failing!

Great, kudos!

@sylvestre sylvestre deleted the pr-fix branch November 14, 2025 09:04
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