<commit_before>package pipelines_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("A pipeline containing jobs with hooks", func() {
	BeforeEach(func() {
		configurePipeline(
			"-c", "fixtures/hooks.yml",
		)
	})

	It("performs hooks under the right conditions", func() {
		By("performing ensure and on_success outputs on success")
		watch := triggerJob("some-passing-job")
		<-watch.Exited
		Expect(watch).To(gbytes.Say("passing job on success"))
		Expect(watch).To(gbytes.Say("passing job ensure"))
		Expect(watch).To(gbytes.Say("passing job on job success"))
		Expect(watch).To(gbytes.Say("passing job on job ensure"))
		Expect(watch).To(gexec.Exit(0))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("passing job on failure"))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("passing job on job failure"))

		By("performing ensure and on_failure steps on failure")
		watch = triggerJob("some-failing-job")
		<-watch.Exited
		Expect(watch).To(gbytes.Say("failing job on failure"))
		Expect(watch).To(gbytes.Say("failing job ensure"))
		Expect(watch).To(gbytes.Say("failing job on job failure"))
		Expect(watch).To(gbytes.Say("failing job on job ensure"))
		Expect(watch).To(gexec.Exit(1))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("failing job on success"))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("failing job on job success"))

		By("performing ensure steps on abort")
		watch = triggerJob("some-aborted-job")
		Eventually(watch).Should(gbytes.Say("waiting to be aborted"))
		abortBuild("some-aborted-job", 1)
		<-watch.Exited
		Expect(watch).To(gbytes.Say("aborted job ensure"))
		Expect(watch).To(gexec.Exit(1))
	})
})<commit_msg>add 2<commit_after>package pipelines_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("A pipeline containing jobs with hooks", func() {
	BeforeEach(func() {
		configurePipeline(
			"-c", "fixtures/hooks.yml",
		)
	})

	It("performs hooks under the right conditions", func() {
		By("performing ensure and on_success outputs on success")
		watch := triggerJob("some-passing-job")
		<-watch.Exited
		Expect(watch).To(gbytes.Say("passing job on success"))
		Expect(watch).To(gbytes.Say("passing job ensure"))
		Expect(watch).To(gbytes.Say("passing job on job success"))
		Expect(watch).To(gbytes.Say("passing job on job ensure"))
		Expect(watch).To(gexec.Exit(0))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("passing job on failure"))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("passing job on job failure"))

		By("performing ensure and on_failure steps on failure")
		watch = triggerJob("some-failing-job")
		<-watch.Exited
		Expect(watch).To(gbytes.Say("failing job on failure"))
		Expect(watch).To(gbytes.Say("failing job ensure"))
		Expect(watch).To(gbytes.Say("failing job on job failure"))
		Expect(watch).To(gbytes.Say("failing job on job ensure"))
		Expect(watch).To(gexec.Exit(1))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("failing job on success"))
		Expect(watch.Out.Contents()).NotTo(ContainSubstring("failing job on job success"))

		By("performing ensure steps on abort")
		watch = triggerJob("some-aborted-job")
		Eventually(watch).Should(gbytes.Say("waiting to be aborted"))
		abortBuild("some-aborted-job", 1)
		<-watch.Exited
		Expect(watch).To(gbytes.Say("aborted job ensure"))
		Expect(watch).To(gexec.Exit(3))
	})
})
{'fraction_non_alphanumeric': 0.16366704161979753, 'fraction_numerical': 0.002530933633295838, 'mean_word_length': 5.374551971326165, 'pattern_counts': {'":': 0, '<': 9, '<?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': '479348', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1209, 'n_words': 237}