<commit_before>package main

import (
	"bytes"
	"io"
	"os"
	"path"
	"strings"
	"testing"
)

func TestMain(t *testing.T) {
	stdout := os.Stdout
	tmpStdout, err := os.Create(path.Join(os.TempDir(), "test-stdout"))
	if err != nil {
		t.Skip("Unable to create temporary test file")
	}
	os.Stdout = tmpStdout
	main()
	os.Stdout = stdout
	contents := make([]byte, 256)
	_, err = io.ReadFull(tmpStdout, contents)
	if err != nil {
		t.Skip("Unable to read output buffer")
	}
	stringContents := bytes.NewBuffer(contents).String()
	if !strings.Contains(stringContents, "matterleast") {
		t.Error("Stdout incorrect; expected the word 'matterleast'")
	}
}<commit_msg>Update test to be runnable on Travis<commit_after>package main

import (
	"bytes"
	"io"
	"os"
	"strings"
	"testing"
)

func TestMain(t *testing.T) {
	stdout := os.Stdout
	// Credit to <NAME> for this way to capture stdout without creating
	// a new file. See:
	// http://stackoverflow.com/a/10476304/7106084
	readEnd, writeEnd, err := os.Pipe()
	if err != nil {
		t.Skip("Unable to create pipe to replace stdout")
	}
	os.Stdout = writeEnd
	// Send anything written on stdout back on the contents channel as a string
	contents := make(chan string)
	go func() {
		var buf bytes.Buffer
		io.Copy(&buf, readEnd)
		contents <- buf.String()
	}()
	main() //print to stdout
	os.Stdout = stdout
	writeEnd.Close() // tell our goroutine that we're done writing

	stringContents := <-contents // wait for goroutine to give us output
	if !strings.Contains(stringContents, "matterleast") {
		t.Error("Stdout incorrect; expected the word 'matterleast'")
	}
}
{'fraction_non_alphanumeric': 0.13829787234042554, 'fraction_numerical': 0.011264080100125156, 'mean_word_length': 3.9658385093167703, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '3770604', 'n_tokens_mistral': 592, 'n_tokens_neox': 557, 'n_words': 165}