| // Runs the servicerunner binary and checks that it outputs a JSON line to |
| // stdout with the expected variables. |
| func check(t *testing.T, err error) { |
| func TestMain(t *testing.T) { |
| tmpdir, err := ioutil.TempDir("", "servicerunner_test") |
| 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()) |
| stdout, err := cmd.StdoutPipe() |
| line, err := bufio.NewReader(stdout).ReadBytes('\n') |
| vars := map[string]string{} |
| check(t, json.Unmarshal(line, &vars)) |
| for _, name := range []string{"VEYRON_CREDENTIALS", "MT_NAME", "PROXY_ADDR", "WSPR_ADDR"} { |
| if _, ok := vars[name]; !ok { |
| check(t, cmd.Process.Kill()) |