<commit_before>package system

import (
	"os"
	"os/exec"
)

type Shell struct{}

func (self *Shell) GoTest(directory string) (output string, err error) {
	err = os.Chdir(directory)
	if err != nil {
		panic(err)
		return "", err
	}
	output, err = self.execute("go", "test", "-i")
	if err != nil {
		return output, err
	}
	output, err = self.execute("go", "test", "-v", "-timeout=-42s")
	return
}

func (self *Shell) execute(name string, args ...string) (output string, err error) {
	rawOutput, err := exec.Command(name, args...).CombinedOutput()
	output = string(rawOutput)
	return
}

func (self *Shell) Getenv(key string) string {
	return os.Getenv(key)
}

func (self *Shell) Setenv(key, value string) error {
	if self.Getenv(key) != value {
		return os.Setenv(key, value)
	}
	return nil
}

func NewShell() *Shell {
	return &Shell{}
}
<commit_msg>Phew, you can specify the working directory on a per-command basis.<commit_after>package system

import (
	"os"
	"os/exec"
)

type Shell struct{}

func (self *Shell) GoTest(directory string) (output string, err error) {
	output, err = self.execute(directory, "go", "test", "-i")
	if err == nil {
		output, err = self.execute(directory, "go", "test", "-v", "-timeout=-42s")
	}
	return
}

func (self *Shell) execute(directory, name string, args ...string) (output string, err error) {
	command := exec.Command(name, args...)
	command.Dir = directory
	rawOutput, err := command.CombinedOutput()
	output = string(rawOutput)
	return
}

func (self *Shell) Getenv(key string) string {
	return os.Getenv(key)
}

func (self *Shell) Setenv(key, value string) error {
	if self.Getenv(key) != value {
		return os.Setenv(key, value)
	}
	return nil
}

func NewShell() *Shell {
	return &Shell{}
}

{'fraction_non_alphanumeric': 0.1607865818392134, 'fraction_numerical': 0.002313475997686524, 'mean_word_length': 4.148809523809524, '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': '785414', 'n_tokens_mistral': 621, 'n_tokens_neox': 612, 'n_words': 184}