Skip to content

Commit 948e8af

Browse files
committed
Add custom up_to_date for TimeSCons to handle individual SConscript timing output during null build run
1 parent ebd2adb commit 948e8af

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

testing/framework/TestSCons.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,11 @@ def null(self, *args, **kw):
18231823
# TODO(sgk): allow the caller to specify the target (argument)
18241824
# that must be up-to-date.
18251825
self.add_timing_options(kw)
1826-
self.up_to_date(arguments='.', **kw)
1826+
1827+
# Build up regex for
1828+
# SConscript:/private/var/folders/ng/48pttrpj239fw5rmm3x65pxr0000gn/T/testcmd.12081.pk1bv5i5/SConstruct took 533.646 ms
1829+
read_str = 'SConscript:.*\n'
1830+
self.up_to_date(arguments='.', read_str=read_str, **kw)
18271831
sys.stdout.write(self.stdout())
18281832
stats = self.collect_stats(self.stdout())
18291833
# time-commands should always be 0.0 on a null build, because
@@ -1885,6 +1889,27 @@ def copy_timing_configuration(self, source_dir, dest_dir):
18851889
destination = source.replace(source_dir, dest_dir)
18861890
shutil.copy2(source, destination)
18871891

1892+
def up_to_date(self, arguments='.', read_str="", **kw):
1893+
"""Asserts that all of the targets listed in arguments is
1894+
up to date, but does not make any assumptions on other targets.
1895+
This function is most useful in conjunction with the -n option.
1896+
Note: This custom version for timings tests does NOT escape
1897+
read_str.
1898+
"""
1899+
s = ""
1900+
for arg in arguments.split():
1901+
s = s + "scons: `%s' is up to date.\n" % arg
1902+
kw['arguments'] = arguments
1903+
stdout = self.wrap_stdout(read_str="REPLACEME", build_str=s)
1904+
# Append '.*' so that timing output that comes after the
1905+
# up-to-date output is okay.
1906+
stdout = re.escape(stdout) + '.*'
1907+
stdout = stdout.replace('REPLACEME', read_str)
1908+
kw['stdout'] = stdout
1909+
kw['match'] = self.match_re_dotall
1910+
self.run(**kw)
1911+
1912+
18881913

18891914
# In some environments, $AR will generate a warning message to stderr
18901915
# if the library doesn't previously exist and is being created. One

0 commit comments

Comments
 (0)