diff options
author | Steven Knight <knight@baldmt.com> | 2005-06-02 13:40:28 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-06-02 13:40:28 (GMT) |
commit | 8281e43014e93d8a8e674902410ba42e38355405 (patch) | |
tree | 70e700745fd48c5a42731cd63626b74f51e2ec8e | |
parent | 1d3c36ee983d5f26bbd9cf9733a8084eced1b2c4 (diff) | |
download | SCons-8281e43014e93d8a8e674902410ba42e38355405.zip SCons-8281e43014e93d8a8e674902410ba42e38355405.tar.gz SCons-8281e43014e93d8a8e674902410ba42e38355405.tar.bz2 |
Print statistics even when we terminate early (e.g. using -h).
-rw-r--r-- | src/engine/SCons/Script/Main.py | 47 | ||||
-rw-r--r-- | test/option/debug-count.py | 22 | ||||
-rw-r--r-- | test/option/debug-memoizer.py | 24 | ||||
-rw-r--r-- | test/option/debug-memory.py | 13 |
4 files changed, 60 insertions, 46 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 73f6a6c..cdf0139 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -295,12 +295,13 @@ class CountStats(Stats): l = len(self.stats) fmt1 = string.join(pre + [' %7s']*l + post, '') fmt2 = string.join(pre + [' %7d']*l + post, '') - self.labels.append(("", "Class")) - self.outfp.write(fmt1 % tuple(map(lambda x: x[0], self.labels))) - self.outfp.write(fmt1 % tuple(map(lambda x: x[1], self.labels))) + labels = self.labels[:l] + labels.append(("", "Class")) + self.outfp.write(fmt1 % tuple(map(lambda x: x[0], labels))) + self.outfp.write(fmt1 % tuple(map(lambda x: x[1], labels))) for k in keys: - r = stats_table[k] - self.outfp.write(fmt2 % (r[0], r[1], r[2], r[3], k)) + r = stats_table[k][:l] + [k] + self.outfp.write(fmt2 % tuple(r)) count_stats = CountStats() @@ -1174,25 +1175,7 @@ def _main(args, parser): SCons.SConsign.write() memory_stats.append('after building targets:') - memory_stats.print_stats() - count_stats.append(('post-', 'build')) - count_stats.print_stats() - - if print_objects: - SCons.Debug.listLoggedInstances('*') - #SCons.Debug.dumpLoggedInstances('*') - - if print_memoizer: - print "Memoizer (memory cache) hits and misses:" - SCons.Memoize.Dump() - - # Dump any development debug info that may have been enabled. - # These are purely for internal debugging during development, so - # there's no need to control them with --debug= options; they're - # controlled by changing the source code. - SCons.Debug.dump_caller_counts() - SCons.Taskmaster.dump_stats() def _exec_main(): all_args = sys.argv[1:] @@ -1234,6 +1217,24 @@ def main(): SCons.Script._SConscript.SConscript_exception() sys.exit(2) + memory_stats.print_stats() + count_stats.print_stats() + + if print_objects: + SCons.Debug.listLoggedInstances('*') + #SCons.Debug.dumpLoggedInstances('*') + + if print_memoizer: + print "Memoizer (memory cache) hits and misses:" + SCons.Memoize.Dump() + + # Dump any development debug info that may have been enabled. + # These are purely for internal debugging during development, so + # there's no need to control them with --debug= options; they're + # controlled by changing the source code. + SCons.Debug.dump_caller_counts() + SCons.Taskmaster.dump_stats() + if print_time: total_time = time.time()-SCons.Script.start_time scons_time = total_time-sconscript_time-command_time diff --git a/test/option/debug-count.py b/test/option/debug-count.py index ca627e8..3cb924b 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -56,11 +56,9 @@ test.write('file.in', "file.in\n") # Just check that object counts for some representative classes # show up in the output. -test.run(arguments = "--debug=count") -stdout = test.stdout() def find_object_count(s, stdout): - re_string = '\d+ +\d+ +\d+ +\d+ %s' % re.escape(s) + re_string = '\d+ +\d+ %s' % re.escape(s) return re.search(re_string, stdout) objects = [ @@ -73,14 +71,18 @@ objects = [ 'Node.Node', ] -missing = filter(lambda o: find_object_count(o, stdout) is None, objects) +for args in ['-h --debug=count', '--debug=count']: + test.run(arguments = args) + stdout = test.stdout() -if missing: - print "Missing the following object lines:" - print "\t", string.join(missing) - print "STDOUT ==========" - print stdout - test.fail_test(1) + missing = filter(lambda o: find_object_count(o, stdout) is None, objects) + + if missing: + print "Missing the following object lines from '%s' output:" % args + print "\t", string.join(missing) + print "STDOUT ==========" + print stdout + test.fail_test(1) test.pass_test() diff --git a/test/option/debug-memoizer.py b/test/option/debug-memoizer.py index 4249ca6..c9f001c 100644 --- a/test/option/debug-memoizer.py +++ b/test/option/debug-memoizer.py @@ -51,20 +51,20 @@ test.write('file.in', "file.in\n") expect = [ "Memoizer (memory cache) hits and misses", "Dir.exists()", - "Executor.get_contents()", - "File._save_str()", - "SConsEnvironment.get_calculator()", + "File.exists()", + "SConsEnvironment.Detect()", ] -test.run(arguments = '--debug=memoizer') -stdout = test.stdout() -missing = filter(lambda e, s=stdout: string.find(s, e) == -1, expect) -if missing: - print "Missing the following strings in the command line --debug=memoizer output:" - print " " + string.join(missing, "\n ") - print "STDOUT ============" - print stdout - test.fail_test(1) +for args in ['-h --debug=memoizer', '--debug=memoizer']: + test.run(arguments = args) + stdout = test.stdout() + missing = filter(lambda e, s=stdout: string.find(s, e) == -1, expect) + if missing: + print "Missing the following strings in the command line '%s' output:" % args + print " " + string.join(missing, "\n ") + print "STDOUT ============" + print stdout + test.fail_test(1) test.must_match('file.out', "file.in\n") diff --git a/test/option/debug-memory.py b/test/option/debug-memory.py index 3c3aebd..2812f50 100644 --- a/test/option/debug-memory.py +++ b/test/option/debug-memory.py @@ -54,7 +54,9 @@ env.Cat('file.out', 'file.in') test.write('file.in', "file.in\n") -test.run(arguments = "--debug=memory") + + +test.run(arguments = '--debug=memory') lines = string.split(test.stdout(), '\n') @@ -65,4 +67,13 @@ test.fail_test(re.match(r'Memory after building targets: +\d+', lines[-2]) is No +test.run(arguments = '-h --debug=memory') + +lines = string.split(test.stdout(), '\n') + +test.fail_test(re.match(r'Memory before reading SConscript files: +\d+', lines[-3]) is None) +test.fail_test(re.match(r'Memory after reading SConscript files: +\d+', lines[-2]) is None) + + + test.pass_test() |