OSDN Git Service

ART: Run Checker with Python >2.6
authorDavid Brazdil <dbrazdil@google.com>
Tue, 20 Jan 2015 09:28:38 +0000 (09:28 +0000)
committerDavid Brazdil <dbrazdil@google.com>
Tue, 20 Jan 2015 09:35:18 +0000 (09:35 +0000)
Chromium buildbots don't have Python 3. This patch fixes the uses
of print() and ASCII vs. Unicode strings to make Checker compatible
with Python 2.6 and above.

Change-Id: Ic065d990f668b8cf95a337aae037699e8474fcee

tools/checker.py
tools/checker_test.py

index b71eac6..55f015e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python2
 #
 # Copyright (C) 2014 The Android Open Source Project
 #
@@ -71,6 +71,7 @@
 #   constant folding returns an integer constant with value either 11 or 22.
 #
 
+from __future__ import print_function
 import argparse
 import os
 import re
index 1466b93..18152b5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python2
 #
 # Copyright (C) 2014 The Android Open Source Project
 #
@@ -359,6 +359,8 @@ class TestCheckGroup_Match(unittest.TestCase):
 
 class TestOutputFile_Parse(unittest.TestCase):
   def __parsesTo(self, string, expected):
+    if isinstance(string, str):
+      string = unicode(string)
     outputStream = io.StringIO(string)
     return self.assertEqual(checker.OutputFile(outputStream).groups, expected)
 
@@ -421,6 +423,8 @@ class TestOutputFile_Parse(unittest.TestCase):
 
 class TestCheckFile_Parse(unittest.TestCase):
   def __parsesTo(self, string, expected):
+    if isinstance(string, str):
+      string = unicode(string)
     checkStream = io.StringIO(string)
     return self.assertEqual(checker.CheckFile("CHECK", checkStream).groups, expected)