diff options
-rw-r--r-- | .appveyor.yml | 3 | ||||
-rw-r--r-- | .github/workflows/build.yml | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rwxr-xr-x | scripts/gen-emscripten-exported-json.py | 2 | ||||
-rwxr-xr-x | scripts/sha256sum.py | 1 | ||||
-rwxr-xr-x | src/wasm2c_tmpl.py | 8 | ||||
-rw-r--r-- | test/README.md | 2 | ||||
-rw-r--r-- | test/find_exe.py | 2 | ||||
-rwxr-xr-x | test/gen-spec-js.py | 9 | ||||
-rwxr-xr-x | test/gen-wasm.py | 3 | ||||
-rwxr-xr-x | test/run-c-api-examples.py | 2 | ||||
-rwxr-xr-x | test/run-roundtrip.py | 2 | ||||
-rwxr-xr-x | test/run-spec-wasm2c.py | 21 | ||||
-rwxr-xr-x | test/run-tests.py | 15 | ||||
-rwxr-xr-x | test/update-spec-tests.py | 3 | ||||
-rw-r--r-- | test/utils.py | 3 |
16 files changed, 24 insertions, 69 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index b07300e7..919bd28d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,7 +1,8 @@ --- init: - - set PATH=C:\Python27\Scripts;%PATH% # while python's bin is already in PATH, but pip.exe in Scripts\ dir isn't + # AppVeyor default is python2, but we want python 3 + - set PATH=C:\Python36;C:\Python36\Scripts;%PATH% - set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH% # Python doesn't seem to be able to import files from the current script's # directory on Windows. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ea6dc43..64ba8511 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,16 +9,10 @@ jobs: strategy: matrix: os: [ubuntu-16.04, macos-latest, windows-latest] - python: [2.7, '3.x'] - exclude: - - os: macos-latest - python: '3.x' - - os: windows-latest - python: '3.x' steps: - uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python }} + python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true diff --git a/CMakeLists.txt b/CMakeLists.txt index efb60181..dbe7597d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,14 +515,9 @@ if (NOT EMSCRIPTEN) set(USES_TERMINAL USES_TERMINAL) endif () + # Python 3.5 is the version shipped in Ubuntu Xenial + find_package(PythonInterp 3.5 REQUIRED) # test running - # TODO(sbc): Requrie python3 for running tests. - # For now we don't set a version here due to and issue with github actions - # where python 2.7 is in the PATH as "python.exe" but a mingw version is - # installed as "python2.7.exe" and cmake will alwasy choose the later (which - # we don't want) if we specify 2.7 explictly here. - # See: https://github.com/actions/setup-python/issues/40 - find_package(PythonInterp REQUIRED) set(RUN_TESTS_PY ${WABT_SOURCE_DIR}/test/run-tests.py) add_custom_target(run-tests diff --git a/scripts/gen-emscripten-exported-json.py b/scripts/gen-emscripten-exported-json.py index 7f5246f2..3eaca462 100755 --- a/scripts/gen-emscripten-exported-json.py +++ b/scripts/gen-emscripten-exported-json.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # diff --git a/scripts/sha256sum.py b/scripts/sha256sum.py index 5caedf5f..7d8cf3d1 100755 --- a/scripts/sha256sum.py +++ b/scripts/sha256sum.py @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function import argparse import hashlib import sys diff --git a/src/wasm2c_tmpl.py b/src/wasm2c_tmpl.py index b854d887..af3b953e 100755 --- a/src/wasm2c_tmpl.py +++ b/src/wasm2c_tmpl.py @@ -15,12 +15,8 @@ # limitations under the License. # -from __future__ import print_function import argparse -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO +import io import os import sys @@ -52,7 +48,7 @@ def main(args): options = arg_parser.parse_args(args) section_name = None - output = StringIO() + output = io.StringIO() output.write('/* Generated from \'%s\' by wasm2c_tmpl.py, do not edit! */\n' % os.path.basename(options.file)) diff --git a/test/README.md b/test/README.md index 669fd28d..689e8c99 100644 --- a/test/README.md +++ b/test/README.md @@ -7,6 +7,8 @@ All end-to-end tests are written using a text format that is parsed by `test/run-tests.py`. All files with the extension `.txt` recursively under the `test` directory will be run as tests. +The test runner itself is written in python and requires python 3.5 or above. + ## Running the test suite To run all the tests with default configuration: diff --git a/test/find_exe.py b/test/find_exe.py index 67fcf01c..040c1ee6 100644 --- a/test/find_exe.py +++ b/test/find_exe.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # diff --git a/test/gen-spec-js.py b/test/gen-spec-js.py index 7e222781..826e45a4 100755 --- a/test/gen-spec-js.py +++ b/test/gen-spec-js.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # @@ -18,10 +18,7 @@ """Convert a JSON descrption of a spec test into a JavaScript.""" import argparse -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO +import io import json import os import re @@ -524,7 +521,7 @@ def main(args): new_module_filename = extender.Extend(wasm_path, assert_commands) module_command['filename'] = new_module_filename - output = StringIO() + output = io.StringIO() if options.prefix: with open(options.prefix) as prefix_file: output.write(prefix_file.read()) diff --git a/test/gen-wasm.py b/test/gen-wasm.py index 26d58fda..31de03d1 100755 --- a/test/gen-wasm.py +++ b/test/gen-wasm.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # @@ -15,7 +15,6 @@ # limitations under the License. # -from __future__ import print_function import argparse import os import struct diff --git a/test/run-c-api-examples.py b/test/run-c-api-examples.py index 7511a002..40a43c87 100755 --- a/test/run-c-api-examples.py +++ b/test/run-c-api-examples.py @@ -15,8 +15,6 @@ # limitations under the License. # -from __future__ import print_function - import argparse import os import subprocess diff --git a/test/run-roundtrip.py b/test/run-roundtrip.py index 61c01533..5f28fa9c 100755 --- a/test/run-roundtrip.py +++ b/test/run-roundtrip.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # diff --git a/test/run-spec-wasm2c.py b/test/run-spec-wasm2c.py index 4d33116e..2a18b426 100755 --- a/test/run-spec-wasm2c.py +++ b/test/run-spec-wasm2c.py @@ -15,12 +15,8 @@ # limitations under the License. # -from __future__ import print_function import argparse -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO +import io import json import os import re @@ -97,8 +93,7 @@ def MangleTypes(types): def MangleName(s): def Mangle(match): s = match.group(0) - c = ord(s) if isinstance(s, str) else s[0] # Python2 vs Python3 - return b'Z%02X' % c + return b'Z%02X' % s[0] # NOTE(binji): Z is not allowed. pattern = b'([^_a-zA-Y0-9])' @@ -381,7 +376,7 @@ def main(args): with open(options.prefix) as prefix_file: prefix = prefix_file.read() + '\n' - output = StringIO() + output = io.StringIO() cwriter = CWriter(spec_json, prefix, output, out_dir) cwriter.Write() @@ -417,12 +412,4 @@ def main(args): if __name__ == '__main__': - try: - sys.exit(main(sys.argv[1:])) - except Error as e: - # TODO(binji): gcc will output unicode quotes in errors since the terminal - # environment allows it, but python2 stderr will always attempt to convert - # to ascii first, which fails. This will replace the invalid characters - # instead, which is ugly, but works. - sys.stderr.write(u'{0}\n'.format(e).encode('ascii', 'replace')) - sys.exit(1) + sys.exit(main(sys.argv[1:])) diff --git a/test/run-tests.py b/test/run-tests.py index 9df51e26..02799f17 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # @@ -15,7 +15,6 @@ # limitations under the License. # -from __future__ import print_function import argparse import difflib import fnmatch @@ -524,17 +523,7 @@ class TestInfo(object): else: m = re.match(b'\\s*;;;(.*)$', line) if m: - # The matched string has type bytes, but in python2 - # that is the same as str. In python3 that needs to be - # decoded first. If we decode the string in python2 the - # result is a unicode string, which doesn't work - # everywhere (as used in a subprocess environment, for - # example). - if sys.version_info.major == 3: - directive = m.group(1).decode('utf-8').strip() - else: - directive = m.group(1).strip() - + directive = m.group(1).decode('utf-8').strip() if state == 'header': key, value = directive.split(':', 1) key = key.strip() diff --git a/test/update-spec-tests.py b/test/update-spec-tests.py index 0bcbab39..7ca0c879 100755 --- a/test/update-spec-tests.py +++ b/test/update-spec-tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # @@ -15,7 +15,6 @@ # limitations under the License. # -from __future__ import print_function import argparse import os import sys diff --git a/test/utils.py b/test/utils.py index bdb36e6e..6bbcb8af 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 WebAssembly Community Group participants # @@ -15,7 +15,6 @@ # limitations under the License. # -from __future__ import print_function import contextlib import os import json |