def test_needs_compile(): main_files = ['test.css', 'test.less', 'test.js'] dependency_files = ['dependency.png'] try: manifest = run_compiler() raise Exception("should need compile") except NeedsCompilation: pass # This time, we should not need a recompile manifest = run_compiler(test_needs_compile=False) for key in main_files + dependency_files: assert key in manifest.assets assert len(manifest.blocks) == len(main_files) # But if any of the dependencies are modified, a recompile is needed for filename in main_files + dependency_files: with temporarily_alter_contents('static_dir/%s' % filename, '\n\n\n'): try: manifest = run_compiler() raise Exception("should need compile") except NeedsCompilation: pass # Sanity check that we still don't need a compile (since we should have # undone the changes above after the with block) manifest = run_compiler() files_to_upload = upload_assets_to_s3(manifest, get_settings(), skip_s3_upload=True) logging.debug(files_to_upload) assert len(files_to_upload) == 4
if settings['test_needs_compile']: raise NeedsCompilation() pool = multiprocessing.Pool() try: # See note above about bug in pool.map w/r/t KeyboardInterrupt. _compile_worker = CompileWorker(settings.get('skip_inline_images', False), current_manifest) pool.map_async(_compile_worker, to_compile).get(1e100) except CompileError, e: cmd, msg = e.args logging.error('Compile error!') logging.error('Command: %s', ' '.join(cmd)) logging.error('Error: %s', msg) raise Exception('Compilation Failed') #TODO: refactor to some chain of command for plugins if settings['aws_username']: upload_assets_to_s3(current_manifest, settings, skip_s3_upload=settings['skip_s3_upload']) if settings.get('merge_manifest_updates', True): cached_manifest.union(current_manifest) else: cached_manifest = current_manifest cached_manifest.write(settings=settings) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) options, args = parser.parse_args() settings = _create_settings(options) run(settings)
try: # See note above about bug in pool.map w/r/t KeyboardInterrupt. _compile_worker = CompileWorker( settings.get('skip_inline_images', False), current_manifest) pool.map_async(_compile_worker, to_compile).get(1e100) except CompileError, e: cmd, msg = e.args logging.error('Compile error!') logging.error('Command: %s', ' '.join(cmd)) logging.error('Error: %s', msg) raise Exception('Compilation Failed') #TODO: refactor to some chain of command for plugins if settings['aws_username']: upload_assets_to_s3(current_manifest, settings, skip_s3_upload=settings['skip_s3_upload']) if settings.get('merge_manifest_updates', True): cached_manifest.union(current_manifest) else: cached_manifest = current_manifest cached_manifest.write(settings=settings) return cached_manifest return current_manifest if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) options, args = parser.parse_args() settings = _create_settings(options)