15 var authSettings = make(map[string]string)
18 for k, v := range authSettings {
23 func ParseAuthSettings(authScript []byte) {
24 scanner := bufio.NewScanner(bytes.NewReader(authScript))
26 line := scanner.Text()
27 if 0 != strings.Index(line, "export ") {
28 log.Printf("Ignoring: %v", line)
31 toks := strings.SplitN(strings.Replace(line, "export ", "", 1), "=", 2)
33 authSettings[toks[0]] = toks[1]
35 log.Fatalf("Could not parse: %v", line)
38 log.Printf("authSettings: %v", authSettings)
41 var pythonTestDir string = ""
43 func chdirToPythonTests() {
44 if pythonTestDir != "" {
45 if err := os.Chdir(pythonTestDir); err != nil {
46 log.Fatalf("chdir %s: %s", pythonTestDir, err)
51 if err := os.Chdir("sdk/python/tests"); err == nil {
52 pythonTestDir, err = os.Getwd()
55 if parent, err := os.Getwd(); err != nil || parent == "/" {
56 log.Fatalf("sdk/python/tests/ not found in any ancestor")
58 if err := os.Chdir(".."); err != nil {
69 cmd := exec.Command("python", "run_test_server.py", "start", "--auth", "admin")
70 stderr, err := cmd.StderrPipe()
74 go io.Copy(os.Stderr, stderr)
75 stdout, err := cmd.StdoutPipe()
79 if err = cmd.Start(); err != nil {
83 if authScript, err = ioutil.ReadAll(stdout); err != nil {
86 if err = cmd.Wait(); err != nil {
89 ParseAuthSettings(authScript)
98 exec.Command("python", "run_test_server.py", "stop").Run()
106 cmd := exec.Command("python", "run_test_server.py", "start_keep")
107 stderr, err := cmd.StderrPipe()
109 log.Fatalf("Setting up stderr pipe: %s", err)
111 go io.Copy(os.Stderr, stderr)
112 if err := cmd.Run(); err != nil {
113 panic(fmt.Sprintf("'python run_test_server.py start_keep' returned error %s", err))
122 exec.Command("python", "run_test_server.py", "stop_keep").Run()