Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from chrome_profiler import postprocessor | |
| 6 | |
| 7 import json | |
| 8 import tempfile | |
| 9 import unittest | |
| 10 | |
| 11 | |
| 12 class PostprocessorTest(unittest.TestCase): | |
| 13 def testJsonTraceMerging(self): | |
| 14 t1 = {'traceEvents': [{'ts': 123, 'ph': 'b'}]} | |
| 15 t2 = {'traceEvents': [], 'stackFrames': ['blah']} | |
| 16 | |
| 17 with tempfile.NamedTemporaryFile(delete=False) as f1: | |
| 18 with tempfile.NamedTemporaryFile(delete=False) as f2: | |
|
bulach
2014/06/04 10:34:12
why delete=False? the with would only close them a
Sami
2014/06/04 15:16:59
Both of these files get deleted during merging, an
| |
| 19 f1.write(json.dumps(t1)) | |
| 20 f2.write(json.dumps(t2)) | |
| 21 f1.flush() | |
| 22 f2.flush() | |
| 23 | |
| 24 with tempfile.NamedTemporaryFile() as output: | |
| 25 postprocessor.PackageTraces([f1.name, f2.name], | |
| 26 output.name, | |
| 27 compress=False, | |
| 28 write_json=True) | |
| 29 with open(output.name) as output: | |
| 30 output = json.load(output) | |
| 31 self.assertEquals(output['traceEvents'], t1['traceEvents']) | |
| 32 self.assertEquals(output['stackFrames'], t2['stackFrames']) | |
| OLD | NEW |