$OpenBSD: patch-build_tap-gtester,v 1.1 2016/04/16 08:18:27 ajacoutot Exp $

From d50dbae41ef973b0a858dbda5db91b8658787f3b Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mitya57@gmail.com>
Date: Wed, 6 Apr 2016 10:37:38 +0200
Subject: build: Port to Python 3

--- build/tap-gtester.orig	Tue Sep 23 09:49:21 2014
+++ build/tap-gtester	Sat Apr 16 10:14:16 2016
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2014 Red Hat, Inc.
 #
@@ -42,7 +42,7 @@ class NullCompiler:
 
     def process(self, proc):
         while True:
-            line = proc.stdout.readline()
+            line = proc.stdout.readline().decode("utf-8")
             if not line:
                 break
             self.input(line)
@@ -75,27 +75,27 @@ class GTestCompiler(NullCompiler):
                self.test_num += 1
            elif cmd == "result":
                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":
-                   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
            elif cmd == "skipping":
                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
            elif data:
-               print "# %s: %s" % (cmd, data)
+               print("# %s: %s" % (cmd, data))
            else:
-               print "# %s" % cmd
+               print("# %s" % cmd)
         elif line.startswith("(MSG: "):
-            print "# %s" % line[6:-1]
+            print("# %s" % line[6:-1])
         elif line:
-            print "# %s" % line
+            print("# %s" % line)
         sys.stdout.flush()
 
     def run(self, proc, output=""):
         # Complete retrieval of the list of tests
-        output += proc.stdout.read()
+        output += proc.stdout.read().decode("utf-8")
         proc.wait()
         if 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("/"):
                 self.test_remaining.append(line.strip())
         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
 
-        print "1..%d" % len(self.test_remaining)
+        print("1..%d" % len(self.test_remaining))
 
         # First try to run all the tests in a batch
         proc = subprocess.Popen(self.command + ["--verbose" ], close_fds=True, stdout=subprocess.PIPE)
@@ -120,7 +120,7 @@ class GTestCompiler(NullCompiler):
         while True:
             # Assume that the last test failed
             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
 
             # Run any tests which didn't get run
@@ -156,7 +156,7 @@ def main(argv):
     if format in ["auto", "gtest"]:
         list_cmd = cmd + ["-l", "--verbose"]
         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
         if "random seed" in output or "GTest" in output or output.startswith("/"):
             format = "gtest"
