Skip to content

Make some tests more lenient - #141

Open
tomodachi94 wants to merge 2 commits into
MichaelAquilina:masterfrom
tomodachi94:make-some-tests-more-lenient
Open

Make some tests more lenient#141
tomodachi94 wants to merge 2 commits into
MichaelAquilina:masterfrom
tomodachi94:make-some-tests-more-lenient

Conversation

@tomodachi94

@tomodachi94 tomodachi94 commented Dec 10, 2024

Copy link
Copy Markdown
  • 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.
}

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

@tomodachi94 tomodachi94 Dec 10, 2024

Copy link
Copy Markdown
Author

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.

Comment thread tests/test_buffer.zunit
}

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

Copy link
Copy Markdown
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
Copy Markdown
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.

@MichaelAquilina

Copy link
Copy Markdown
Owner

@tomodachi94 sorry coming back to this after so long. I dont think I agree with the changes here because they introduce the risk of silently failing tests. Could you explain what you are trying to achieve? Maybe we can find an alternative solution for your problem.

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