mirror of
https://github.com/openharmony/third_party_astc-encoder.git
synced 2026-08-26 18:26:43 -04:00
d07c3d8d7f
This PR adds the beginnings of a command line functional test suite, ensuring that command line options are correctly wired up and processed. For this first PR not every option is tested, but this suite includes positive tests and negative tests for all of the common operations. See the testing documentation page for more details on how to run these tests. Some negative tests are currently marked as skipped pending bug fix (notably, the code is intolerant of missing input files, or output directories), so the test suite does currently pass on both Windows and Linux (macOS should pass, but is not tested). In addition this commit increases the astcenc stack size on Windows to 4MB. We have had persistent problem with stack space on Windows builds, which only have 1MB stacks by default compared to Linux which reserves 8MB. Something in a recent VS2019 upgrade make the build use more stack space which just pushed us over the 1MB limit, so bumped these up to 4MB which should be more than enough.
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
# -----------------------------------------------------------------------------
|
|
# Copyright 2020 Arm Limited
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy
|
|
# of the License at:
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
# -----------------------------------------------------------------------------
|
|
"""
|
|
The python test runner is designed to run some basic tests against the Python
|
|
test code base.
|
|
"""
|
|
|
|
import re
|
|
import sys
|
|
import unittest
|
|
|
|
import pycodestyle
|
|
import pylint.epylint as lint
|
|
|
|
|
|
class PythonTests(unittest.TestCase):
|
|
"""
|
|
Some basic Python static analysis and style checks.
|
|
"""
|
|
|
|
def test_pylint(self):
|
|
"""
|
|
Run pylint over the codebase.
|
|
"""
|
|
pylintOut, _ = lint.py_run("./Test", True)
|
|
pattern = re.compile(r"Your code has been rated at (.*?)/10")
|
|
match = pattern.search(pylintOut.getvalue())
|
|
self.assertIsNotNone(match)
|
|
score = float(match.group(1))
|
|
self.assertGreaterEqual(score, 9.8)
|
|
|
|
with open("pylint.log", "w") as fileHandle:
|
|
fileHandle.write(pylintOut.getvalue())
|
|
|
|
def test_pycodestyle(self):
|
|
"""
|
|
Test that we conform to PEP-8.
|
|
"""
|
|
style = pycodestyle.StyleGuide()
|
|
result = style.check_files(["./Test"])
|
|
self.assertEqual(result.total_errors, 0,
|
|
"Found code style errors (and warnings).")
|
|
|
|
|
|
def main():
|
|
"""
|
|
The main function.
|
|
|
|
Returns:
|
|
int: The process return code.
|
|
"""
|
|
results = unittest.main(exit=False)
|
|
return 0 if results.result.wasSuccessful() else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|