Commit 03b6e3b2 by Ben Patterson

FEDX-152. Pipe collectstatic results to a file for bok-choy tests.

parent 39c2abdf
......@@ -641,14 +641,16 @@ def restart_django_servers():
))
def collect_assets(systems, settings):
def collect_assets(systems, settings, output_file):
"""
Collect static assets, including Django pipeline processing.
`systems` is a list of systems (e.g. 'lms' or 'studio' or both)
`settings` is the Django settings module to use.
"""
for sys in systems:
sh(django_cmd(sys, settings, "collectstatic --noinput > /dev/null"))
sh(django_cmd(sys, settings, "collectstatic --noinput > {logfile}".format(
logfile=output_file
)))
print("\t\tFinished collecting {} assets.".format(sys))
......@@ -763,6 +765,10 @@ def update_assets(args):
'--themes', type=str, nargs='+', default=None,
help="list of themes to compile sass for",
)
parser.add_argument(
'--collect-log', dest='collect_log_file', default="/dev/null",
help="When running collectstatic, direct output to this log file",
)
args = parser.parse_args(args)
compile_templated_sass(args.system, args.settings)
......@@ -774,7 +780,7 @@ def update_assets(args):
execute_compile_sass(args)
if args.collect:
collect_assets(args.system, args.settings)
collect_assets(args.system, args.settings, args.collect_log_file)
if args.watch:
call_task(
......
......@@ -213,8 +213,8 @@ def run_all_servers(options):
# means that the optimized assets are ignored, so we skip collectstatic in that
# case to save time.
if settings != DEFAULT_SETTINGS:
collect_assets(['lms'], asset_settings_lms)
collect_assets(['studio'], asset_settings_cms)
collect_assets(['lms'], asset_settings_lms, "/dev/null")
collect_assets(['studio'], asset_settings_cms, "/dev/null")
# Install an asset watcher to regenerate files that change
call_task('pavelib.assets.watch_assets', options={'background': True})
......
......@@ -155,7 +155,7 @@ class BokChoyTestSuite(TestSuite):
sh("{}/scripts/reset-test-db.sh".format(Env.REPO_ROOT))
if not self.fasttest:
self.generate_optimized_static_assets()
self.generate_optimized_static_assets(log_dir=self.log_dir)
# Clear any test data already in Mongo or MySQLand invalidate
# the cache
......
......@@ -5,7 +5,7 @@ import sys
import subprocess
from paver import tasks
from paver.easy import sh
from paver.easy import sh, call_task
from pavelib.utils.process import kill_process
......@@ -61,13 +61,21 @@ class TestSuite(object):
"""
return None
def generate_optimized_static_assets(self):
def generate_optimized_static_assets(self, log_dir=None):
"""
Collect static assets using test_static_optimized.py which generates
optimized files to a dedicated test static root.
optimized files to a dedicated test static root. Optionally use
a log file for collectstatic output.
"""
opts_dict = {'settings': 'test_static_optimized'}
if log_dir:
opts_dict.update({'collect_log_file': log_dir})
print colorize('green', "Generating optimized static assets...")
sh("paver update_assets --settings=test_static_optimized")
call_task(
"pavelib.assets.update_assets",
args=opts_dict
)
# sh("paver update_assets --settings=test_static_optimized")
def run_test(self):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment