diff options
author | Mats Wichmann <mats@linux.com> | 2022-06-26 19:07:57 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2022-06-30 18:51:31 (GMT) |
commit | 3fc497c7775f572a32056a1c6b52ee4592c4bced (patch) | |
tree | f5b272619e1fc945a93e59d462dd2acfdd97b22b /testing | |
parent | 07dc10b25b6169c9fb7e16dd78de8bb9ea107be6 (diff) | |
download | SCons-3fc497c7775f572a32056a1c6b52ee4592c4bced.zip SCons-3fc497c7775f572a32056a1c6b52ee4592c4bced.tar.gz SCons-3fc497c7775f572a32056a1c6b52ee4592c4bced.tar.bz2 |
Improvements to lex and yacc tools
The mocked tools mylex.py and myyacc.py now understand the file-generation
options, and generate a dummy file with predictable contents, for
checking. This allows more testing of the path through the SCons support
for these two without needing live commands.
New tests added which invoke the file-generation options, and make
sure the extra files are created, and that SCons detects and tracks
the added targets. Work is done in a subdirectory, which exposes some
existing known inconsistent behavior (the regular generated file goes
in the subdir per the LEXCOM and YACCOM generated line, while the ones
generated from commandline options go in the topdir) - but we're going
to allow that behavior to continue for backwards compat.
Same fix applied to yacc tool that PR #4168 did for lex - do subst_list()
instead of subst() to preserve spaces in paths. That fix left the lex
tool unable to pass the new test, as it could not see the individual
arguments in the FLAGS variable, which was solved by indexing into the
subst'd list so we can iterate over the args again.
Test and tool cleanup; add DefaultEnvironment calls, etc.
Note this mentions, but does not address the problem described in issue 4154.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/framework/TestSCons.py | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index ec82102..4e8e93b 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -422,20 +422,35 @@ class TestSCons(TestCommon): return None - def wrap_stdout(self, build_str="", read_str="", error=0, cleaning=0): - """Wraps standard output string(s) in the normal - "Reading ... done" and "Building ... done" strings + def wrap_stdout(self, build_str="", read_str="", error=0, cleaning=0) -> str: + """Wraps "expect" strings in SCons boilerplate. + + Given strings of expected output specific to a test, + returns a string which includes the SCons wrapping such as + "Reading ... done", etc.: that is, adds the text that would + be left out by running SCons in quiet mode; + Makes a complete message to match against. + + Args: + read_str: the message for the execution part of the output. + If non-empty, needs to be newline-terminated. + read_str: the message for the reading-sconscript part of + the output. If non-empty, needs to be newline-terminated. + error: if true, expect a fail message rather than a done message. + cleaning (int): index into type messages, if 0 selects + build messages, if 1 selects clean messages. """ cap, lc = [('Build', 'build'), ('Clean', 'clean')][cleaning] if error: - term = "scons: %sing terminated because of errors.\n" % lc + term = f"scons: {lc}ing terminated because of errors.\n" else: - term = "scons: done %sing targets.\n" % lc + term = f"scons: done {lc}ing targets.\n" + return "scons: Reading SConscript files ...\n" + \ read_str + \ "scons: done reading SConscript files.\n" + \ - "scons: %sing targets ...\n" % cap + \ + f"scons: {cap}ing targets ...\n" + \ build_str + \ term @@ -718,12 +733,12 @@ class TestSCons(TestCommon): for p in patterns: result.extend(sorted(glob.glob(p))) return result - + def get_sconsignname(self): """Get the scons database name used, and return both the prefix and full filename. if the user left the options defaulted AND the default algorithm set by SCons is md5, then set the database name to be the special default name - + otherwise, if it defaults to something like 'sha1' or the user explicitly set 'md5' as the hash format, set the database name to .sconsign_<algorithm> eg .sconsign_sha1, etc. @@ -857,7 +872,7 @@ class TestSCons(TestCommon): Args: version: if set, match only that version - Returns: + Returns: path where JDK components live Bails out of the entire test (skip) if not found. """ |