OLD | NEW |
1 # Copyright 2016 the V8 project authors. All rights reserved. | 1 # Copyright 2016 the V8 project authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import subprocess | 6 import subprocess |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 import v8_foozzie | 10 import v8_foozzie |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 """ | 78 """ |
79 two = """ | 79 two = """ |
80 undefined | 80 undefined |
81 otherfile.js: TypeError: undefined is not a constructor | 81 otherfile.js: TypeError: undefined is not a constructor |
82 """ | 82 """ |
83 diff = """- somefile.js: TypeError: undefined is not a constructor | 83 diff = """- somefile.js: TypeError: undefined is not a constructor |
84 + otherfile.js: TypeError: undefined is not a constructor""", None | 84 + otherfile.js: TypeError: undefined is not a constructor""", None |
85 self.assertEquals(diff, suppress.diff(one, two)) | 85 self.assertEquals(diff, suppress.diff(one, two)) |
86 | 86 |
87 | 87 |
| 88 def cut_verbose_output(stdout): |
| 89 return '\n'.join(stdout.split('\n')[2:]) |
| 90 |
| 91 |
88 def run_foozzie(first_d8, second_d8): | 92 def run_foozzie(first_d8, second_d8): |
89 return subprocess.check_output([ | 93 return subprocess.check_output([ |
90 sys.executable, FOOZZIE, | 94 sys.executable, FOOZZIE, |
91 '--random-seed', '12345', | 95 '--random-seed', '12345', |
92 '--first-d8', os.path.join(TEST_DATA, first_d8), | 96 '--first-d8', os.path.join(TEST_DATA, first_d8), |
93 '--second-d8', os.path.join(TEST_DATA, second_d8), | 97 '--second-d8', os.path.join(TEST_DATA, second_d8), |
94 '--first-config', 'ignition', | 98 '--first-config', 'ignition', |
95 '--second-config', 'ignition_staging', | 99 '--second-config', 'ignition_staging', |
96 os.path.join(TEST_DATA, 'fuzz-123.js'), | 100 os.path.join(TEST_DATA, 'fuzz-123.js'), |
97 ]) | 101 ]) |
98 | 102 |
99 | 103 |
100 class SystemTest(unittest.TestCase): | 104 class SystemTest(unittest.TestCase): |
101 def testSyntaxErrorDiffPass(self): | 105 def testSyntaxErrorDiffPass(self): |
102 stdout = run_foozzie('test_d8_1.py', 'test_d8_2.py') | 106 stdout = run_foozzie('test_d8_1.py', 'test_d8_2.py') |
103 self.assertEquals('# V8 correctness - pass\n', stdout) | 107 self.assertEquals('# V8 correctness - pass\n', cut_verbose_output(stdout)) |
104 | 108 |
105 def testDifferentOutputFail(self): | 109 def testDifferentOutputFail(self): |
106 with open(os.path.join(TEST_DATA, 'failure_output.txt')) as f: | 110 with open(os.path.join(TEST_DATA, 'failure_output.txt')) as f: |
107 expected_output = f.read() | 111 expected_output = f.read() |
108 with self.assertRaises(subprocess.CalledProcessError) as ctx: | 112 with self.assertRaises(subprocess.CalledProcessError) as ctx: |
109 run_foozzie('test_d8_1.py', 'test_d8_3.py') | 113 run_foozzie('test_d8_1.py', 'test_d8_3.py') |
110 e = ctx.exception | 114 e = ctx.exception |
111 self.assertEquals(v8_foozzie.RETURN_FAIL, e.returncode) | 115 self.assertEquals(v8_foozzie.RETURN_FAIL, e.returncode) |
112 self.assertEquals(expected_output, e.output) | 116 self.assertEquals(expected_output, cut_verbose_output(e.output)) |
OLD | NEW |