From 02af18423d75ccfc051c31a25b803b13f6985c62 Mon Sep 17 00:00:00 2001 From: Hamilton Turner Date: Tue, 22 Jul 2014 13:59:32 -0400 Subject: [PATCH] Update go/setup.py to use new ShellUtils --- go/setup.py | 20 ++++++-------------- toolset/benchmark/utils.py | 2 ++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/go/setup.py b/go/setup.py index 69fee7549ff..b42d1169dc7 100644 --- a/go/setup.py +++ b/go/setup.py @@ -4,7 +4,7 @@ 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)") @@ -12,16 +12,12 @@ def start(self): #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): @@ -29,10 +25,6 @@ def stop(self): 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 diff --git a/toolset/benchmark/utils.py b/toolset/benchmark/utils.py index 1d99ee260f7..7ab3f20e599 100644 --- a/toolset/benchmark/utils.py +++ b/toolset/benchmark/utils.py @@ -1,6 +1,7 @@ import subprocess import time +import os import logging import shlex @@ -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: