Skip to content

Commit

Permalink
Update go/setup.py to use new ShellUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
hamiltont committed Jul 22, 2014
1 parent c5e489b commit 02af184
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 6 additions & 14 deletions go/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,27 @@
import setup_util
from test_runner import TestRunner

class Bar(TestRunner):
class Go(TestRunner):

def start(self):
setup_util.replace_text("go/src/hello/hello.go", "tcp\(.*:3306\)", "tcp(" + self.database_host + ":3306)")
if os.name == 'nt':
#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("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

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("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

def stop(self):
if os.name == 'nt':
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)
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
2 changes: 2 additions & 0 deletions toolset/benchmark/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import subprocess
import time
import os
import logging
import shlex

Expand All @@ -22,6 +23,7 @@ def __init__(self, directory, outfile, errfile, logger=None):
self.outfile = outfile
self.errfile = errfile
self.logger = logger
self.os = os.name

def __write_out(self, message, level=logging.INFO, stream=None):
if self.logger:
Expand Down

0 comments on commit 02af184

Please sign in to comment.