From 64db10aa2df9972d6d4a38e04d054c30a6790b47 Mon Sep 17 00:00:00 2001 From: Mark Miller Date: Fri, 30 Sep 2011 03:59:50 -0400 Subject: Just reformatting to 80 columns --- tools/packaging/packager.py | 62 ++++++++++++++++++++++++++------------- tools/packaging/packagerConfig.py | 44 +++++++++++++++++---------- 2 files changed, 69 insertions(+), 37 deletions(-) (limited to 'tools') diff --git a/tools/packaging/packager.py b/tools/packaging/packager.py index af30cf743..3a81d7273 100644 --- a/tools/packaging/packager.py +++ b/tools/packaging/packager.py @@ -42,17 +42,19 @@ from packagerConfig import * #--Globals--------------------------------------------------------------------- -__parser = argparse.ArgumentParser(description='Tool used to generate the test262 website') +__parser = argparse.ArgumentParser(description= \ + 'Tool used to generate the test262 website') __parser.add_argument('version', action='store', - help='Version of the test suite.') + help='Version of the test suite.') __parser.add_argument('--type', action='store', default='test262', - help='Type of test case runner to generate.') + help='Type of test case runner to generate.') __parser.add_argument('--console', action='store_true', default=False, - help='Type of test case runner to generate.') + help='Type of test case runner to generate.') ARGS = __parser.parse_args() if not os.path.exists(EXCLUDED_FILENAME): - print "Cannot generate (JSON) test262 tests without a file, %s, showing which tests have been disabled!" % EXCLUDED_FILENAME + print "Cannot generate (JSON) test262 tests without a file," + \ + " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME sys.exit(1) EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME) EXCLUDE_LIST = EXCLUDE_LIST.getElementsByTagName("test") @@ -105,7 +107,8 @@ def createDepDirs(dirName): os.mkdir(dirName) def test262PathToConsoleFile(path): - stuff = os.path.join(TEST262_CONSOLE_CASES_DIR, path.replace("/", os.path.sep)) + stuff = os.path.join(TEST262_CONSOLE_CASES_DIR, + path.replace("/", os.path.sep)) createDepDirs(os.path.dirname(stuff)) return stuff @@ -133,7 +136,8 @@ def dirWalker(dirName): ''' global TEST_SUITE_SECTIONS #First check to see if it has test files directly inside it - temp = [os.path.join(dirName, x) for x in os.listdir(dirName) if not os.path.isdir(os.path.join(dirName, x))] + temp = [os.path.join(dirName, x) for x in os.listdir(dirName) \ + if not os.path.isdir(os.path.join(dirName, x))] if len(temp)!=0: TEST_SUITE_SECTIONS.append(dirName) return @@ -171,7 +175,8 @@ def isTestStarted(line): elif "/*" in line: #Beginning of a newline comment IS_MULTILINE_COMMENT = True return False - elif IS_MULTILINE_COMMENT: #//we're already in a multi-line comment that hasn't ended + elif IS_MULTILINE_COMMENT: #//we're already in a multi-line + #comment that hasn't ended return False elif re.match("^\s*//", line)!=None: #//blah return False @@ -221,7 +226,8 @@ for chapter in TEST_SUITE_SECTIONS: testCount = 0 for test in sourceFiles: #TODO - use something other than the hard-coded 'TestCases' below - testPath = "TestCases" + test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/") + testPath = "TestCases" + \ + test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/") testName=test.rsplit(".", 1)[0] testName=testName.rsplit(os.path.sep, 1)[1] if EXCLUDE_LIST.count(testName)==0: @@ -233,7 +239,8 @@ for chapter in TEST_SUITE_SECTIONS: scriptCode = tempFile.readlines() tempFile.close() scriptCodeContent="" - #Rip out license headers that add unnecessary bytes to the JSON'ized test cases + #Rip out license headers that add unnecessary bytes to + #the JSON'ized test cases inBeginning = True IS_MULTILINE_COMMENT = False @@ -246,7 +253,8 @@ for chapter in TEST_SUITE_SECTIONS: scriptCodeContent += line if scriptCodeContent=="": - print "WARNING (" + test + "): unable to strip comments/license header/etc." + print "WARNING (" + test + \ + "): unable to strip comments/license header/etc." scriptCodeContent = "".join(scriptCode) scriptCodeContentB64 = base64.b64encode(scriptCodeContent) @@ -265,9 +273,12 @@ for chapter in TEST_SUITE_SECTIONS: tests.append(testDict) if ARGS.console: - with open(test262PathToConsoleFile(testDict["path"]), "w") as fConsole: + with open(test262PathToConsoleFile(testDict["path"]), + "w") as fConsole: fConsole.write(scriptCodeContent) - with open(test262PathToConsoleFile(testDict["path"][:-3] + "_metadata.js"), "w") as fConsoleMeta: + with open(test262PathToConsoleFile(testDict["path"][:-3] + \ + "_metadata.js"), + "w") as fConsoleMeta: metaDict = testDict.copy() del metaDict["code"] fConsoleMeta.write("testDescrip = " + str(metaDict)) @@ -283,7 +294,8 @@ for chapter in TEST_SUITE_SECTIONS: #create a node for the tests and add it to our testsLists testsList["testsCollection"] = sect - with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"), "w") as f: + with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"), + "w") as f: json.dump(testsList, f, separators=(',',':'), sort_keys=True) @@ -291,11 +303,17 @@ for chapter in TEST_SUITE_SECTIONS: CHAPTER_TEST_CASES_JSON = {} CHAPTER_TEST_CASES_JSON["numTests"] = int(sect["numTests"]) CHAPTER_TEST_CASES_JSON["version"] = ARGS.version - CHAPTER_TEST_CASES_JSON["date"] = str(datetime.datetime.now().date()) - CHAPTER_TEST_CASES_JSON["testSuite"] = [WEBSITE_CASES_PATH + chapterName + ".json"] - with open(os.path.join(TEST262_WEB_CASES_DIR, "testcases_%s.json" % chapterName), "w") as f: - json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'), sort_keys=True) - generateHarness(ARGS.type, "testcases_%s.json" % chapterName, chapterName.replace("chapter", "Chapter ")) + CHAPTER_TEST_CASES_JSON["date"] = \ + str(datetime.datetime.now().date()) + CHAPTER_TEST_CASES_JSON["testSuite"] = \ + [WEBSITE_CASES_PATH + chapterName + ".json"] + with open(os.path.join(TEST262_WEB_CASES_DIR, + "testcases_%s.json" % chapterName), + "w") as f: + json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'), + sort_keys=True) + generateHarness(ARGS.type, "testcases_%s.json" % chapterName, + chapterName.replace("chapter", "Chapter ")) #add the name of the chapter test to our complete list SECTIONS_LIST.append(WEBSITE_CASES_PATH + chapterName + ".json") @@ -317,10 +335,12 @@ generateHarness(ARGS.type, "default.json", "Chapters 1-16") print "" print "Deploying test harness files to 'TEST262_WEB_HARNESS_DIR'..." if TEST262_HARNESS_DIR!=TEST262_WEB_HARNESS_DIR: - for filename in [x for x in os.listdir(TEST262_HARNESS_DIR) if x.endswith(".js")]: + for filename in [x for x in os.listdir(TEST262_HARNESS_DIR) \ + if x.endswith(".js")]: toFilenameList = [ os.path.join(TEST262_WEB_HARNESS_DIR, filename)] if ARGS.console: - toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR, filename)) + toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR, + filename)) for toFilename in toFilenameList: if not os.path.exists(os.path.dirname(toFilename)): diff --git a/tools/packaging/packagerConfig.py b/tools/packaging/packagerConfig.py index 1d0af2b9f..8218eb9f5 100644 --- a/tools/packaging/packagerConfig.py +++ b/tools/packaging/packagerConfig.py @@ -31,30 +31,38 @@ WEBSITE_SHORT_NAME = "website" CONSOLE_SHORT_NAME = "console" #Path to the root of the Hg repository (relative to this file's location) -TEST262_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..") +TEST262_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), + "..", "..") TEST262_ROOT = os.path.abspath(TEST262_ROOT) -#Directory full of test cases we want to port to the website's test harness runner +#Directory full of test cases we want to port to the website's test +#harness runner TEST262_CASES_DIR = os.path.join(TEST262_ROOT, "test", "suite") -#Directory containing test harness files to be ported over to the website. Note that -#only *.js files will be migrated from this dir. +#Directory containing test harness files to be ported over to the +#website. Note that only *.js files will be migrated from this dir. TEST262_HARNESS_DIR = os.path.join(TEST262_ROOT, "test", "harness") #Directory full of website test cases (ported over from TEST262_CASES_DIR) TEST262_WEB_CASES_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "json") TEST262_CONSOLE_CASES_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME) -#Directory containing the website's test harness (ported over from TEST262_HARNESS_DIR) -TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "harness") -TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME, "harness") +#Directory containing the website's test harness (ported over from +#TEST262_HARNESS_DIR) +TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, + "harness") +TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME, + "harness") -#Path to the ported test case files on the actual website as opposed to the Hg layout +#Path to the ported test case files on the actual website as opposed +#to the Hg layout WEBSITE_CASES_PATH = "json/" -#The name of a file which contains a list of tests which should be disabled in test262. -#These tests are either invalid as-per ES5 or have issues with the test262 web harness. -EXCLUDED_FILENAME = os.path.join(TEST262_ROOT, "test", "config", "excludelist.xml") +#The name of a file which contains a list of tests which should be +#disabled in test262. These tests are either invalid as-per ES5 or +#have issues with the test262 web harness. +EXCLUDED_FILENAME = os.path.join(TEST262_ROOT, "test", "config", + "excludelist.xml") WEBSITE_EXCLUDE_RE_LIST = ["bestPractice"] WEBSITE_EXCLUDE_RE_LIST = [ re.compile(x) for x in WEBSITE_EXCLUDE_RE_LIST] @@ -70,9 +78,11 @@ def generateHarness(harnessType, jsonName, title): if TEMPLATE_LINES==None or harnessType!=__lastHarnessType: __lastHarnessType = harnessType TEMPLATE_LINES = [] - with open(os.path.join(os.getcwd(), "templates","runner." + harnessType + ".html"), "r") as f: + with open(os.path.join(os.getcwd(), "templates", + "runner." + harnessType + ".html"), "r") as f: TEMPLATE_LINES = f.readlines() - fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, jsonName.replace(".json", ".html")) + fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, + jsonName.replace(".json", ".html")) fileNameExists = False if os.path.exists(fileName): SC_HELPER.edit(fileName) @@ -80,9 +90,11 @@ 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 = \"json/" + 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)) + # f.write(line.replace("ECMAScript 5", + # "ECMAScript 5: %s" % title)) else: f.write(line) if not fileNameExists: @@ -109,4 +121,4 @@ class SCAbstraction(object): ''' subprocess.call(["hg", "add", filename]) -SC_HELPER = SCAbstraction() \ No newline at end of file +SC_HELPER = SCAbstraction() -- cgit v1.2.3