-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ls: add -T support and fix --classify output #7616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0c766c4
add -T option parsing
emar-kar 4a233a7
add usage of tab_size in display_grid
emar-kar 1c19599
fix test_ls_columns with \t
emar-kar 2a202e7
update test_tabsize_formatting
emar-kar 35eb82b
use grid DEFAULT_SEPARATOR_SIZE
emar-kar 48ca8ba
update Tabs
emar-kar e6e76e2
fix test with column width
emar-kar 8b9af95
fix cspell
emar-kar c222dc4
fix linter warning on match bool
emar-kar b4fe319
add comment for 0 tab_size
emar-kar 548c4ea
update tabsize test with -C
emar-kar 17ab4cd
update one of the tabs tests to use -x
emar-kar 471144c
remove comment and split tests for both x/C args
emar-kar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -837,7 +837,7 @@ fn test_ls_columns() { | |
|
||
for option in COLUMN_ARGS { | ||
let result = scene.ucmd().arg(option).succeeds(); | ||
result.stdout_only("test-columns-1 test-columns-2 test-columns-3 test-columns-4\n"); | ||
result.stdout_only("test-columns-1\ttest-columns-2\ttest-columns-3\ttest-columns-4\n"); | ||
} | ||
|
||
for option in COLUMN_ARGS { | ||
|
@@ -846,7 +846,7 @@ fn test_ls_columns() { | |
.arg("-w=40") | ||
.arg(option) | ||
.succeeds() | ||
.stdout_only("test-columns-1 test-columns-3\ntest-columns-2 test-columns-4\n"); | ||
.stdout_only("test-columns-1\ttest-columns-3\ntest-columns-2\ttest-columns-4\n"); | ||
} | ||
|
||
// On windows we are always able to get the terminal size, so we can't simulate falling back to the | ||
|
@@ -859,15 +859,15 @@ fn test_ls_columns() { | |
.env("COLUMNS", "40") | ||
.arg(option) | ||
.succeeds() | ||
.stdout_only("test-columns-1 test-columns-3\ntest-columns-2 test-columns-4\n"); | ||
.stdout_only("test-columns-1\ttest-columns-3\ntest-columns-2\ttest-columns-4\n"); | ||
} | ||
|
||
scene | ||
.ucmd() | ||
.env("COLUMNS", "garbage") | ||
.arg("-C") | ||
.succeeds() | ||
.stdout_is("test-columns-1 test-columns-2 test-columns-3 test-columns-4\n") | ||
.stdout_is("test-columns-1\ttest-columns-2\ttest-columns-3\ttest-columns-4\n") | ||
.stderr_is("ls: ignoring invalid width in environment variable COLUMNS: 'garbage'\n"); | ||
} | ||
scene | ||
|
@@ -4366,28 +4366,52 @@ fn test_tabsize_option() { | |
scene.ucmd().arg("-T").fails(); | ||
} | ||
|
||
#[ignore = "issue #3624"] | ||
#[test] | ||
fn test_tabsize_formatting() { | ||
let (at, mut ucmd) = at_and_ucmd!(); | ||
let scene = TestScenario::new(util_name!()); | ||
let at = &scene.fixtures; | ||
|
||
at.touch("aaaaaaaa"); | ||
at.touch("bbbb"); | ||
at.touch("cccc"); | ||
at.touch("dddddddd"); | ||
|
||
ucmd.args(&["-T", "4"]) | ||
scene | ||
.ucmd() | ||
.args(&["-x", "-w18", "-T4"]) | ||
.succeeds() | ||
.stdout_is("aaaaaaaa bbbb\ncccc\t dddddddd"); | ||
.stdout_is("aaaaaaaa bbbb\ncccc\t dddddddd\n"); | ||
|
||
ucmd.args(&["-T", "2"]) | ||
scene | ||
.ucmd() | ||
.args(&["-C", "-w18", "-T4"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should test both |
||
.succeeds() | ||
.stdout_is("aaaaaaaa cccc\nbbbb\t dddddddd\n"); | ||
|
||
scene | ||
.ucmd() | ||
.args(&["-x", "-w18", "-T2"]) | ||
.succeeds() | ||
.stdout_is("aaaaaaaa bbbb\ncccc\t\t dddddddd"); | ||
.stdout_is("aaaaaaaa\tbbbb\ncccc\t\t\tdddddddd\n"); | ||
|
||
scene | ||
.ucmd() | ||
.args(&["-C", "-w18", "-T2"]) | ||
.succeeds() | ||
.stdout_is("aaaaaaaa\tcccc\nbbbb\t\t\tdddddddd\n"); | ||
|
||
scene | ||
.ucmd() | ||
.args(&["-x", "-w18", "-T0"]) | ||
.succeeds() | ||
.stdout_is("aaaaaaaa bbbb\ncccc dddddddd\n"); | ||
|
||
// use spaces | ||
ucmd.args(&["-T", "0"]) | ||
scene | ||
.ucmd() | ||
.args(&["-C", "-w18", "-T0"]) | ||
.succeeds() | ||
.stdout_is("aaaaaaaa bbbb\ncccc dddddddd"); | ||
.stdout_is("aaaaaaaa cccc\nbbbb dddddddd\n"); | ||
} | ||
|
||
#[cfg(any( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you left this in as an optimization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since -T0 literally means no
\t
I thought it's gonna be a good idea to add this small check here to omit additional work in gridThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add that as a comment to the code?