summaryrefslogtreecommitdiffstats
path: root/testing/framework/TestCommon.py
Commit message (Collapse)AuthorAgeFilesLines
* test framework: bulk reformatMats Wichmann2024-12-291-74/+104
| | | | | | Imcludes test snippets contained in docstrings, too. Signed-off-by: Mats Wichmann <mats@linux.com>
* Modernize stat usageMats Wichmann2024-12-151-1/+1
| | | | | | | | | | | Since Python 2.2, the object returned by an os.stat() call presents attributes matching the 10-tuple of stat values. Use these instead of indexing into the tuple. As usual for non-removed tests, minor tweaks made if needed - copyright header and DefautlEnvironment() call for performance. Signed-off-by: Mats Wichmann <mats@linux.com>
* Integrate `from __future__ import annotations`Thaddeus Crews2024-11-161-21/+23
|
* Some tweaks to testing framework.Mats Wichmann2024-09-101-100/+160
| | | | | | | | | | | | | | | | | | | | | | | Most interesting is an "api change" - the test methods test.must_exist() and test.must_exist_one_of() now take an optional 'message' keyword argument which is passed on to fail_test() if the test fails. The regex used to test an exception is now working for Python 3.13, and enabled conditionally - the "enhanced error reporting" changed, in a way that made it easy to reuse the existing regex (if somebody wants to take a shot at unifying them, more power!). Also one unexpected issue was found - one of the check routines does "output = os.newline.join(output)", but there is no os.newline. Could use os.linesep, but just changed it to the Python newline character. Some annotations added, and some cleanup done on possibly unsafe uses - mainly that self.stderr() and selt.stdout() *can* return None, but several places in the code just did string operations on the return unconditionally. There's already precendent- other places did do a check before using, so just extended the concept to possibly vulnerable palces. Signed-off-by: Mats Wichmann <mats@linux.com>
* More conversions: {repr(var)} -> {var!r}Mats Wichmann2023-08-041-6/+6
| | | | | | | Some of these got done in the tool conversion, some not, so picked up the rest manually. Signed-off-by: Mats Wichmann <mats@linux.com>
* Add some cheap return and parameter annotationsMats Wichmann2023-05-011-26/+26
| | | | | | | | | | | | | | | | | Use: https://github.com/JelleZijlstra/autotyping to add "safe" return annotations. Where a parameter has a default value that is an obvious scalar type (bool, int, str, etc.) add those annotations as well. Also fixed two small bugs that popped up when sanity-checking with mypy. One in FortranCommon, where a return had been previously annotated to be a tuple of Action, which should be ActionBase - Action is the factory function, not the base class. The other was a typo in the error raised in _add_cppdefines - the message was formatted with the value of "define" which should have been "defines". Signed-off-by: Mats Wichmann <mats@linux.com>
* Merge branch 'master' of github.com:SCons/scons into ↵William Deegan2022-12-041-30/+46
|\ | | | | | | add_logging_to_new_parallel_job
| * Use f-strings in framework and framework testsMats Wichmann2022-11-241-33/+33
| | | | | | | | | | | | | | | | | | This is a mostly tool-based conversion (a couple added by hand), and other changes were not made, to try to keep the diff manageable. Adds a GitHub Action to run framework tests if framework changes. Signed-off-by: Mats Wichmann <mats@linux.com>
| * Fixed taskmaster trace tests. Previously there was an extra line at the end ↵William Deegan2022-10-261-0/+16
| | | | | | | | of the file. It's no longer there. Added TestCommon.detailed_diff() function which can be used to diff large text blobs expected vs actual
* | Added TestCommon.must_match_file() function. Updated test for ↵William Deegan2022-12-041-0/+21
|/ | | | --taskmastertracefor (NewParallel/LegacyParallel Jobs). Now uses golden files to compare expected output and output files
* [framewqork] use subprocess timeoutsMats Wichmann2022-08-061-3/+3
| | | | | | | | | | | | Since Python 3.3, the subprocess module has its own timeout implementation, so remove the test framework's custom one. Required a little rejigger since the subprocess timeout is done on the communicate() call, not set up before the test is started. Noted that the framework intends to support two levels: one for the testing class instance, and one for an individual start call, which should override the one in the instance. Signed-off-by: Mats Wichmann <mats@linux.com>
* If no newline at end of message supplied to skip_test(), then we write one ↵William Deegan2022-06-031-0/+2
| | | | to stdout after the original message
* Use super call instead of direct class callMats Wichmann2022-03-151-1/+1
| | | | | | | | | - super used where direct call to superclass existed - convert a few older-style super() (two-argument) uses - in a few places, where there was an intersection with a super change, variables that override a builtin (e.g. "dict") were renamed. Signed-off-by: Mats Wichmann <mats@linux.com>
* Test tweaks to help testing on mingw-only win32 systemsMats Wichmann2021-04-141-4/+0
| | | | | | | | | | | | | | | | On a system where SCons is started from the mingw bash shell, and mingw Python is the interpreter, the secondary self-identification differs. Use that in a few tests which otherwise make the wrong decision. EnvironmentTests used an invalid value for CCFLAGS, and empty string is a better choice. Change a couple of cases where Python code was run directly so it's prefixed by the-Python-in-use, which fails if there is not a Windows-registered program for .py files - we didn't really want to use the Windows-native Python anyway. Signed-off-by: Mats Wichmann <mats@linux.com>
* Test harness add a from_fw to skip callsMats Wichmann2021-04-131-36/+53
| | | | | | | | | | | | | | | | | | Main functional change is a new kwarg to skip_test() to allow calls from inside the framework to skip an additional line of traceback in the skip output - i.e. don't just skip the entry for skip_test, but also the function in the fw that called it. Other functional change is for the try block in skip_if_not_msvc() (which is one of the internal callers of skip_test() mentioned for the other change) to catch Exception, thus avoiding system-existing exceptions that were caught by the existing bare except, which caused the skip to not actually skip. The remainder of the patch is docstring reformatting, some minor code reformats, top-of-file license blocks, etc. Signed-off-by: Mats Wichmann <mats@linux.com>
* fix sider issuesDaniel Moody2021-04-051-1/+0
|
* improved DoubleCacheDir test, added extra cachedir validation check.Daniel Moody2021-04-051-3/+31
|
* Run autoflake on codeMats Wichmann2020-09-211-1/+0
| | | | | | | | | | Eliminate unneeded imports, and a few unneeded statements - usually "pass" where it is not syntactically needed. A couple of import try blocks were eliminated or changed when they're "cannot happen" due to current floor Python version. Signed-off-by: Mats Wichmann <mats@linux.com>
* Fixed Docbook Tool and updated its tests.Dirk Baechle2020-06-211-0/+19
|
* Cleanups in tests and in frameworkMats Wichmann2020-06-141-6/+2
| | | | | | | | | | | | * Some Py2/Py3 compat blocks were simplified to Py3 only * some sequences of define-cleaup-function + atexit.register were changed to use the decorator (this works if func needs to take no arguments) * Lightly update a bunch of docstrings in TestCmd, and reformat a few places, towards the style we're generally using now. * call_python() in TestCmdTests was modernized to use subprocess.run Signed-off-by: Mats Wichmann <mats@linux.com>
* rm-py2: Remove "from __future__" from more placesMats Wichmann2020-02-201-2/+0
| | | | | | | | | | | | | | | A couple of minor reformats along the way, most prominently, in tests, if being edited anyway, make sure the docstring most tests have is actually the docstring (sometimes the __revision__ line came before, which makes the string not be the docstring). Snuck in some minor framework changes that were orphaned when another draft PR was not needed: this almost all docstring changes, the functional part is using casefold instead of lower in a match func - a slightly better approach which is now possible that Py2 compatibility is not needed. Signed-off-by: Mats Wichmann <mats@linux.com>
* Fix incorrect testing assumptions for SolarisJakub Kulik2019-11-011-2/+2
|
* Merge remote-tracking branch 'upstream/master' into ↵William Deegan2018-10-151-63/+42
|\ | | | | | | fix_java_tests_path_with_spaces
| * fixed minor typosPaweł Tomulik2018-10-051-5/+5
| |
| * fixed some docs in TestCommon.py and refactored a littlePaweł Tomulik2018-10-051-59/+39
| |
| * make the must[_not]_contain_...() functions compatible with str.findPaweł Tomulik2018-10-051-9/+9
| |
| * fixed bugs in must_[not_]_contain()Paweł Tomulik2018-10-051-6/+5
| |
* | Add test for 1.8. Modularize java tests and move files to a fixture. Change ↵William Deegan2018-10-011-3/+8
|/ | | | TestCommon's options_arguments to keep passed lists and not join them into a string.
* Try a more scons-y file conversion for Py3 file readsMats Wichmann2018-07-311-8/+16
| | | | | | | | | | Instead of custom conversion as in the previous iteration, use the to_bytes function. The two known tests which incorrectly let the text-mode xml file be opened in binary mode are adjusted to supply mode='r' Signed-off-by: Mats Wichmann <mats@linux.com>
* Testing: python 3 fix for must_containMats Wichmann2018-07-251-0/+9
| | | | | | | | | | | | | | TestCommon defines a method must_contain which checks for a file including a given string. With Python 3, the test runs into some typing problems. This could be fixed either by changing all the tests which call the routine either omitting the mode argument (which then defaults to 'rb'), or specifying a mode which includes 'b'; or by modifying must_contain to align the types of the file data and the data to check for. This patch uses the latter approach. This is a test-only change, no run-time scons code is modified. Signed-off-by: Mats Wichmann <mats@linux.com>
* move test files from QMTest to testing/framework. QMtest hasn't been used in ↵William Deegan2018-04-301-0/+748
quite some time