Commits

Anonymous committed b2806e7

Fix various problems with --profile (Anthony Roach)

Comments (0)

Files changed (2)

src/engine/SCons/Script/__init__.py

 climb_up = 0
 target_top = None
 exit_status = 0 # exit status, assume success by default
+profiling = 0
 
 # utility functions
 
 	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',

test/option--profile.py

 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()