3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-05 22:14:08 +00:00

Merge pull request #33 from cr1901/no-resource

Meaningful Windows Support
This commit is contained in:
Clifford Wolf 2019-03-19 14:20:28 +01:00 committed by GitHub
commit ef26dff799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 18 deletions

View file

@ -364,6 +364,9 @@ def run_job(taskname):
print('<?xml version="1.0" encoding="UTF-8"?>', file=f) print('<?xml version="1.0" encoding="UTF-8"?>', file=f)
print('<testsuites disabled="0" errors="%d" failures="%d" tests="1" time="%d">' % (junit_errors, junit_failures, job.total_time), file=f) print('<testsuites disabled="0" errors="%d" failures="%d" tests="1" time="%d">' % (junit_errors, junit_failures, job.total_time), file=f)
print('<testsuite disabled="0" errors="%d" failures="%d" name="%s" skipped="0" tests="1" time="%d">' % (junit_errors, junit_failures, junit_ts_name, job.total_time), file=f) print('<testsuite disabled="0" errors="%d" failures="%d" name="%s" skipped="0" tests="1" time="%d">' % (junit_errors, junit_failures, junit_ts_name, job.total_time), file=f)
print('<properties>', file=f)
print('<property name="os" value="%s"/>' % os.name, file=f)
print('</properties>', file=f)
print('<testcase classname="%s" name="%s" status="%s" time="%d">' % (junit_ts_name, junit_tc_name, job.status, job.total_time), file=f) print('<testcase classname="%s" name="%s" status="%s" time="%d">' % (junit_ts_name, junit_tc_name, job.status, job.total_time), file=f)
if junit_errors: if junit_errors:
print('<error message="%s" type="%s"/>' % (job.status, job.status), file=f) print('<error message="%s" type="%s"/>' % (job.status, job.status), file=f)
@ -385,4 +388,3 @@ for t in tasknames:
retcode |= run_job(t) retcode |= run_job(t)
sys.exit(retcode) sys.exit(retcode)

View file

@ -16,9 +16,11 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
import os, re, resource, sys import os, re, sys
import subprocess, fcntl if os.name == "posix":
from shutil import copyfile, rmtree import resource, fcntl
import subprocess
from shutil import copyfile
from select import select from select import select
from time import time, localtime from time import time, localtime
@ -31,7 +33,21 @@ class SbyTask:
self.job = job self.job = job
self.info = info self.info = info
self.deps = deps self.deps = deps
self.cmdline = cmdline if os.name == "posix":
self.cmdline = cmdline
else:
# Windows command interpreter equivalents for sequential
# commands (; => &) command grouping ({} => ()).
replacements = {
";" : "&",
"{" : "(",
"}" : ")",
}
cmdline_copy = cmdline
for u, w in replacements.items():
cmdline_copy = cmdline_copy.replace(u, w)
self.cmdline = cmdline_copy
self.logfile = logfile self.logfile = logfile
self.noprintregex = None self.noprintregex = None
self.notify = [] self.notify = []
@ -91,8 +107,9 @@ class SbyTask:
self.job.log("%s: starting process \"%s\"" % (self.info, self.cmdline)) self.job.log("%s: starting process \"%s\"" % (self.info, self.cmdline))
self.p = subprocess.Popen(self.cmdline, shell=True, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, self.p = subprocess.Popen(self.cmdline, shell=True, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
stderr=(subprocess.STDOUT if self.logstderr else None)) stderr=(subprocess.STDOUT if self.logstderr else None))
fl = fcntl.fcntl(self.p.stdout, fcntl.F_GETFL) if os.name == "posix":
fcntl.fcntl(self.p.stdout, fcntl.F_SETFL, fl | os.O_NONBLOCK) fl = fcntl.fcntl(self.p.stdout, fcntl.F_GETFL)
fcntl.fcntl(self.p.stdout, fcntl.F_SETFL, fl | os.O_NONBLOCK)
self.job.tasks_pending.remove(self) self.job.tasks_pending.remove(self)
self.job.tasks_running.append(self) self.job.tasks_running.append(self)
self.running = True self.running = True
@ -162,8 +179,9 @@ class SbyJob:
self.start_clock_time = time() self.start_clock_time = time()
ru = resource.getrusage(resource.RUSAGE_CHILDREN) if os.name == "posix":
self.start_process_time = ru.ru_utime + ru.ru_stime ru = resource.getrusage(resource.RUSAGE_CHILDREN)
self.start_process_time = ru.ru_utime + ru.ru_stime
self.summary = list() self.summary = list()
@ -578,16 +596,23 @@ class SbyJob:
total_clock_time = int(time() - self.start_clock_time) total_clock_time = int(time() - self.start_clock_time)
ru = resource.getrusage(resource.RUSAGE_CHILDREN) if os.name == "posix":
total_process_time = int((ru.ru_utime + ru.ru_stime) - self.start_process_time) ru = resource.getrusage(resource.RUSAGE_CHILDREN)
self.total_time = total_process_time total_process_time = int((ru.ru_utime + ru.ru_stime) - self.start_process_time)
self.total_time = total_process_time
self.summary = [ self.summary = [
"Elapsed clock time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" % "Elapsed clock time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" %
(total_clock_time // (60*60), (total_clock_time // 60) % 60, total_clock_time % 60, total_clock_time), (total_clock_time // (60*60), (total_clock_time // 60) % 60, total_clock_time % 60, total_clock_time),
"Elapsed process time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" % "Elapsed process time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" %
(total_process_time // (60*60), (total_process_time // 60) % 60, total_process_time % 60, total_process_time), (total_process_time // (60*60), (total_process_time // 60) % 60, total_process_time % 60, total_process_time),
] + self.summary ] + self.summary
else:
self.summary = [
"Elapsed clock time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" %
(total_clock_time // (60*60), (total_clock_time // 60) % 60, total_clock_time % 60, total_clock_time),
"Elapsed process time unvailable on Windows"
] + self.summary
for line in self.summary: for line in self.summary:
self.log("summary: %s" % line) self.log("summary: %s" % line)