<commit_before>// Runs the servicerunner binary and checks that it outputs a JSON line to
// stdout with the expected variables.
package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"path"
	"testing"
)

func check(t *testing.T, err error) {
	if err != nil {
		t.Fatal(err)
	}
}

func TestMain(t *testing.T) {
	tmpdir, err := ioutil.TempDir("", "servicerunner_test")
	check(t, err)
	defer os.RemoveAll(tmpdir)
	os.Setenv("TMPDIR", tmpdir)

	bin := path.Join(tmpdir, "servicerunner")
	fmt.Println("Building", bin)
	check(t, exec.Command("v23", "go", "build", "-o", bin, "v.io/core/veyron/tools/servicerunner").Run())

	cmd := exec.Command(bin)
	stdout, err := cmd.StdoutPipe()
	check(t, err)
	check(t, cmd.Start())

	line, err := bufio.NewReader(stdout).ReadBytes('\n')
	check(t, err)
	vars := map[string]string{}
	check(t, json.Unmarshal(line, &vars))
	fmt.Println(vars)
	expectedVars := []string{
		"VEYRON_CREDENTIALS",
		"MT_NAME",
		"PROXY_ADDR",
		"WSPR_ADDR",
		"TEST_IDENTITYD_ADDR",
		"TEST_IDENTITYD_HTTP_ADDR",
	}
	for _, name := range expectedVars {
		if _, ok := vars[name]; !ok {
			t.Error("Missing", name)
		}
	}

	check(t, cmd.Process.Kill())
}
<commit_msg>veyron/tools/servicerunner: Use t.Fatalf directly instead of through a helper.<commit_after>// Runs the servicerunner binary and checks that it outputs a JSON line to
// stdout with the expected variables.
package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"path"
	"testing"
)

func TestMain(t *testing.T) {
	tmpdir, err := ioutil.TempDir("", "servicerunner_test")
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(tmpdir)
	os.Setenv("TMPDIR", tmpdir)

	bin := path.Join(tmpdir, "servicerunner")
	fmt.Println("Building", bin)
	err = exec.Command("v23", "go", "build", "-o", bin, "v.io/core/veyron/tools/servicerunner").Run()
	if err != nil {
		t.Fatal(err)
	}

	cmd := exec.Command(bin)
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		t.Fatal(err)
	}
	if err = cmd.Start(); err != nil {
		t.Fatal(err)
	}

	line, err := bufio.NewReader(stdout).ReadBytes('\n')
	if err != nil {
		t.Fatal(err)
	}
	vars := map[string]string{}
	if err = json.Unmarshal(line, &vars); err != nil {
		t.Fatal(err)
	}
	fmt.Println(vars)
	expectedVars := []string{
		"VEYRON_CREDENTIALS",
		"MT_NAME",
		"PROXY_ADDR",
		"WSPR_ADDR",
		"TEST_IDENTITYD_ADDR",
		"TEST_IDENTITYD_HTTP_ADDR",
	}
	for _, name := range expectedVars {
		if _, ok := vars[name]; !ok {
			t.Error("Missing", name)
		}
	}

	if err != cmd.Process.Kill() {
		t.Fatal(err)
	}
}

{'fraction_non_alphanumeric': 0.1794871794871795, 'fraction_numerical': 0.001554001554001554, 'mean_word_length': 4.019493177387914, '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': '6070587', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1066, 'n_words': 227}