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

bats hangs when setup sources script with exec 3>&1 #885

Open
happy-barney opened this issue Mar 16, 2024 · 2 comments
Open

bats hangs when setup sources script with exec 3>&1 #885

happy-barney opened this issue Mar 16, 2024 · 2 comments
Labels
Component: Bash Code Everything regarding the bash code Priority: High Broken behavior in specific environments like in parallel mode or only on some operating systems Type: Bug
Milestone

Comments

@happy-barney
Copy link

To Reproduce
Steps to reproduce the behavior:

  1. Create example source.sh with following contents
exec 3>&1
  1. Create example file.bats with following contents
setup () {
	. "${DIR}"/source.sh
}

@test "..." {
	run true
}
  1. run bats file.bats

Expected behavior
Test should be executed

Environment (please complete the following information):

  • Bats version:
$ bats -v
Bats 1.2.1
  • operating system (including version):
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy
  • bash --version:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
  • Install method: distribution package manager

Additional context
Writing my first tests using bats ... :-)

@happy-barney happy-barney added Priority: NeedsTriage Issue has not been vetted yet Type: Bug labels Mar 16, 2024
@martin-schulze-vireso
Copy link
Member

Please note that this is far from the most recent bats version, so any fixes will only be available with much newer versions.

That being said, I believe this will be problematic even now. FD 3 is used internally by bats and interfering with it will result in problems. I am unsure, if we can do anything about that.

@martin-schulze-vireso martin-schulze-vireso added Priority: High Broken behavior in specific environments like in parallel mode or only on some operating systems Component: Bash Code Everything regarding the bash code and removed Priority: NeedsTriage Issue has not been vetted yet labels Mar 16, 2024
@happy-barney
Copy link
Author

Can you mention it in documentation and suggest that users use some smarter mechanism?

exec {FD}>test.txt
echo line 1 >&$FD

@martin-schulze-vireso martin-schulze-vireso added this to the v1.12.0 milestone May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Bash Code Everything regarding the bash code Priority: High Broken behavior in specific environments like in parallel mode or only on some operating systems Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants