<commit_before>package testrunner

import (
	"fmt"
	"os/exec"
	"time"

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

type Runner struct {
	binPath string
	Session *gexec.Session
	config  Config
}

type Config struct {
	stack             string
	cellID            string
	executorURL       string
	etcdCluster       string
	serverPort        int
	logLevel          string
	heartbeatInterval time.Duration
	pollingInterval   time.Duration
}

func New(
	binPath, cellID, stack, executorURL, etcdCluster, logLevel string,
	serverPort int,
	heartbeatInterval, pollingInterval time.Duration) *Runner {
	return &Runner{
		binPath: binPath,
		config: Config{
			cellID:            cellID,
			stack:             stack,
			executorURL:       executorURL,
			serverPort:        serverPort,
			etcdCluster:       etcdCluster,
			logLevel:          logLevel,
			heartbeatInterval: heartbeatInterval,
			pollingInterval:   pollingInterval,
		},
	}
}

func (r *Runner) Start() {
	if r.Session != nil && r.Session.ExitCode() == -1 {
		panic("starting more than one rep!!!")
	}

	repSession, err := gexec.Start(
		exec.Command(
			r.binPath,
			"-cellID", r.config.cellID,
			"-stack", r.config.stack,
			"-executorURL", r.config.executorURL,
			"-listenAddr", fmt.Sprintf("0.0.0.0:%d", r.config.serverPort),
			"-etcdCluster", r.config.etcdCluster,
			"-logLevel", r.config.logLevel,
			"-heartbeatInterval", r.config.heartbeatInterval.String(),
			"-pollingInterval", r.config.pollingInterval.String(),
		),
		gexec.NewPrefixedWriter("\x1b[32m[o]\x1b[32m[rep]\x1b[0m ", ginkgo.GinkgoWriter),
		gexec.NewPrefixedWriter("\x1b[91m[e]\x1b[32m[rep]\x1b[0m ", ginkgo.GinkgoWriter),
	)

	Ω(err).ShouldNot(HaveOccurred())
	r.Session = repSession

	Eventually(r.Session.Buffer()).Should(gbytes.Say("rep.started"))
}

func (r *Runner) Stop() {
	if r.Session != nil {
		r.Session.Interrupt().Wait(5 * time.Second)
	}
}<commit_msg>See if travis just needs more time<commit_after>package testrunner

import (
	"fmt"
	"os/exec"
	"time"

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

type Runner struct {
	binPath string
	Session *gexec.Session
	config  Config
}

type Config struct {
	stack             string
	cellID            string
	executorURL       string
	etcdCluster       string
	serverPort        int
	logLevel          string
	heartbeatInterval time.Duration
	pollingInterval   time.Duration
}

func New(
	binPath, cellID, stack, executorURL, etcdCluster, logLevel string,
	serverPort int,
	heartbeatInterval, pollingInterval time.Duration) *Runner {
	return &Runner{
		binPath: binPath,
		config: Config{
			cellID:            cellID,
			stack:             stack,
			executorURL:       executorURL,
			serverPort:        serverPort,
			etcdCluster:       etcdCluster,
			logLevel:          logLevel,
			heartbeatInterval: heartbeatInterval,
			pollingInterval:   pollingInterval,
		},
	}
}

func (r *Runner) Start() {
	if r.Session != nil && r.Session.ExitCode() == -1 {
		panic("starting more than one rep!!!")
	}

	repSession, err := gexec.Start(
		exec.Command(
			r.binPath,
			"-cellID", r.config.cellID,
			"-stack", r.config.stack,
			"-executorURL", r.config.executorURL,
			"-listenAddr", fmt.Sprintf("0.0.0.0:%d", r.config.serverPort),
			"-etcdCluster", r.config.etcdCluster,
			"-logLevel", r.config.logLevel,
			"-heartbeatInterval", r.config.heartbeatInterval.String(),
			"-pollingInterval", r.config.pollingInterval.String(),
		),
		gexec.NewPrefixedWriter("\x1b[32m[o]\x1b[32m[rep]\x1b[0m ", ginkgo.GinkgoWriter),
		gexec.NewPrefixedWriter("\x1b[91m[e]\x1b[32m[rep]\x1b[0m ", ginkgo.GinkgoWriter),
	)

	Ω(err).ShouldNot(HaveOccurred())
	r.Session = repSession

	Eventually(r.Session.Buffer(), 10).Should(gbytes.Say("rep.started"))
}

func (r *Runner) Stop() {
	if r.Session != nil {
		r.Session.Interrupt().Wait(5 * time.Second)
	}
}
{'fraction_non_alphanumeric': 0.13877038895859473, 'fraction_numerical': 0.011543287327478042, 'mean_word_length': 3.351528384279476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2333530', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1438, 'n_words': 263}