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

Ensure teardown is always executed #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chitoku-k
Copy link

In some cases especially when tests failed due to err_exit, the teardown function was not executed. This PR uses trap functions to ensure it is always executed.

@setup {
  tempfile=test
  touch $tempfile
}

@teardown {
  # Here is not executed in some of the following cases
  rm $tempfile
}

@test 'case ok' {
  # This case is totally OK because `run` temporarily disables `err_exit` (using unsetopt)
  run false
}

@test 'case ng' {
  # This PR fixes this case where the test fails with `err_exit` being set
  false
}

I tried to show this by adding test cases that cover them which resulted in the entire test to break because it needs to be somehow failed...

@chitoku-k chitoku-k requested review from molovo and psprint February 1, 2020 10:05
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.

1 participant