diff --git a/.circleci/config.yml b/.circleci/config.yml index 2b1541524d..ca9d070a92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,15 +62,21 @@ jobs: # - run: # name: "Run deploy" # command: ./tools/scripts/deploy.sh - "Project lint unit tests on Python 3": + "Project lint and generation unit tests on Python 3": docker: - image: circleci/python:3.7.4 working_directory: ~/test262 steps: - checkout + - run: + name: "Install requirements for generation tool" + command: python -m pip install --user --requirement tools/generation/requirements.txt - run: name: "Install requirements for linter tool" command: python -m pip install --user --requirement tools/lint/requirements.txt + - run: + name: "Test the generation tool" + command: ./tools/generation/test/run.py - run: name: "Test the lint tool" command: ./tools/lint/test/run.py @@ -137,7 +143,7 @@ workflows: Tools: jobs: - "Project lint, generation tests and build" - - "Project lint unit tests on Python 3" + - "Project lint and generation unit tests on Python 3" Tests execution: jobs: - "ChakraCore: New or modified tests execution" diff --git a/tools/generation/lib/case.py b/tools/generation/lib/case.py index 5ed1c63de0..7c8b99ca2d 100644 --- a/tools/generation/lib/case.py +++ b/tools/generation/lib/case.py @@ -4,8 +4,8 @@ import codecs import re -from util.find_comments import find_comments -from util.parse_yaml import parse_yaml +from .util.find_comments import find_comments +from .util.parse_yaml import parse_yaml regionStartPattern = re.compile(r'-\s+(\S+)') diff --git a/tools/generation/lib/expander.py b/tools/generation/lib/expander.py index c0b7a57136..0ce64990fe 100644 --- a/tools/generation/lib/expander.py +++ b/tools/generation/lib/expander.py @@ -3,8 +3,8 @@ import re, os -from case import Case -from template import Template +from .case import Case +from .template import Template caseFilenamePattern = re.compile(r'^[^\.].*\.case$') templateFilenamePattern = re.compile(r'^[^\.].*\.template$') diff --git a/tools/generation/lib/template.py b/tools/generation/lib/template.py index 88e92a9d72..16eb2ccd92 100644 --- a/tools/generation/lib/template.py +++ b/tools/generation/lib/template.py @@ -5,9 +5,9 @@ import os, re import codecs, yaml from collections import OrderedDict -from util.find_comments import find_comments -from util.parse_yaml import parse_yaml -from test import Test +from .util.find_comments import find_comments +from .util.parse_yaml import parse_yaml +from .test import Test indentPattern = re.compile(r'^(\s*)') interpolatePattern = re.compile(r'\{\s*(\S+)\s*\}') diff --git a/tools/generation/lib/test.py b/tools/generation/lib/test.py index 1dd6d45f73..bf4079fb24 100644 --- a/tools/generation/lib/test.py +++ b/tools/generation/lib/test.py @@ -3,8 +3,8 @@ import os, re -from util.find_comments import find_comments -from util.parse_yaml import parse_yaml +from .util.find_comments import find_comments +from .util.parse_yaml import parse_yaml class Test: """Representation of a generated test. Specifies a file location which may @@ -19,7 +19,7 @@ class Test: def load(self, prefix = None): location = os.path.join(prefix or '', self.file_name) - with open(location) as handle: + with open(location, 'rb') as handle: self.source = handle.read() self._parse() @@ -59,5 +59,5 @@ class Test: else: raise Exception('Directory does not exist: ' + path) - with open(location, 'w') as handle: + with open(location, 'wb') as handle: handle.write(self.source) diff --git a/tools/generation/lib/util/find_comments.py b/tools/generation/lib/util/find_comments.py index bf4b0ffd7b..f93f336709 100644 --- a/tools/generation/lib/util/find_comments.py +++ b/tools/generation/lib/util/find_comments.py @@ -23,7 +23,7 @@ def find_comments(source): comment = '' lineno = 0 - for idx in xrange(len(source)): + for idx in range(len(source)): if source[idx] == '\n': lineno += 1 diff --git a/tools/generation/test/run.py b/tools/generation/test/run.py index c21efa1b83..e2941223cc 100755 --- a/tools/generation/test/run.py +++ b/tools/generation/test/run.py @@ -36,8 +36,8 @@ class TestGeneration(unittest.TestCase): actualFiles = self.getFiles(actualPath) self.assertListEqual( - map(lambda x: os.path.relpath(x, expectedPath), expectedFiles), - map(lambda x: os.path.relpath(x, actualPath), actualFiles)) + [os.path.relpath(x, expectedPath) for x in expectedFiles], + [os.path.relpath(x, actualPath) for x in actualFiles]) for expectedFile, actualFile in zip(expectedFiles, actualFiles): with open(expectedFile) as expectedHandle: