Skip to content

improve the way we terminate subprocess during test runs#7

Merged
GustavoCaso merged 2 commits intomainfrom
ensure-no-lingering-process-stay-after-running-tests
Aug 21, 2025
Merged

improve the way we terminate subprocess during test runs#7
GustavoCaso merged 2 commits intomainfrom
ensure-no-lingering-process-stay-after-running-tests

Conversation

@GustavoCaso
Copy link
Copy Markdown
Owner

@GustavoCaso GustavoCaso commented Aug 20, 2025

Some of our test we are leaving lingering processes after completing.

  • Using the t.Context when using runCliCommand sometimes failed to execute the command because of the context being cancelled. This was particular hapenning on our Cleanup function for our server.
  • The other test that left lingering process was TestRunCommand_Foreground . Looks like our tests creates a many processes: go test, go run . so when sending the SIGTERM to go run . command we still have a process left after the test.
    We fixed by creating a process group associated with the go run . command, so all sub processes created can be terminated using syscall.Kill(-cmd.Process.Pid, syscall.SIGTERM)

@GustavoCaso GustavoCaso marked this pull request as ready for review August 21, 2025 05:45
@GustavoCaso GustavoCaso merged commit ae59174 into main Aug 21, 2025
2 checks passed
@GustavoCaso GustavoCaso deleted the ensure-no-lingering-process-stay-after-running-tests branch August 21, 2025 05:47
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