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(): ...@@ -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. Collect static assets, including Django pipeline processing.
`systems` is a list of systems (e.g. 'lms' or 'studio' or both) `systems` is a list of systems (e.g. 'lms' or 'studio' or both)
`settings` is the Django settings module to use. `settings` is the Django settings module to use.
""" """
for sys in systems: 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)) print("\t\tFinished collecting {} assets.".format(sys))
...@@ -763,6 +765,10 @@ def update_assets(args): ...@@ -763,6 +765,10 @@ def update_assets(args):
'--themes', type=str, nargs='+', default=None, '--themes', type=str, nargs='+', default=None,
help="list of themes to compile sass for", 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) args = parser.parse_args(args)
compile_templated_sass(args.system, args.settings) compile_templated_sass(args.system, args.settings)
...@@ -774,7 +780,7 @@ def update_assets(args): ...@@ -774,7 +780,7 @@ def update_assets(args):
execute_compile_sass(args) execute_compile_sass(args)
if args.collect: if args.collect:
collect_assets(args.system, args.settings) collect_assets(args.system, args.settings, args.collect_log_file)
if args.watch: if args.watch:
call_task( call_task(
......
...@@ -213,8 +213,8 @@ def run_all_servers(options): ...@@ -213,8 +213,8 @@ def run_all_servers(options):
# means that the optimized assets are ignored, so we skip collectstatic in that # means that the optimized assets are ignored, so we skip collectstatic in that
# case to save time. # case to save time.
if settings != DEFAULT_SETTINGS: if settings != DEFAULT_SETTINGS:
collect_assets(['lms'], asset_settings_lms) collect_assets(['lms'], asset_settings_lms, "/dev/null")
collect_assets(['studio'], asset_settings_cms) collect_assets(['studio'], asset_settings_cms, "/dev/null")
# Install an asset watcher to regenerate files that change # Install an asset watcher to regenerate files that change
call_task('pavelib.assets.watch_assets', options={'background': True}) call_task('pavelib.assets.watch_assets', options={'background': True})
......
...@@ -155,7 +155,7 @@ class BokChoyTestSuite(TestSuite): ...@@ -155,7 +155,7 @@ class BokChoyTestSuite(TestSuite):
sh("{}/scripts/reset-test-db.sh".format(Env.REPO_ROOT)) sh("{}/scripts/reset-test-db.sh".format(Env.REPO_ROOT))
if not self.fasttest: 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 # Clear any test data already in Mongo or MySQLand invalidate
# the cache # the cache
......
...@@ -5,7 +5,7 @@ import sys ...@@ -5,7 +5,7 @@ import sys
import subprocess import subprocess
from paver import tasks from paver import tasks
from paver.easy import sh from paver.easy import sh, call_task
from pavelib.utils.process import kill_process from pavelib.utils.process import kill_process
...@@ -61,13 +61,21 @@ class TestSuite(object): ...@@ -61,13 +61,21 @@ class TestSuite(object):
""" """
return None 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 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...") 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): 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