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

Stop runner when found duplicate functions #101

Merged
merged 20 commits into from
Sep 19, 2023

Conversation

Chemaclass
Copy link
Member

@Chemaclass Chemaclass commented Sep 17, 2023

πŸ“š Description

Issue: #56

Stop the execution of the test runner if you have two tests with the same name.

πŸ”– Changes

  • Terminate the runner if duplicated tests were found

πŸ–ΌοΈ Screenshots

Example:

Screenshot 2023-09-19 at 12 36 06

πŸ—οΈ TODO

This current implementation works only when using the syntax function foo () {..., but in bash you can define functions without function and without the parentheses, so these two forms should also be valid and implemented in a follow up PR

  • yourFunc() { ...
  • function yourFunc { ...

@Chemaclass Chemaclass added the bug Something isn't working label Sep 17, 2023
@Chemaclass Chemaclass self-assigned this Sep 17, 2023
@Chemaclass Chemaclass added enhancement New feature or request and removed bug Something isn't working labels Sep 17, 2023
Copy link
Member

@khru khru left a comment

Choose a reason for hiding this comment

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

Why if there is duplicated the exit code it's 0 at the end of the execution of bashunit.

test to prove it:

function test_with_duplicates_should_end_with_error_code() {
  assertGeneralError "$(./bashunit "$(dirname "${BASH_SOURCE[0]}")/fixtures/duplicate_functions.sh")"
}

image

.editorconfig Outdated Show resolved Hide resolved
src/console_results.sh Outdated Show resolved Hide resolved
src/helpers.sh Outdated Show resolved Hide resolved
src/helpers.sh Outdated Show resolved Hide resolved
src/helpers.sh Show resolved Hide resolved
tests/unit/assert_test.sh Outdated Show resolved Hide resolved
src/runner.sh Outdated Show resolved Hide resolved
@Chemaclass Chemaclass force-pushed the feat/stop-exec-when-found-duplicate branch from 4260418 to 2064653 Compare September 18, 2023 16:31
@Chemaclass Chemaclass force-pushed the feat/stop-exec-when-found-duplicate branch from 6eeb95a to fbb540d Compare September 19, 2023 08:37
bashunit Outdated Show resolved Hide resolved
src/console_results.sh Outdated Show resolved Hide resolved
src/helpers.sh Outdated Show resolved Hide resolved
src/runner.sh Outdated Show resolved Hide resolved
tests/unit/helpers_test.sh Outdated Show resolved Hide resolved
@Chemaclass
Copy link
Member Author

Why if there is duplicated the exit code it's 0 at the end of the execution of bashunit.

test to prove it:

function test_with_duplicates_should_end_with_error_code() {
  assertGeneralError "$(./bashunit "$(dirname "${BASH_SOURCE[0]}")/fixtures/duplicate_functions.sh")"
}

image

I've tried different approaches, but I couldn’t make this happen... Maybe you could try this out. What about working on this idea in a follow up PR to unblock the changes in this one?

src/console_results.sh Outdated Show resolved Hide resolved
tests/unit/fixtures/duplicate_functions.sh Show resolved Hide resolved
@Chemaclass Chemaclass merged commit d23bf22 into main Sep 19, 2023
7 checks passed
@Chemaclass Chemaclass deleted the feat/stop-exec-when-found-duplicate branch September 19, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants