dom/imptests/parseManifest.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 # Copyright (C) 2011-2013 Ms2ger
michael@0 2 #
michael@0 3 # Permission is hereby granted, free of charge, to any person obtaining a copy
michael@0 4 # of this software and associated documentation files (the "Software"), to deal
michael@0 5 # in the Software without restriction, including without limitation the rights
michael@0 6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
michael@0 7 # copies of the Software, and to permit persons to whom the Software is
michael@0 8 # furnished to do so, subject to the following conditions:
michael@0 9 #
michael@0 10 # The above copyright notice and this permission notice shall be included in
michael@0 11 # all copies or substantial portions of the Software.
michael@0 12 #
michael@0 13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
michael@0 14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
michael@0 15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
michael@0 16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
michael@0 17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
michael@0 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
michael@0 19 # THE SOFTWARE.
michael@0 20
michael@0 21
michael@0 22 def parseManifest(fd):
michael@0 23 def parseReftestLine(chunks):
michael@0 24 assert len(chunks) % 2 == 0
michael@0 25 reftests = []
michael@0 26 for i in range(2, len(chunks), 2):
michael@0 27 if not chunks[i] in ["==", "!="]:
michael@0 28 raise Exception("Misformatted reftest line " + line)
michael@0 29 reftests.append([chunks[i], chunks[1], chunks[i + 1]])
michael@0 30 return reftests
michael@0 31
michael@0 32 dirs = []
michael@0 33 autotests = []
michael@0 34 reftests = []
michael@0 35 othertests = []
michael@0 36 supportfiles = []
michael@0 37 for fullline in fd:
michael@0 38 line = fullline.strip()
michael@0 39 if not line:
michael@0 40 continue
michael@0 41
michael@0 42 chunks = line.split(" ")
michael@0 43
michael@0 44 if chunks[0] == "MANIFEST":
michael@0 45 raise Exception("MANIFEST listed on line " + line)
michael@0 46
michael@0 47 if chunks[0] == "dir":
michael@0 48 dirs.append(chunks[1])
michael@0 49 elif chunks[0] == "support" and chunks[1] == "dir":
michael@0 50 dirs.append(chunks[1])
michael@0 51 elif chunks[0] == "ref":
michael@0 52 if len(chunks) % 2:
michael@0 53 raise Exception("Missing chunk in line " + line)
michael@0 54 reftests.extend(parseReftestLine(chunks))
michael@0 55 elif chunks[0] == "support":
michael@0 56 supportfiles.append(chunks[1])
michael@0 57 elif chunks[0] in ["manual", "parser", "http"]:
michael@0 58 othertests.append(chunks[1])
michael@0 59 else:
michael@0 60 # automated
michael@0 61 autotests.append(chunks[0])
michael@0 62 return dirs, autotests, reftests, othertests, supportfiles
michael@0 63
michael@0 64
michael@0 65 def parseManifestFile(path):
michael@0 66 fp = open(path)
michael@0 67 dirs, autotests, reftests, othertests, supportfiles = parseManifest(fp)
michael@0 68 fp.close()
michael@0 69 return dirs, autotests, reftests, othertests, supportfiles

mercurial