<commit_before>package gqt_test

import (
	"fmt"
	"os"
	"os/exec"
	"regexp"
	"strings"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Init process", func() {
	var (
		tmpDir        string
		parentCommand *exec.Cmd
	)

	BeforeEach(func() {
		tmpDir = tempDir("", "")

		cmd := exec.Command("gcc", "-static", "-o", "test_init", "test_init.c", "../../cmd/init/ignore_sigchild.c", "-I", "../../cmd/init")
		runCommandInDir(cmd, "cmd")
	})

	AfterEach(func() {
		os.RemoveAll(tmpDir)
	})

	It("does not allow children to become zombies", func() {
		parentCommand = exec.Command("cmd/test_init")
		parentCommand.Start()

		Eventually(countPsOccurances).Should(Equal(1))

		psOut := string(runPs())
		matchingPsLines := []string{}
		psLines := strings.Split(psOut, "\n")
		for _, psLine := range psLines {
			if !strings.Contains(psLine, "test_init") {
				continue
			}
			matchingPsLines = append(matchingPsLines, psLine)
		}

		Expect(strings.Join(matchingPsLines, "\n")).NotTo(ContainSubstring("defunct"), fmt.Sprintf("\n\nps output:\n%s\n\n", psOut))
	})<commit_msg>Kill test process on AfterEach<commit_after>package gqt_test

import (
	"fmt"
	"os"
	"os/exec"
	"regexp"
	"strings"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Init process", func() {
	var (
		tmpDir        string
		parentCommand *exec.Cmd
	)

	BeforeEach(func() {
		tmpDir = tempDir("", "")

		cmd := exec.Command("gcc", "-static", "-o", "test_init", "test_init.c", "../../cmd/init/ignore_sigchild.c", "-I", "../../cmd/init")
		runCommandInDir(cmd, "cmd")
	})

	AfterEach(func() {
		Expect(parentCommand.Process.Kill()).To(Succeed())
		_, waitErr := parentCommand.Process.Wait()
		Expect(waitErr).NotTo(HaveOccurred())
		os.RemoveAll(tmpDir)
	})

	It("does not allow children to become zombies", func() {
		parentCommand = exec.Command("cmd/test_init")
		Expect(parentCommand.Start()).To(Succeed())

		Eventually(countPsOccurances).Should(Equal(1))

		psOut := string(runPs())
		matchingPsLines := []string{}
		psLines := strings.Split(psOut, "\n")
		for _, psLine := range psLines {
			if !strings.Contains(psLine, "test_init") {
				continue
			}
			matchingPsLines = append(matchingPsLines, psLine)
		}

		Expect(strings.Join(matchingPsLines, "\n")).NotTo(ContainSubstring("defunct"), fmt.Sprintf("\n\nps output:\n%s\n\n", psOut))
	})
{'fraction_non_alphanumeric': 0.19180397127165189, 'fraction_numerical': 0.0008449514152936206, 'mean_word_length': 4.081545064377682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1517590', 'n_tokens_mistral': 946, 'n_tokens_neox': 867, 'n_words': 148}