diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/packaging/TestCasePackagerConfig.py | 2 | ||||
-rw-r--r-- | tools/packaging/common.py | 33 | ||||
-rw-r--r-- | tools/packaging/packager.py | 16 |
3 files changed, 45 insertions, 6 deletions
diff --git a/tools/packaging/TestCasePackagerConfig.py b/tools/packaging/TestCasePackagerConfig.py index e92f27b93..64210f794 100644 --- a/tools/packaging/TestCasePackagerConfig.py +++ b/tools/packaging/TestCasePackagerConfig.py @@ -78,7 +78,7 @@ def generateHarness(harnessType, jsonName, title): with open(fileName, "w") as f: for line in TEMPLATE_LINES: if "var TEST_LIST_PATH =" in line: - f.write(" var TEST_LIST_PATH = \"resources/scripts/testcases/" + jsonName + "\";" + os.linesep) + f.write(" var TEST_LIST_PATH = \"json/" + jsonName + "\";" + os.linesep) #elif "ECMAScript 5" in line: # f.write(line.replace("ECMAScript 5", "ECMAScript 5: %s" % title)) else: diff --git a/tools/packaging/common.py b/tools/packaging/common.py index ba4ffba5d..568744e9f 100644 --- a/tools/packaging/common.py +++ b/tools/packaging/common.py @@ -1,13 +1,42 @@ #--Imports--------------------------------------------------------------------- +import re #--Stubs----------------------------------------------------------------------- #--Globals--------------------------------------------------------------------- - +captureCommentPattern = re.compile(r"\/\*\*?((?:\s|\S)*?)\*\/\s*\n") +atattrs = re.compile(r"\s*\n\s*\*\s*@") +stars = re.compile(r"\s*\n\s*\*\s?") #--Helpers--------------------------------------------------------------------# - +def stripStars(text): + return stars.sub('\n', text).strip() + +def convertDocString(docString): + envelope = {} + temp = captureCommentPattern.findall(docString)[0] + propTexts = atattrs.split(temp) + envelope['commentary'] = stripStars(propTexts[0]) + del propTexts[0] + + for propText in propTexts: + # TODO: error check for mismatch + propName = re.match(r"^\w+", propText).group(0) + propVal = propText[len(propName):] + + # Just till last one-time conversion + # strip optional initial colon or final semicolon. + # The initial colon is only stripped if it comes immediately + # after the identifier with no intervening whitespace. + propVal = re.sub(r"^:\s*", '', propVal, 1) + propVal = re.sub(r";\s*$", '', propVal, 1) + propVal = stripStars(propVal) + + if propName in envelope: + raise Exception('duplicate: ' + propName) + envelope[propName] = propVal; + return envelope #--MAIN------------------------------------------------------------------------ diff --git a/tools/packaging/packager.py b/tools/packaging/packager.py index f1ee23e5f..c61d66820 100644 --- a/tools/packaging/packager.py +++ b/tools/packaging/packager.py @@ -30,6 +30,8 @@ import re import json import stat +from common import convertDocString + #--Stubs----------------------------------------------------------------------- def generateHarness(harnessType, jsonFile, description): pass @@ -144,7 +146,8 @@ def isTestStarted(line): or Sputnik tests. ''' global IS_MULTILINE_COMMENT - + #TODO + return True if IS_MULTILINE_COMMENT and ("*/" in line): #End of a newline comment IS_MULTILINE_COMMENT = False return False @@ -180,7 +183,6 @@ for temp in TEST_CONTRIB_DIRS: else: for tempSubdir in os.listdir(temp): TEST_SUITE_SECTIONS.append(os.path.join(temp, tempSubdir)) - for chapter in TEST_SUITE_SECTIONS: chapterName = chapter.rsplit(os.path.sep, 1)[1] @@ -205,7 +207,8 @@ for chapter in TEST_SUITE_SECTIONS: if EXCLUDE_LIST.count(testName)==0: # dictionary for each test testDict = {} - testDict["id"] = testName + #TODO + #testDict["id"] = testName testDict["path"] = testPath.replace("/ietestcenter", "").replace("/sputnik_converted", "") tempFile = open(test, "r") @@ -233,6 +236,13 @@ for chapter in TEST_SUITE_SECTIONS: testDict["code"] = scriptCodeContent #now close the dictionary for the test + #now get the metadata added. + tempDict = convertDocString("".join(scriptCode)) + for tempKey in tempDict.keys(): + #TODO - is this check really necessary? + if not (tempKey in ["path"]): + testDict[tempKey] = tempDict[tempKey] + #this adds the test to our tests array tests.append(testDict) testCount += 1 |