diff options
author | Steven Knight <knight@baldmt.com> | 2002-04-05 03:28:51 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-04-05 03:28:51 (GMT) |
commit | 863885a0df1f83b7e5b29f0370a865b4da330e24 (patch) | |
tree | 8733e9467a47c940d64b4940c21a763a9278af3e | |
parent | 3df4ee57235d30950d07b0b498387d5e16e67e6d (diff) | |
download | SCons-863885a0df1f83b7e5b29f0370a865b4da330e24.zip SCons-863885a0df1f83b7e5b29f0370a865b4da330e24.tar.gz SCons-863885a0df1f83b7e5b29f0370a865b4da330e24.tar.bz2 |
Fix various problems with --profile (Anthony Roach)
-rw-r--r-- | src/engine/SCons/Script/__init__.py | 10 | ||||
-rw-r--r-- | test/option--profile.py | 22 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 143fa19..126eb6b 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -156,6 +156,7 @@ print_dtree = 0 climb_up = 0 target_top = None exit_status = 0 # exit status, assume success by default +profiling = 0 # utility functions @@ -530,9 +531,12 @@ def options_init(): help = "Print internal environments/objects.") def opt_profile(opt, arg): - sys.argv = filter(lambda x: x[0:10] != "--profile=", sys.argv) - import profile - profile.run('SCons.Script.main()', arg) + global profiling + if not profiling: + profiling = 1 + import profile + profile.run('SCons.Script.main()', arg) + sys.exit(exit_status) Option(func = opt_profile, long = ['profile'], arg = 'FILE', diff --git a/test/option--profile.py b/test/option--profile.py index 4b8fd37..6d7efe4 100644 --- a/test/option--profile.py +++ b/test/option--profile.py @@ -53,5 +53,27 @@ test.fail_test(string.find(s, 'option_v') == -1) test.fail_test(string.find(s, 'SCons.Script.main()') == -1) test.fail_test(string.find(s, 'getopt.py') == -1) + +scons_prof = test.workpath('scons2.prof') + +test.run(arguments = "--profile %s -v " % scons_prof) +test.fail_test(string.find(test.stdout(), 'SCons by ') == -1) +test.fail_test(string.find(test.stdout(), 'Copyright') == -1) + +stats = pstats.Stats(scons_prof) +stats.sort_stats('time') + +sys.stdout = StringIO.StringIO() + +stats.strip_dirs().print_stats() + +s = sys.stdout.getvalue() + +test.fail_test(string.find(s, '__init__.py') == -1) +test.fail_test(string.find(s, 'option_v') == -1) +test.fail_test(string.find(s, 'SCons.Script.main()') == -1) +test.fail_test(string.find(s, 'getopt.py') == -1) + + test.pass_test() |