Skip to content

Commit

Permalink
🚧
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Jul 30, 2024
1 parent c5ad1e5 commit e9799e9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ fn inner_display_grid(
// Maybe skip showing the directory meta now; show its contents later.
if skip_dirs
&& (matches!(meta.file_type, FileType::Directory { .. })
|| (matches!(meta.file_type, FileType::SymLink { is_dir: true })
&& flags.layout != Layout::OneLine))
|| (matches!(meta.file_type, FileType::SymLink { is_dir: true })))
{
continue;
}
Expand Down
16 changes: 0 additions & 16 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,6 @@ fn test_dereference_link_broken_link_output() {
.stdout(predicate::str::starts_with("l????????? ? ? ? ?"));
}

#[cfg(unix)]
#[test]
fn test_show_folder_content_of_symlink() {
let dir = tempdir();
dir.child("target").child("inside").touch().unwrap();
let link = dir.path().join("link");
fs::symlink("target", &link).unwrap();

cmd()
.arg("--ignore-config")
.arg(link)
.assert()
.stdout(predicate::str::starts_with("link").not())
.stdout(predicate::str::starts_with("inside"));
}

#[cfg(unix)]
#[test]
fn test_no_show_folder_content_of_symlink_for_long() {
Expand Down
38 changes: 38 additions & 0 deletions tests/lscompatible.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/// This is tests make sure lsd is compatible with the GNU ls
/// The tests here MUST all pass in every changes
extern crate assert_cmd;
extern crate predicates;

use assert_cmd::prelude::*;
use assert_fs::prelude::*;
use predicates::prelude::*;

Check failure on line 8 in tests/lscompatible.rs

View workflow job for this annotation

GitHub Actions / Style (windows-latest)

unused import: `predicates::prelude::*`

Check warning on line 8 in tests/lscompatible.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, i686-pc-windows-gnu)

unused import: `predicates::prelude::*`

Check warning on line 8 in tests/lscompatible.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unused import: `predicates::prelude::*`

Check warning on line 8 in tests/lscompatible.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, i686-pc-windows-msvc)

unused import: `predicates::prelude::*`

Check warning on line 8 in tests/lscompatible.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-gnu)

unused import: `predicates::prelude::*`
#[cfg(unix)]
use std::os::unix::fs;
use std::process::{Command, Stdio};

fn cmd() -> Command {
Expand Down Expand Up @@ -52,3 +57,36 @@ fn test_pipe_should_use_line() {

assert_eq!(output_ls.stdout, output_lsd.stdout);
}

#[cfg(unix)]
#[test]
fn test_show_folder_content_of_symlink_oneline() {
let dir = tempdir();
dir.child("target").child("inside").touch().unwrap();
let link = dir.path().join("link");
fs::symlink("target", &link).unwrap();

cmd()
.arg("--ignore-config")
.arg("--oneline")
.arg(link)
.assert()
.stdout(predicate::str::starts_with("link").not())
.stdout(predicate::str::starts_with("inside"));
}

#[cfg(unix)]
#[test]
fn test_show_folder_content_of_symlink() {
let dir = tempdir();
dir.child("target").child("inside").touch().unwrap();
let link = dir.path().join("link");
fs::symlink("target", &link).unwrap();

cmd()
.arg("--ignore-config")
.arg(link)
.assert()
.stdout(predicate::str::starts_with("link").not())
.stdout(predicate::str::starts_with("inside"));
}

0 comments on commit e9799e9

Please sign in to comment.