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

Conversation

tomodachi94
Copy link

@tomodachi94 tomodachi94 commented Dec 10, 2024

  • tests: skip tests requiring tput if not present
    • tput appears to be optional for this plugin, so the tests should not fail if we cannot find tput.
  • tests: skip tests requiring git or git repo
    • In some exotic packaging environments like Nixpkgs, we enforce heavy amounts of sandboxing; we do not include git by default in that sandbox.
    • Additionally, in said exotic packaging environments, we should not always assume we are in a Git repository. The Nixpkgs GitHub fetcher functions by downloading a tarball, not the whole Git directory, so the test fails.

This is part of my work to run unit tests in the Nixpkgs zsh-you-should-use package, so that potential breakages are caught early.

tput appears to be optional for this plugin, so
the tests should not fail if we cannot find tput.
In some exotic packaging environments like Nixpkgs,
we enforce heavy amounts of sandboxing; we do not
include git by default in that sandbox.

Additionally, in said exotic packaging environments,
we should not always assume we are in a Git repository.
The Nixpkgs GitHub fetcher functions by downloading a
tarball, not the whole Git directory, so the test fails.
@@ -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.

@@ -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.

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