mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 12:48:51 +00:00
build: Port to Python 3
https://bugzilla.gnome.org/show_bug.cgi?id=687637
This commit is contained in:
parent
ae5761cd65
commit
d50dbae41e
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright (C) 2013 Red Hat, Inc.
|
# Copyright (C) 2013 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
@ -102,7 +102,7 @@ class Driver:
|
|||||||
proc = subprocess.Popen(self.argv, close_fds=True,
|
proc = subprocess.Popen(self.argv, close_fds=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
except OSError, ex:
|
except OSError as ex:
|
||||||
self.report_error("Couldn't run %s: %s" % (self.argv[0], str(ex)))
|
self.report_error("Couldn't run %s: %s" % (self.argv[0], str(ex)))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -112,13 +112,13 @@ class Driver:
|
|||||||
while len(rset) > 0:
|
while len(rset) > 0:
|
||||||
ret = select.select(rset, [], [], 10)
|
ret = select.select(rset, [], [], 10)
|
||||||
if outf in ret[0]:
|
if outf in ret[0]:
|
||||||
data = os.read(outf, 1024)
|
data = os.read(outf, 1024).decode("utf-8")
|
||||||
if data == "":
|
if data == "":
|
||||||
rset.remove(outf)
|
rset.remove(outf)
|
||||||
self.log.write(data)
|
self.log.write(data)
|
||||||
self.process(data)
|
self.process(data)
|
||||||
if errf in ret[0]:
|
if errf in ret[0]:
|
||||||
data = os.read(errf, 1024)
|
data = os.read(errf, 1024).decode("utf-8")
|
||||||
if data == "":
|
if data == "":
|
||||||
rset.remove(errf)
|
rset.remove(errf)
|
||||||
self.log.write(data)
|
self.log.write(data)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright (C) 2014 Red Hat, Inc.
|
# Copyright (C) 2014 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
@ -42,7 +42,7 @@ class NullCompiler:
|
|||||||
|
|
||||||
def process(self, proc):
|
def process(self, proc):
|
||||||
while True:
|
while True:
|
||||||
line = proc.stdout.readline()
|
line = proc.stdout.readline().decode("utf-8")
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
self.input(line)
|
self.input(line)
|
||||||
@ -75,27 +75,27 @@ class GTestCompiler(NullCompiler):
|
|||||||
self.test_num += 1
|
self.test_num += 1
|
||||||
elif cmd == "result":
|
elif cmd == "result":
|
||||||
if data == "OK":
|
if data == "OK":
|
||||||
print "ok %d %s" % (self.test_num, self.test_name)
|
print("ok %d %s" % (self.test_num, self.test_name))
|
||||||
if data == "FAIL":
|
if data == "FAIL":
|
||||||
print "not ok %d %s", (self.test_num, self.test_name)
|
print("not ok %d %s", (self.test_num, self.test_name))
|
||||||
self.test_name = None
|
self.test_name = None
|
||||||
elif cmd == "skipping":
|
elif cmd == "skipping":
|
||||||
if "/subprocess" not in data:
|
if "/subprocess" not in data:
|
||||||
print "ok %d # skip -- %s" % (self.test_num, data)
|
print("ok %d # skip -- %s" % (self.test_num, data))
|
||||||
self.test_name = None
|
self.test_name = None
|
||||||
elif data:
|
elif data:
|
||||||
print "# %s: %s" % (cmd, data)
|
print("# %s: %s" % (cmd, data))
|
||||||
else:
|
else:
|
||||||
print "# %s" % cmd
|
print("# %s" % cmd)
|
||||||
elif line.startswith("(MSG: "):
|
elif line.startswith("(MSG: "):
|
||||||
print "# %s" % line[6:-1]
|
print("# %s" % line[6:-1])
|
||||||
elif line:
|
elif line:
|
||||||
print "# %s" % line
|
print("# %s" % line)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
def run(self, proc, output=""):
|
def run(self, proc, output=""):
|
||||||
# Complete retrieval of the list of tests
|
# Complete retrieval of the list of tests
|
||||||
output += proc.stdout.read()
|
output += proc.stdout.read().decode("utf-8")
|
||||||
proc.wait()
|
proc.wait()
|
||||||
if proc.returncode:
|
if proc.returncode:
|
||||||
sys.stderr.write("tap-gtester: listing GTest tests failed: %d\n" % proc.returncode)
|
sys.stderr.write("tap-gtester: listing GTest tests failed: %d\n" % proc.returncode)
|
||||||
@ -105,10 +105,10 @@ class GTestCompiler(NullCompiler):
|
|||||||
if line.startswith("/"):
|
if line.startswith("/"):
|
||||||
self.test_remaining.append(line.strip())
|
self.test_remaining.append(line.strip())
|
||||||
if not self.test_remaining:
|
if not self.test_remaining:
|
||||||
print "Bail out! No tests found in GTest: %s" % self.command[0]
|
print("Bail out! No tests found in GTest: %s" % self.command[0])
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
print "1..%d" % len(self.test_remaining)
|
print("1..%d" % len(self.test_remaining))
|
||||||
|
|
||||||
# First try to run all the tests in a batch
|
# First try to run all the tests in a batch
|
||||||
proc = subprocess.Popen(self.command + ["--verbose" ], close_fds=True, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(self.command + ["--verbose" ], close_fds=True, stdout=subprocess.PIPE)
|
||||||
@ -120,7 +120,7 @@ class GTestCompiler(NullCompiler):
|
|||||||
while True:
|
while True:
|
||||||
# Assume that the last test failed
|
# Assume that the last test failed
|
||||||
if self.test_name:
|
if self.test_name:
|
||||||
print "not ok %d %s" % (self.test_num, self.test_name)
|
print("not ok %d %s" % (self.test_num, self.test_name))
|
||||||
self.test_name = None
|
self.test_name = None
|
||||||
|
|
||||||
# Run any tests which didn't get run
|
# Run any tests which didn't get run
|
||||||
@ -156,7 +156,7 @@ def main(argv):
|
|||||||
if format in ["auto", "gtest"]:
|
if format in ["auto", "gtest"]:
|
||||||
list_cmd = cmd + ["-l", "--verbose"]
|
list_cmd = cmd + ["-l", "--verbose"]
|
||||||
proc = subprocess.Popen(list_cmd, close_fds=True, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(list_cmd, close_fds=True, stdout=subprocess.PIPE)
|
||||||
output = proc.stdout.readline()
|
output = proc.stdout.readline().decode("utf-8")
|
||||||
# Smell whether we're dealing with GTest list output from first line
|
# Smell whether we're dealing with GTest list output from first line
|
||||||
if "random seed" in output or "GTest" in output or output.startswith("/"):
|
if "random seed" in output or "GTest" in output or output.startswith("/"):
|
||||||
format = "gtest"
|
format = "gtest"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
#
|
#
|
||||||
# This is a TAP compiler for python unittest
|
# This is a TAP compiler for python unittest
|
||||||
|
Loading…
Reference in New Issue
Block a user