diff -r 1ee45eb6aab9 Lib/compileall.py --- a/Lib/compileall.py Sat Nov 09 23:15:52 2013 +0200 +++ b/Lib/compileall.py Sun Nov 10 17:38:37 2013 +0800 @@ -229,7 +229,8 @@ success = False return success else: - return compile_path(legacy=args.legacy) + return compile_path(legacy=args.legacy, force=args.force, + quiet=args.quiet) except KeyboardInterrupt: print("\n[interrupted]") return False diff -r 1ee45eb6aab9 Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py Sat Nov 09 23:15:52 2013 +0200 +++ b/Lib/test/test_compileall.py Sun Nov 10 17:38:37 2013 +0800 @@ -5,8 +5,6 @@ import py_compile import shutil import struct -import subprocess -import sys import tempfile import time import unittest @@ -176,10 +174,24 @@ def test_no_args_compiles_path(self): # Note that -l is implied for the no args case. bazfn = script_helper.make_script(self.directory, 'baz', '') - self.assertRunOK(PYTHONPATH=self.directory) + noisy = self.assertRunOK(PYTHONPATH=self.directory) + self.assertIn(b'Listing', noisy) self.assertCompiled(bazfn) self.assertNotCompiled(self.initfn) self.assertNotCompiled(self.barfn) + pycpath = importlib.util.cache_from_source(bazfn) + # Set atime/mtime backward to avoid file timestamp resolution issues + os.utime(pycpath, (time.time()-60,)*2) + mtime = os.stat(pycpath).st_mtime + # Without force, no recompilation. On the other hand, use quiet flag. + quiet = self.assertRunOK('-q', PYTHONPATH=self.directory) + mtime2 = os.stat(pycpath).st_mtime + self.assertEqual(mtime, mtime2) + self.assertNotIn(b'Listing', quiet) + # Now force it. + self.assertRunOK('-f', PYTHONPATH=self.directory) + mtime2 = os.stat(pycpath).st_mtime + self.assertNotEqual(mtime, mtime2) # Ensure that the default behavior of compileall's CLI is to create # PEP 3147 pyc/pyo files.