1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__
import print_function
, unicode_literals
12 import writeBuildFiles
18 line
= line
.decode('utf-8')
19 if line
== '@@@ @@@ Failures\n':
23 idx
= line
.index('@@@')
24 lines
.append((line
[:idx
], line
[idx
+ 3:]))
28 dir = path
[:path
.rfind('/')]
29 if not os
.path
.exists(dir):
32 def dumpFailures(lines
):
34 for url
, objstr
in lines
:
38 # Avoid overly large diffs.
44 jsonpath
= 'failures/' + url
+ '.json'
45 files
.append(jsonpath
)
47 obj
= json
.loads(objstr
, object_pairs_hook
=collections
.OrderedDict
)
48 formattedobjstr
= json
.dumps(obj
, indent
=2, separators
=(',', sep
)) + '\n'
49 formattedobj
= formattedobjstr
.encode('utf-8')
50 fp
= open(jsonpath
, 'wb')
51 fp
.write(formattedobj
)
55 def writeFiles(files
):
58 dirp
, leaf
= path
.rsplit('/', 1)
59 pathmap
.setdefault(dirp
, []).append(leaf
)
61 for k
, v
in pathmap
.items():
62 with
open(k
+ '/mochitest.ini', 'w') as fh
:
63 result
= writeBuildFiles
.substManifest('parseFailures.py', v
, [])
68 fp
= open(logPath
, 'rb')
69 lines
= extractLines(fp
)
72 files
= dumpFailures(lines
)
75 if __name__
== '__main__':
77 print("Please pass the path to the logfile from which failures should be extracted.")