michael@0: # Copyright (C) 2011-2013 Ms2ger michael@0: # michael@0: # Permission is hereby granted, free of charge, to any person obtaining a copy michael@0: # of this software and associated documentation files (the "Software"), to deal michael@0: # in the Software without restriction, including without limitation the rights michael@0: # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell michael@0: # copies of the Software, and to permit persons to whom the Software is michael@0: # furnished to do so, subject to the following conditions: michael@0: # michael@0: # The above copyright notice and this permission notice shall be included in michael@0: # all copies or substantial portions of the Software. michael@0: # michael@0: # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE michael@0: # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, michael@0: # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN michael@0: # THE SOFTWARE. michael@0: michael@0: michael@0: def parseManifest(fd): michael@0: def parseReftestLine(chunks): michael@0: assert len(chunks) % 2 == 0 michael@0: reftests = [] michael@0: for i in range(2, len(chunks), 2): michael@0: if not chunks[i] in ["==", "!="]: michael@0: raise Exception("Misformatted reftest line " + line) michael@0: reftests.append([chunks[i], chunks[1], chunks[i + 1]]) michael@0: return reftests michael@0: michael@0: dirs = [] michael@0: autotests = [] michael@0: reftests = [] michael@0: othertests = [] michael@0: supportfiles = [] michael@0: for fullline in fd: michael@0: line = fullline.strip() michael@0: if not line: michael@0: continue michael@0: michael@0: chunks = line.split(" ") michael@0: michael@0: if chunks[0] == "MANIFEST": michael@0: raise Exception("MANIFEST listed on line " + line) michael@0: michael@0: if chunks[0] == "dir": michael@0: dirs.append(chunks[1]) michael@0: elif chunks[0] == "support" and chunks[1] == "dir": michael@0: dirs.append(chunks[1]) michael@0: elif chunks[0] == "ref": michael@0: if len(chunks) % 2: michael@0: raise Exception("Missing chunk in line " + line) michael@0: reftests.extend(parseReftestLine(chunks)) michael@0: elif chunks[0] == "support": michael@0: supportfiles.append(chunks[1]) michael@0: elif chunks[0] in ["manual", "parser", "http"]: michael@0: othertests.append(chunks[1]) michael@0: else: michael@0: # automated michael@0: autotests.append(chunks[0]) michael@0: return dirs, autotests, reftests, othertests, supportfiles michael@0: michael@0: michael@0: def parseManifestFile(path): michael@0: fp = open(path) michael@0: dirs, autotests, reftests, othertests, supportfiles = parseManifest(fp) michael@0: fp.close() michael@0: return dirs, autotests, reftests, othertests, supportfiles