|
| 1 | +diff --git "a/src/test262.py" "b/src/test262.py" |
| 2 | +index c92e5bf..a6722d8 100644 |
| 3 | +--- "a/src/test262.py" |
| 4 | ++++ "b/src/test262.py" |
| 5 | +@@ -42,8 +42,8 @@ def ReportError(s): |
| 6 | + |
| 7 | + |
| 8 | + if not os.path.exists(EXCLUDED_FILENAME): |
| 9 | +- print "Cannot generate (JSON) test262 tests without a file," + \ |
| 10 | +- " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME |
| 11 | ++ print ("Cannot generate (JSON) test262 tests without a file," + \ |
| 12 | ++ " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME) |
| 13 | + sys.exit(1) |
| 14 | + EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME) |
| 15 | + EXCLUDE_REASON = EXCLUDE_LIST.getElementsByTagName("reason") |
| 16 | +@@ -111,10 +111,10 @@ class TempFile(object): |
| 17 | + text = self.text) |
| 18 | + |
| 19 | + def Write(self, str): |
| 20 | +- os.write(self.fd, str) |
| 21 | ++ os.write(self.fd, str.encode()) |
| 22 | + |
| 23 | + def Read(self): |
| 24 | +- f = file(self.name) |
| 25 | ++ f = open(self.name, "r", encoding="latin-1") |
| 26 | + result = f.read() |
| 27 | + f.close() |
| 28 | + return result |
| 29 | +@@ -128,7 +128,7 @@ class TempFile(object): |
| 30 | + try: |
| 31 | + self.Close() |
| 32 | + os.unlink(self.name) |
| 33 | +- except OSError, e: |
| 34 | ++ except OSError as e: |
| 35 | + logging.error("Error disposing temp file: %s", str(e)) |
| 36 | + |
| 37 | + |
| 38 | +@@ -145,20 +145,20 @@ class TestResult(object): |
| 39 | + mode = self.case.GetMode() |
| 40 | + if self.HasUnexpectedOutcome(): |
| 41 | + if self.case.IsNegative(): |
| 42 | +- print "=== %s was expected to fail in %s, but didn't ===" % (name, mode) |
| 43 | +- print "--- expected error: %s ---\n" % self.case.GetNegativeType() |
| 44 | ++ print ("=== %s was expected to fail in %s, but didn't ===" % (name, mode)) |
| 45 | ++ print ("--- expected error: %s ---\n" % self.case.GetNegativeType()) |
| 46 | + else: |
| 47 | + if long_format: |
| 48 | +- print "=== %s failed in %s ===" % (name, mode) |
| 49 | ++ print ("=== %s failed in %s ===" % (name, mode)) |
| 50 | + else: |
| 51 | +- print "%s in %s: " % (name, mode) |
| 52 | ++ print ("%s in %s: " % (name, mode)) |
| 53 | + self.WriteOutput(sys.stdout) |
| 54 | + if long_format: |
| 55 | +- print "===" |
| 56 | ++ print ("===") |
| 57 | + elif self.case.IsNegative(): |
| 58 | +- print "%s failed in %s as expected" % (name, mode) |
| 59 | ++ print ("%s failed in %s as expected" % (name, mode)) |
| 60 | + else: |
| 61 | +- print "%s passed in %s" % (name, mode) |
| 62 | ++ print ("%s passed in %s" % (name, mode)) |
| 63 | + |
| 64 | + def WriteOutput(self, target): |
| 65 | + out = self.stdout.strip() |
| 66 | +@@ -302,7 +302,6 @@ class TestCase(object): |
| 67 | + return self.test |
| 68 | + |
| 69 | + source = self.suite.GetInclude("sta.js") + \ |
| 70 | +- self.suite.GetInclude("cth.js") + \ |
| 71 | + self.suite.GetInclude("assert.js") |
| 72 | + |
| 73 | + if self.IsAsyncTest(): |
| 74 | +@@ -373,7 +372,7 @@ class TestCase(object): |
| 75 | + return result |
| 76 | + |
| 77 | + def Print(self): |
| 78 | +- print self.GetSource() |
| 79 | ++ print (self.GetSource()) |
| 80 | + |
| 81 | + def validate(self): |
| 82 | + flags = self.testRecord.get("flags") |
| 83 | +@@ -488,7 +487,7 @@ class TestSuite(object): |
| 84 | + basename = path.basename(full_path)[:-3] |
| 85 | + name = rel_path.split(path.sep)[:-1] + [basename] |
| 86 | + if EXCLUDE_LIST.count(basename) >= 1: |
| 87 | +- print 'Excluded: ' + basename |
| 88 | ++ print ('Excluded: ' + basename) |
| 89 | + else: |
| 90 | + if not self.non_strict_only: |
| 91 | + strict_case = TestCase(self, name, full_path, True) |
| 92 | +@@ -511,9 +510,9 @@ class TestSuite(object): |
| 93 | + def write(s): |
| 94 | + if logfile: |
| 95 | + self.logf.write(s + "\n") |
| 96 | +- print s |
| 97 | ++ print (s) |
| 98 | + |
| 99 | +- print |
| 100 | ++ print () |
| 101 | + write("=== Summary ==="); |
| 102 | + count = progress.count |
| 103 | + succeeded = progress.succeeded |
| 104 | +@@ -527,12 +526,12 @@ class TestSuite(object): |
| 105 | + positive = [c for c in progress.failed_tests if not c.case.IsNegative()] |
| 106 | + negative = [c for c in progress.failed_tests if c.case.IsNegative()] |
| 107 | + if len(positive) > 0: |
| 108 | +- print |
| 109 | ++ print () |
| 110 | + write("Failed Tests") |
| 111 | + for result in positive: |
| 112 | + write(" %s in %s" % (result.case.GetName(), result.case.GetMode())) |
| 113 | + if len(negative) > 0: |
| 114 | +- print |
| 115 | ++ print () |
| 116 | + write("Expected to fail but passed ---") |
| 117 | + for result in negative: |
| 118 | + write(" %s in %s" % (result.case.GetName(), result.case.GetMode())) |
| 119 | +@@ -541,7 +540,7 @@ class TestSuite(object): |
| 120 | + for result in progress.failed_tests: |
| 121 | + if logfile: |
| 122 | + self.WriteLog(result) |
| 123 | +- print |
| 124 | ++ print () |
| 125 | + result.ReportOutcome(False) |
| 126 | + |
| 127 | + def Run(self, command_template, tests, print_summary, full_summary, logname, junitfile): |
| 128 | +@@ -585,9 +584,9 @@ class TestSuite(object): |
| 129 | + if full_summary: |
| 130 | + self.PrintFailureOutput(progress, logname) |
| 131 | + else: |
| 132 | +- print |
| 133 | +- print "Use --full-summary to see output from failed tests" |
| 134 | +- print |
| 135 | ++ print () |
| 136 | ++ print ("Use --full-summary to see output from failed tests") |
| 137 | ++ print () |
| 138 | + return progress.failed |
| 139 | + |
| 140 | + def WriteLog(self, result): |
| 141 | +@@ -619,7 +618,7 @@ class TestSuite(object): |
| 142 | + includes = case.GetIncludeList() |
| 143 | + includes_dict.update(includes) |
| 144 | + |
| 145 | +- print includes_dict |
| 146 | ++ print (includes_dict) |
| 147 | + |
| 148 | + |
| 149 | + def Main(): |
| 150 | +@@ -659,6 +658,6 @@ if __name__ == '__main__': |
| 151 | + try: |
| 152 | + code = Main() |
| 153 | + sys.exit(code) |
| 154 | +- except Test262Error, e: |
| 155 | +- print "Error: %s" % e.message |
| 156 | ++ except Test262Error as e: |
| 157 | ++ print ("Error: %s" % e.message) |
| 158 | + sys.exit(1) |
0 commit comments