Browse Source

Update go/setup.py to use new ShellUtils

Hamilton Turner 11 years ago
parent
commit
02af18423d
2 changed files with 8 additions and 14 deletions
  1. 6 14
      go/setup.py
  2. 2 0
      toolset/benchmark/utils.py

+ 6 - 14
go/setup.py

@@ -4,7 +4,7 @@ import os
 import setup_util
 import setup_util
 from test_runner import TestRunner
 from test_runner import TestRunner
 
 
-class Bar(TestRunner):
+class Go(TestRunner):
 
 
   def start(self):
   def start(self):
     setup_util.replace_text("go/src/hello/hello.go", "tcp\(.*:3306\)", "tcp(" + self.database_host + ":3306)")
     setup_util.replace_text("go/src/hello/hello.go", "tcp\(.*:3306\)", "tcp(" + self.database_host + ":3306)")
@@ -12,16 +12,12 @@ class Bar(TestRunner):
       #subprocess.call("rmdir /s /q pkg\\windows_amd64", shell=True, cwd="go")
       #subprocess.call("rmdir /s /q pkg\\windows_amd64", shell=True, cwd="go")
       #subprocess.call("rmdir /s /q src\\github.com", shell=True, cwd="go")
       #subprocess.call("rmdir /s /q src\\github.com", shell=True, cwd="go")
       #subprocess.call("del /s /q /f bin\\hello.exe", shell=True, cwd="go")
       #subprocess.call("del /s /q /f bin\\hello.exe", shell=True, cwd="go")
-      subprocess.call("set GOPATH=C:\\FrameworkBenchmarks\\go&& go get ./...", shell=True, cwd="go", stderr=errfile, stdout=logfile)
-      subprocess.Popen("setup.bat", shell=True, cwd="go", stderr=errfile, stdout=logfile)
+      self.sh("go get ./...")
+      self.sh("setup.bat")
       return 0
       return 0
     
     
-    self.sh("which go")
-    self.sh("rm -rf src/github.com")
-    self.sh("ls src/github.com/go-sql-driver/mysql")
     self.sh("go get ./...")
     self.sh("go get ./...")
-    self.sh("ls src/github.com/go-sql-driver/mysql")
-    self.sh_async("go run -x -v src/hello/hello.go")
+    self.pid = self.sh_async("go run -x -v src/hello/hello.go")
     return 0
     return 0
 
 
   def stop(self):
   def stop(self):
@@ -29,10 +25,6 @@ class Bar(TestRunner):
       subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
       subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
       subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
       subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
       return 0
       return 0
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'hello' in line:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
+    # Kill off the entire go process group
+    self.sh_pkill(self.pid)
     return 0
     return 0

+ 2 - 0
toolset/benchmark/utils.py

@@ -1,6 +1,7 @@
 
 
 import subprocess
 import subprocess
 import time
 import time
+import os
 import logging
 import logging
 import shlex
 import shlex
 
 
@@ -22,6 +23,7 @@ class ShellUtils():
     self.outfile = outfile
     self.outfile = outfile
     self.errfile = errfile
     self.errfile = errfile
     self.logger = logger
     self.logger = logger
+    self.os = os.name
   
   
   def __write_out(self, message, level=logging.INFO, stream=None):
   def __write_out(self, message, level=logging.INFO, stream=None):
     if self.logger:
     if self.logger: