| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from collections import namedtuple | 6 from collections import namedtuple |
| 7 import coverage | 7 import coverage |
| 8 import json | 8 import json |
| 9 from mock import DEFAULT | 9 from mock import DEFAULT |
| 10 from mock import MagicMock | 10 from mock import MagicMock |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 self._WriteTestInput(V8_JSON) | 286 self._WriteTestInput(V8_JSON) |
| 287 self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"]) | 287 self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"]) |
| 288 self.assertEquals(0, self._CallMain("--buildbot")) | 288 self.assertEquals(0, self._CallMain("--buildbot")) |
| 289 self._VerifyResults("test", "score", [ | 289 self._VerifyResults("test", "score", [ |
| 290 {"name": "Richards", "results": ["1.234"], "stddev": ""}, | 290 {"name": "Richards", "results": ["1.234"], "stddev": ""}, |
| 291 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, | 291 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, |
| 292 ]) | 292 ]) |
| 293 self._VerifyErrors([]) | 293 self._VerifyErrors([]) |
| 294 self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js") | 294 self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js") |
| 295 | 295 |
| 296 def testBuildbotWithTotal(self): |
| 297 test_input = dict(V8_JSON) |
| 298 test_input["total"] = True |
| 299 self._WriteTestInput(test_input) |
| 300 self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"]) |
| 301 self.assertEquals(0, self._CallMain("--buildbot")) |
| 302 self._VerifyResults("test", "score", [ |
| 303 {"name": "Richards", "results": ["1.234"], "stddev": ""}, |
| 304 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, |
| 305 {"name": "Total", "results": ["3626.49109719"], "stddev": ""}, |
| 306 ]) |
| 307 self._VerifyErrors([]) |
| 308 self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js") |
| 309 |
| 310 def testBuildbotWithTotalAndErrors(self): |
| 311 test_input = dict(V8_JSON) |
| 312 test_input["total"] = True |
| 313 self._WriteTestInput(test_input) |
| 314 self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"]) |
| 315 self.assertEquals(1, self._CallMain("--buildbot")) |
| 316 self._VerifyResults("test", "score", [ |
| 317 {"name": "Richards", "results": [], "stddev": ""}, |
| 318 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, |
| 319 ]) |
| 320 self._VerifyErrors( |
| 321 ["Regexp \"^Richards: (.+)$\" didn't match for benchmark Richards.", |
| 322 "Not all traces have the same number of results."]) |
| 323 self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js") |
| 324 |
| 296 def testRegexpNoMatch(self): | 325 def testRegexpNoMatch(self): |
| 297 self._WriteTestInput(V8_JSON) | 326 self._WriteTestInput(V8_JSON) |
| 298 self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"]) | 327 self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"]) |
| 299 self.assertEquals(1, self._CallMain()) | 328 self.assertEquals(1, self._CallMain()) |
| 300 self._VerifyResults("test", "score", [ | 329 self._VerifyResults("test", "score", [ |
| 301 {"name": "Richards", "results": [], "stddev": ""}, | 330 {"name": "Richards", "results": [], "stddev": ""}, |
| 302 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, | 331 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, |
| 303 ]) | 332 ]) |
| 304 self._VerifyErrors( | 333 self._VerifyErrors( |
| 305 ["Regexp \"^Richards: (.+)$\" didn't match for benchmark Richards."]) | 334 ["Regexp \"^Richards: (.+)$\" didn't match for benchmark Richards."]) |
| 306 self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js") | 335 self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js") |
| 307 | 336 |
| 308 def testOneRunGeneric(self): | 337 def testOneRunGeneric(self): |
| 309 test_input = dict(V8_GENERIC_JSON) | 338 test_input = dict(V8_GENERIC_JSON) |
| 310 self._WriteTestInput(test_input) | 339 self._WriteTestInput(test_input) |
| 311 self._MockCommand(["."], [ | 340 self._MockCommand(["."], [ |
| 312 "Trace(Test1), Result(1.234), StdDev(0.23)\n" | 341 "Trace(Test1), Result(1.234), StdDev(0.23)\n" |
| 313 "Trace(Test2), Result(10657567), StdDev(106)\n"]) | 342 "Trace(Test2), Result(10657567), StdDev(106)\n"]) |
| 314 self.assertEquals(0, self._CallMain()) | 343 self.assertEquals(0, self._CallMain()) |
| 315 self._VerifyResults("test", "ms", [ | 344 self._VerifyResults("test", "ms", [ |
| 316 {"name": "Test1", "results": ["1.234"], "stddev": "0.23"}, | 345 {"name": "Test1", "results": ["1.234"], "stddev": "0.23"}, |
| 317 {"name": "Test2", "results": ["10657567"], "stddev": "106"}, | 346 {"name": "Test2", "results": ["10657567"], "stddev": "106"}, |
| 318 ]) | 347 ]) |
| 319 self._VerifyErrors([]) | 348 self._VerifyErrors([]) |
| 320 self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "") | 349 self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "") |
| OLD | NEW |