Skip to content

close stdout/stderr handles in run_shell_cmd and test teardown + remove duplication in toy_build tests - #5050

Merged
boegel merged 4 commits into
easybuilders:developfrom
Flamefire:toy-refactor
Apr 8, 2026
Merged

close stdout/stderr handles in run_shell_cmd and test teardown + remove duplication in toy_build tests#5050
boegel merged 4 commits into
easybuilders:developfrom
Flamefire:toy-refactor

Conversation

@Flamefire

Copy link
Copy Markdown
Contributor

Almost every test case starts by getting the path to the test-folder, then to toy-0.0.eb and then reading this file.

Not only makes this harder to read the (relevant part of) the test it also slows it down to read the same file in every test.

Hence I factored those out to file-level constants.

While testing I noticed we don't close the mocked stdout/stderr buffers and added that too

@Flamefire

Copy link
Copy Markdown
Contributor Author

Rebased

@boegel

boegel commented Dec 3, 2025

Copy link
Copy Markdown
Member

@Flamefire Needs conflict fixing

@Flamefire

Copy link
Copy Markdown
Contributor Author

Rebased to fix

@boegel boegel modified the milestones: next release (5.2.1), 5.x Feb 11, 2026
@Flamefire
Flamefire force-pushed the toy-refactor branch 2 times, most recently from 4d5fbd6 to 6045c01 Compare March 2, 2026 13:44
Avoid the repaeted reads in almost every test.
The stdin/stdout/stderr handles need be closed by calling `communicate`.
Otherwise the handles will be leaked and e.g.
`test_run_shell_cmd_qa_trace` fails because it may capture a related
warning.

@boegel boegel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@boegel boegel changed the title Remove duplication in toy-build tests close stdout/stderr handles in run_shell_cmd and test teardown + remove duplication in toy_build tests Apr 8, 2026
@boegel boegel modified the milestones: 5.x, next release (5.3.0) Apr 8, 2026
@boegel
boegel merged commit 47638a9 into easybuilders:develop Apr 8, 2026
40 checks passed
@Flamefire
Flamefire deleted the toy-refactor branch April 8, 2026 14:28
@boegel boegel added the bug fix label Apr 9, 2026
@Flamefire

Copy link
Copy Markdown
Contributor Author

I noticed there are > 200 similar cases in other test files.
@boegel Would you merge a PR replacing those too? My idea would be to move the constants to test/framework/__init__.py so we can import them with from test.framework import TEST_ECS_DIR, TOY_EC, TOY_EC_TXT in the 18 test files that use them.
Starting many tests with this boilerplate code gets tiresome.

@boegel

boegel commented Jun 14, 2026

Copy link
Copy Markdown
Member

I noticed there are > 200 similar cases in other test files. @boegel Would you merge a PR replacing those too? My idea would be to move the constants to test/framework/__init__.py so we can import them with from test.framework import TEST_ECS_DIR, TOY_EC, TOY_EC_TXT in the 18 test files that use them. Starting many tests with this boilerplate code gets tiresome.

@Flamefire Sure, sounds like a nice cleanup in the tests. (sorry for the late reply, I often overlook comments in merged PRs)

@Flamefire

Copy link
Copy Markdown
Contributor Author

Followup done: #5203

300 lines removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants