Skip to content
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

Make some tests more lenient #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/test_buffer.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
}

@test 'ysu - _write_ysu_buffer invalid' {
(( $+commands[tput] )) || skip "tput not found"
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure about this one. I would want the CI/CD pipeline to fail if tput is not installed rather than fail silently.

Copy link
Author

Choose a reason for hiding this comment

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

That's understandable. I can drop the tests: skip tests requiring tput if not present commit if you prefer. I added this because YSU gracefully handles a missing tput.


YSU_MESSAGE_POSITION="invalid"
export _YSU_BUFFER

Expand Down
9 changes: 9 additions & 0 deletions tests/test_you_should_use.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
}

@test 'ysu version exported' {
(( $+commands[git] )) || skip "git not found"
Copy link
Author

@tomodachi94 tomodachi94 Dec 10, 2024

Choose a reason for hiding this comment

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

I elected to use pure Zsh when checking if a command is present to avoid a dependency on which.
This increase performance slightly, and also avoids a dependency on which.

[ -d ".git" ] || skip "not in git repo"

git_version="$(git tag --list | sort | tail -1)"
git tag --list

Expand Down Expand Up @@ -34,6 +37,8 @@
}

@test 'ysu message correct output' {
(( $+commands[tput] )) || skip "tput not found"

unset YSU_MESSAGE_FORMAT
run ysu_message "alias" "ls -l" "ll"

Expand All @@ -46,6 +51,8 @@
}

@test 'ysu message correct output 2' {
(( $+commands[tput] )) || skip "tput not found"

unset YSU_MESSAGE_FORMAT
run ysu_message "foobar" "2>/dev/null" "NE"

Expand All @@ -58,6 +65,8 @@
}

@test 'escapes \ and % correctly' {
(( $+commands[tput] )) || skip "tput not found"

unset YSU_MESSAGE_FORMAT
run ysu_message "alias" "printf '%s\\n'" "pf"

Expand Down