mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 16:34:27 +02:00
Generation: Support Python 3 (#2288)
* Generation: Use Python 3-compatible imports. * Generation: Use range() instead of xrange(). * Generation: Use list comprehensions instead of map(). * Generation: Explicitly use bytes in the Test class. * Generation: Run unit tests on Python 3 as well.
This commit is contained in:
parent
2312e123b8
commit
3ff5c0a115
@ -62,15 +62,21 @@ jobs:
|
|||||||
# - run:
|
# - run:
|
||||||
# name: "Run deploy"
|
# name: "Run deploy"
|
||||||
# command: ./tools/scripts/deploy.sh
|
# command: ./tools/scripts/deploy.sh
|
||||||
"Project lint unit tests on Python 3":
|
"Project lint and generation unit tests on Python 3":
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.7.4
|
- image: circleci/python:3.7.4
|
||||||
working_directory: ~/test262
|
working_directory: ~/test262
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: "Install requirements for generation tool"
|
||||||
|
command: python -m pip install --user --requirement tools/generation/requirements.txt
|
||||||
- run:
|
- run:
|
||||||
name: "Install requirements for linter tool"
|
name: "Install requirements for linter tool"
|
||||||
command: python -m pip install --user --requirement tools/lint/requirements.txt
|
command: python -m pip install --user --requirement tools/lint/requirements.txt
|
||||||
|
- run:
|
||||||
|
name: "Test the generation tool"
|
||||||
|
command: ./tools/generation/test/run.py
|
||||||
- run:
|
- run:
|
||||||
name: "Test the lint tool"
|
name: "Test the lint tool"
|
||||||
command: ./tools/lint/test/run.py
|
command: ./tools/lint/test/run.py
|
||||||
@ -137,7 +143,7 @@ workflows:
|
|||||||
Tools:
|
Tools:
|
||||||
jobs:
|
jobs:
|
||||||
- "Project lint, generation tests and build"
|
- "Project lint, generation tests and build"
|
||||||
- "Project lint unit tests on Python 3"
|
- "Project lint and generation unit tests on Python 3"
|
||||||
Tests execution:
|
Tests execution:
|
||||||
jobs:
|
jobs:
|
||||||
- "ChakraCore: New or modified tests execution"
|
- "ChakraCore: New or modified tests execution"
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
import codecs
|
import codecs
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from util.find_comments import find_comments
|
from .util.find_comments import find_comments
|
||||||
from util.parse_yaml import parse_yaml
|
from .util.parse_yaml import parse_yaml
|
||||||
|
|
||||||
regionStartPattern = re.compile(r'-\s+(\S+)')
|
regionStartPattern = re.compile(r'-\s+(\S+)')
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
import re, os
|
import re, os
|
||||||
|
|
||||||
from case import Case
|
from .case import Case
|
||||||
from template import Template
|
from .template import Template
|
||||||
|
|
||||||
caseFilenamePattern = re.compile(r'^[^\.].*\.case$')
|
caseFilenamePattern = re.compile(r'^[^\.].*\.case$')
|
||||||
templateFilenamePattern = re.compile(r'^[^\.].*\.template$')
|
templateFilenamePattern = re.compile(r'^[^\.].*\.template$')
|
||||||
|
@ -5,9 +5,9 @@ import os, re
|
|||||||
import codecs, yaml
|
import codecs, yaml
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from util.find_comments import find_comments
|
from .util.find_comments import find_comments
|
||||||
from util.parse_yaml import parse_yaml
|
from .util.parse_yaml import parse_yaml
|
||||||
from test import Test
|
from .test import Test
|
||||||
|
|
||||||
indentPattern = re.compile(r'^(\s*)')
|
indentPattern = re.compile(r'^(\s*)')
|
||||||
interpolatePattern = re.compile(r'\{\s*(\S+)\s*\}')
|
interpolatePattern = re.compile(r'\{\s*(\S+)\s*\}')
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
import os, re
|
import os, re
|
||||||
|
|
||||||
from util.find_comments import find_comments
|
from .util.find_comments import find_comments
|
||||||
from util.parse_yaml import parse_yaml
|
from .util.parse_yaml import parse_yaml
|
||||||
|
|
||||||
class Test:
|
class Test:
|
||||||
"""Representation of a generated test. Specifies a file location which may
|
"""Representation of a generated test. Specifies a file location which may
|
||||||
@ -19,7 +19,7 @@ class Test:
|
|||||||
|
|
||||||
def load(self, prefix = None):
|
def load(self, prefix = None):
|
||||||
location = os.path.join(prefix or '', self.file_name)
|
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.source = handle.read()
|
||||||
self._parse()
|
self._parse()
|
||||||
|
|
||||||
@ -59,5 +59,5 @@ class Test:
|
|||||||
else:
|
else:
|
||||||
raise Exception('Directory does not exist: ' + path)
|
raise Exception('Directory does not exist: ' + path)
|
||||||
|
|
||||||
with open(location, 'w') as handle:
|
with open(location, 'wb') as handle:
|
||||||
handle.write(self.source)
|
handle.write(self.source)
|
||||||
|
@ -23,7 +23,7 @@ def find_comments(source):
|
|||||||
comment = ''
|
comment = ''
|
||||||
lineno = 0
|
lineno = 0
|
||||||
|
|
||||||
for idx in xrange(len(source)):
|
for idx in range(len(source)):
|
||||||
if source[idx] == '\n':
|
if source[idx] == '\n':
|
||||||
lineno += 1
|
lineno += 1
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ class TestGeneration(unittest.TestCase):
|
|||||||
actualFiles = self.getFiles(actualPath)
|
actualFiles = self.getFiles(actualPath)
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
map(lambda x: os.path.relpath(x, expectedPath), expectedFiles),
|
[os.path.relpath(x, expectedPath) for x in expectedFiles],
|
||||||
map(lambda x: os.path.relpath(x, actualPath), actualFiles))
|
[os.path.relpath(x, actualPath) for x in actualFiles])
|
||||||
|
|
||||||
for expectedFile, actualFile in zip(expectedFiles, actualFiles):
|
for expectedFile, actualFile in zip(expectedFiles, actualFiles):
|
||||||
with open(expectedFile) as expectedHandle:
|
with open(expectedFile) as expectedHandle:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user