Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: tools/foozzie/v8_foozzie_test.py

Issue 2620343005: [foozzie] Improve failure state deduplication (Closed)
Patch Set: Restrict hash to 3 digits to avoid possible duplicate explosion. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/foozzie/v8_foozzie.py ('k') | tools/foozzie/v8_suppressions.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import v8_suppressions 11 import v8_suppressions
12 12
13 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 13 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14 FOOZZIE = os.path.join(BASE_DIR, 'v8_foozzie.py') 14 FOOZZIE = os.path.join(BASE_DIR, 'v8_foozzie.py')
15 TEST_DATA = os.path.join(BASE_DIR, 'testdata') 15 TEST_DATA = os.path.join(BASE_DIR, 'testdata')
16 16
17 class UnitTest(unittest.TestCase): 17 class UnitTest(unittest.TestCase):
18 def testDiff(self): 18 def testDiff(self):
19 # TODO(machenbach): Mock out suppression configuration. 19 # TODO(machenbach): Mock out suppression configuration.
20 suppress = v8_suppressions.get_suppression( 20 suppress = v8_suppressions.get_suppression(
21 'x64', 'fullcode', 'x64', 'default') 21 'x64', 'fullcode', 'x64', 'default')
22 one = '' 22 one = ''
23 two = '' 23 two = ''
24 diff = None 24 diff = None, 'none'
25 self.assertEquals(diff, suppress.diff(one, two)) 25 self.assertEquals(diff, suppress.diff(one, two))
26 26
27 one = 'a \n b\nc();' 27 one = 'a \n b\nc();'
28 two = 'a \n b\nc();' 28 two = 'a \n b\nc();'
29 diff = None 29 diff = None, 'none'
30 self.assertEquals(diff, suppress.diff(one, two)) 30 self.assertEquals(diff, suppress.diff(one, two))
31 31
32 # Ignore line before caret, caret position, stack trace char numbers 32 # Ignore line before caret, caret position, stack trace char numbers
33 # error message and validator output. 33 # error message and validator output.
34 one = """ 34 one = """
35 undefined 35 undefined
36 weird stuff 36 weird stuff
37 ^ 37 ^
38 Validation of asm.js module failed: foo bar 38 Validation of asm.js module failed: foo bar
39 somefile.js: TypeError: undefined is not a function 39 somefile.js: TypeError: undefined is not a function
40 stack line :15: foo 40 stack line :15: foo
41 undefined 41 undefined
42 """ 42 """
43 two = """ 43 two = """
44 undefined 44 undefined
45 other weird stuff 45 other weird stuff
46 ^ 46 ^
47 somefile.js: TypeError: baz is not a function 47 somefile.js: TypeError: baz is not a function
48 stack line :2: foo 48 stack line :2: foo
49 Validation of asm.js module failed: baz 49 Validation of asm.js module failed: baz
50 undefined 50 undefined
51 """ 51 """
52 diff = None 52 diff = None, 'none'
53 self.assertEquals(diff, suppress.diff(one, two)) 53 self.assertEquals(diff, suppress.diff(one, two))
54 54
55 one = """ 55 one = """
56 Still equal 56 Still equal
57 Extra line 57 Extra line
58 """ 58 """
59 two = """ 59 two = """
60 Still equal 60 Still equal
61 """ 61 """
62 diff = '- Extra line' 62 diff = '- Extra line', 'none'
63 self.assertEquals(diff, suppress.diff(one, two)) 63 self.assertEquals(diff, suppress.diff(one, two))
64 64
65 one = """ 65 one = """
66 Still equal 66 Still equal
67 """ 67 """
68 two = """ 68 two = """
69 Still equal 69 Still equal
70 Extra line 70 Extra line
71 """ 71 """
72 diff = '+ Extra line' 72 diff = '+ Extra line', 'none'
73 self.assertEquals(diff, suppress.diff(one, two)) 73 self.assertEquals(diff, suppress.diff(one, two))
74 74
75 one = """ 75 one = """
76 undefined 76 undefined
77 somefile.js: TypeError: undefined is not a constructor 77 somefile.js: TypeError: undefined is not a constructor
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""" 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 run_foozzie(first_d8, second_d8): 88 def run_foozzie(first_d8, second_d8):
89 return subprocess.check_output([ 89 return subprocess.check_output([
90 sys.executable, FOOZZIE, 90 sys.executable, FOOZZIE,
91 '--random-seed', '12345', 91 '--random-seed', '12345',
92 '--first-d8', os.path.join(TEST_DATA, first_d8), 92 '--first-d8', os.path.join(TEST_DATA, first_d8),
93 '--second-d8', os.path.join(TEST_DATA, second_d8), 93 '--second-d8', os.path.join(TEST_DATA, second_d8),
94 '--second-config', 'ignition_staging', 94 '--second-config', 'ignition_staging',
95 os.path.join(TEST_DATA, 'fuzz-123.js'), 95 os.path.join(TEST_DATA, 'fuzz-123.js'),
96 ]) 96 ])
97 97
98 98
99 class SystemTest(unittest.TestCase): 99 class SystemTest(unittest.TestCase):
100 def testSyntaxErrorDiffPass(self): 100 def testSyntaxErrorDiffPass(self):
101 stdout = run_foozzie('test_d8_1.py', 'test_d8_2.py') 101 stdout = run_foozzie('test_d8_1.py', 'test_d8_2.py')
102 self.assertEquals('# V8 correctness - pass\n', stdout) 102 self.assertEquals('# V8 correctness - pass\n', stdout)
103 103
104 def testDifferentOutputFail(self): 104 def testDifferentOutputFail(self):
105 with open(os.path.join(TEST_DATA, 'failure_output.txt')) as f: 105 with open(os.path.join(TEST_DATA, 'failure_output.txt')) as f:
106 expected_output = f.read() 106 expected_output = f.read()
107 with self.assertRaises(subprocess.CalledProcessError) as ctx: 107 with self.assertRaises(subprocess.CalledProcessError) as ctx:
108 run_foozzie('test_d8_1.py', 'test_d8_3.py') 108 run_foozzie('test_d8_1.py', 'test_d8_3.py')
109 e = ctx.exception 109 e = ctx.exception
110 self.assertEquals(v8_foozzie.RETURN_FAIL, e.returncode) 110 self.assertEquals(v8_foozzie.RETURN_FAIL, e.returncode)
111 self.assertEquals(expected_output, e.output) 111 self.assertEquals(expected_output, e.output)
OLDNEW
« no previous file with comments | « tools/foozzie/v8_foozzie.py ('k') | tools/foozzie/v8_suppressions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698